PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
Handling WM_USER messages
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
Handling WM_USER messages
![]() |
Handling WM_USER messages |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Does anyone know how a C#/Forms application might handle a
user defined windows message. I need to do it for migratin reasons. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Try it, just an idea! *gasp!*
"Bob Kirkwood" <kirkwood@k6mfg.com> wrote in message news:047d01c3a313$71a37630$a101280a@phx.gbl... > Does anyone know how a C#/Forms application might handle a > user defined windows message. I need to do it for > migratin reasons. |
|
|
|
#3 |
|
Guest
Posts: n/a
|
If you send it and process it, why not.
Its just a number. "Bob Kirkwood" <kirkwood@k6mfg.com> wrote in message news:047d01c3a313$71a37630$a101280a@phx.gbl... > Does anyone know how a C#/Forms application might handle a > user defined windows message. I need to do it for > migratin reasons. |
|
|
|
#4 |
|
Guest
Posts: n/a
|
On Tue, 4 Nov 2003 12:37:20 -0800, Bob Kirkwood wrote:
> Does anyone know how a C#/Forms application might handle a > user defined windows message. I need to do it for > migratin reasons. The Form has WndProc that you can overload to catch those messages in a form. I think the Application class has a SetMessageFilter method thay may help you. Chris -- Chris To send me an E-mail, remove the underscores and lunchmeat from my E-Mail address. |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Hi Bob,
Chris has given some idea on this issue, and I'd like to expand the solution. In Win32, we often handle the messages in wndproc , Now in WinForm the WndProc still exists, every class derived from Control class have a protected method named WndProc, you can override this method to handle your own message of that control. Here is some snippet to show how to do this. <code> protected override void WndProc(ref Message m) { const int WM_USER = 0x0400; If(m.Msg == WM_USER) { //call your handler here. } base.WndProc(ref m); } </code> Also if you need to handle the message before it is dispatched, you may implement the IMessageFilter interface to do this job, You can add a MessageFilter to the MessageLoop by the Application.AddMessageFilter method, to get more information on and sample code on this topic you may take a look at the this link: <Application.AddMessageFilter Method> http://msdn.microsoft.com/library/d...-us/cpref/html/ frlrfsystemwindowsformsapplicationclassaddmessagefiltertopic.asp Does this answer your problem? Please be free to reply to this group, if you have anything unclear on it. Thanks! Best regards, Ying-Shen Yu [MSFT] Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties and confers no rights. You should not reply this mail directly, "Online" should be removed before sending, Thanks! |
|
|
|
#6 |
|
Guest
Posts: n/a
|
WndProc was not sufficient, many messages arrived there,
but not my WM_USER message (actually WM_USER + 1). Calling Application.AddMessageFilter (mymsgfilter) did work. Thanks for the help. >-----Original Message----- >Does anyone know how a C#/Forms application might handle a >user defined windows message. I need to do it for >migratin reasons. >. > |
|
|
|
#7 |
|
Guest
Posts: n/a
|
Why doesnt WndProc allow processing of ALL mesages? Sounds stupid.
I would expect all messages to be available there and its up to me to process what I need. "Bob Kirkwood" <kirkwood@k6mfg.com> wrote in message news:0d0101c3a39d$55c20f00$a401280a@phx.gbl... > WndProc was not sufficient, many messages arrived there, > but not my WM_USER message (actually WM_USER + 1). > > Calling Application.AddMessageFilter (mymsgfilter) did > work. Thanks for the help. > > >-----Original Message----- > >Does anyone know how a C#/Forms application might handle > a > >user defined windows message. I need to do it for > >migratin reasons. > >. > > > > |
|
|
|
#8 |
|
Guest
Posts: n/a
|
Hi,
Every class derived by control has an WndProc, probably in this case, the overridden WndProc was not in the control which the WM_USER message posted to. Anyway, IMessageFilter will work, because it will get all messages from the message queue. Best regards, Ying-Shen Yu [MSFT] Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties and confers no rights. You should not reply this mail directly, "Online" should be removed before sending, Thanks! |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

