Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Handling WM_USER messages

12 views
Skip to first unread message

Bob Kirkwood

unread,
Nov 4, 2003, 3:37:20 PM11/4/03
to
Does anyone know how a C#/Forms application might handle a
user defined windows message. I need to do it for
migratin reasons.

discu...@discussion.microsoft.com

unread,
Nov 4, 2003, 4:22:25 PM11/4/03
to
Try it, just an idea! *gasp!*


"Bob Kirkwood" <kirk...@k6mfg.com> wrote in message
news:047d01c3a313$71a37630$a101...@phx.gbl...

discu...@discussion.microsoft.com

unread,
Nov 4, 2003, 4:22:39 PM11/4/03
to
If you send it and process it, why not.

Its just a number.


"Bob Kirkwood" <kirk...@k6mfg.com> wrote in message
news:047d01c3a313$71a37630$a101...@phx.gbl...

Chris Dunaway

unread,
Nov 4, 2003, 4:30:00 PM11/4/03
to

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.

Ying-Shen Yu[MSFT]

unread,
Nov 5, 2003, 4:53:36 AM11/5/03
to
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/default.asp?url=/library/en-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!

Bob Kirkwood

unread,
Nov 5, 2003, 8:04:24 AM11/5/03
to
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.

>.
>


news.microsoft.com

unread,
Nov 5, 2003, 8:26:20 AM11/5/03
to
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" <kirk...@k6mfg.com> wrote in message

news:0d0101c3a39d$55c20f00$a401...@phx.gbl...

Ying-Shen Yu[MSFT]

unread,
Nov 5, 2003, 9:11:24 PM11/5/03
to
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.
0 new messages