PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Handling WM_USER messages

Reply

Handling WM_USER messages

 
Thread Tools Rate Thread
Old 04-11-2003, 08:37 PM   #1
Bob Kirkwood
Guest
 
Posts: n/a
Default Handling WM_USER messages


Does anyone know how a C#/Forms application might handle a
user defined windows message. I need to do it for
migratin reasons.
  Reply With Quote
Old 04-11-2003, 09:22 PM   #2
Guest
 
Posts: n/a
Default Re: Handling WM_USER messages

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.



  Reply With Quote
Old 04-11-2003, 09:22 PM   #3
Guest
 
Posts: n/a
Default Re: Handling WM_USER messages

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.



  Reply With Quote
Old 04-11-2003, 09:30 PM   #4
Chris Dunaway
Guest
 
Posts: n/a
Default Re: Handling WM_USER messages

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.
  Reply With Quote
Old 05-11-2003, 09:53 AM   #5
Ying-Shen Yu[MSFT]
Guest
 
Posts: n/a
Default RE: Handling WM_USER messages

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!

  Reply With Quote
Old 05-11-2003, 01:04 PM   #6
Bob Kirkwood
Guest
 
Posts: n/a
Default Handling WM_USER messages

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.
>.
>



  Reply With Quote
Old 05-11-2003, 01:26 PM   #7
news.microsoft.com
Guest
 
Posts: n/a
Default Re: Handling WM_USER messages

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.
> >.
> >

>
>



  Reply With Quote
Old 06-11-2003, 02:11 AM   #8
Ying-Shen Yu[MSFT]
Guest
 
Posts: n/a
Default Re: Handling WM_USER messages

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!

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off