C# event processing and windows messages

  • Thread starter Thread starter Ubergeek
  • Start date Start date
U

Ubergeek

I have some legacy (C) code that I wnat to use to raise events in a C#
component. Basically, when a condition is true (in the C code), I want
to send a WM_ message (using Win32 API from the C code) to a C#
"listener" component which will then handle the event and any data sent.

So basically (in my C code):

void foo()
{
....
SendMessage(hWnd, Msg, wParam, lParam) ;
...
}

And in my C# code :

void EventSink(....)
{
//Code goes here -
//I don't know how to capture and process the message sent !
}
 
Ubergeek said:
I have some legacy (C) code that I wnat to use to raise events in a C#
component. Basically, when a condition is true (in the C code), I want
to send a WM_ message (using Win32 API from the C code) to a C#
"listener" component which will then handle the event and any data sent.
//I don't know how to capture and process the message sent !

Override WndProc or PreProcessMessage in your form. Or, if you don't
have a form, and your message pump was started with Application.Run,
you can use Application.AddMessageFilter (not 100% sure this is the
correct way in this situation).
 
Back
Top