Posting and Handling Custom Messages (WM_USER type)

  • Thread starter Thread starter Brian Reed
  • Start date Start date
B

Brian Reed

I would like to handle custom messages in my windows form/application. In
ATL, I derived from CWindowImpl and added message handlers to my message
map. In VB Code requires me to hook into the WinProc to handle messages.
How can I achieve the same thing in C#? Do I have to hook into the WinProc,
or can I just add message handlers?
 
You may want to take a look at Control.BeginInvoke(). It can take the
place of many of the things you would usually use custom messages for;
essentially it's a PostMessage(WM_USER) with a delegate carried along.

If you do need to use custom messages instead, then you need to override
WndProc() to catch them.
 
Back
Top