473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Cannot catch WM_CLOSE in IMessageFilter.PreFilterMessage

Dear All,

i want to catch the application event (WM_CLOSE) in a user control.

i create a class that implement the IMessageFIlter interface as
follow:

'================================================= ==
Imports System.Windows.Forms
Public Class ClosingControl
Inherits System.Windows.Forms.UserControl
Implements IMessageFilter

Private gbClosed As Boolean = False

Function PreFilterMessage(ByRef m As Message) As Boolean Implements
IMessageFilter.PreFilterMessage

Dim WM_CLOSE As Integer = &H10

If m.Msg = WM_CLOSE Then

gbClosed = True

MsgBox("close")

End If

Return False

End Function

Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load

Application.AddMessageFilter(me)

End Sub

End Class

'================================================= ==

in a window form, i add an instance of the ClosingControl
(ClosingControl1) to the window form (say Form1).
but when i press the upper right 'X' close button of the window form,
Form1, the PreFilterMessage can't catch the WM_CLOSE message..

i check that there is no such message passing into the function
PreFilterMessage...

can anybody tell me why?
how can i catch the application exit signal in a user control?
(for some reason, i can't use the Form.close event, as the user
control
will be hosted in internet explorer)

thank you very much

lsp

Aug 12 '07 #1
0 1864

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: See Sharp | last post by:
Hello all, I have a form class that implements the imessagefilter interface public class frmMain : System.Windows.Forms.Form, IMessageFilter I also have this implemented bool...
7
by: Michael Culley | last post by:
I've added an IMessageFilter to my app but I don't get messages or I get only a few and then it stops. My code is very simple. Am I doing something wrong? public class MF : IMessageFilter {...
5
by: Tony | last post by:
Hi, I am looking for the opposite of wm_close, I assume it's possibly wm_open but no info comes up with that term. so, what is the opposite of WM_Close Any ideas welcome Tony
0
by: Whitney Kew | last post by:
Hi there, I want to implement the COM interface IMessageFilter from my VB.NET application. I realize that it's inside ole32.dll, and that ole32.dll doesn't have a type library inside of it, so...
1
by: Neil Stevens | last post by:
Hi, I am in the process of developing a popup utility for a project i am working on, the basic idea is that when a user presses the control key a popup menu will be displayed listing the shortcut...
4
by: GrandpaB | last post by:
Hi, I recently had a post about how to block Mousewheel events. The answer was to implement an IMessageFilter. Sadly, I must report that after 24 hours of researching my library and online...
4
by: ThunderMusic | last post by:
Hi, I'm developping a form that renders differently when hovered and trigger some processing when not hovered (leaved). The thing is, when I leave my form and another form from my application is...
4
by: =?Utf-8?B?am9obmY=?= | last post by:
Trying to get a see windows messages using IMessageFilter interface however it does not seem to get all window messages. Specifically I am looking for the WM_POWERBROADCAST. I override wndproc...
4
by: Ashish Gupra | last post by:
Hi, I want to use 'IMessageFilter' interface to monitor my Key and mouse events to let me know the idle time of my application. But this interface nt works fine. 'PreFilterMessage' function of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.