Sending a custom Windows message

  • Thread starter Thread starter Dmitry
  • Start date Start date
D

Dmitry

Hi,

can anybody tell me if there is a way to define and send a custom windows
message to a window and to specify
a handler function for it in C#?

The reason I'm asking this is following - I use some 3d party component that
start its own threads. When my
command is executed by this component it invokes my callback in the context
of its thread. But
I need to somehow update my GUI after that. I can't access my GUI controls
from this callback (get an
exception - wrong thread or something like that), so I thought that if I
could place a message into my app's
message queue then I could handle this situation properly.

Thanks in advance!

Regards,
Dmitry.
 
Just one more thing - can I get away with using
Application.AddMessageFilter
instead of overriding Control.WndProc ? If, say, my implementation of the
filter
modified some GUI controls this would ultimately end up in sending some
"normal"
messages into my app's message queue etc. Is there any hidden problem with
this approach?

Thanks,
Dmitry.
 
Dmitry,
I believe so, I forget about AddMessageFilter.

I have not really used AddMessageFilter to say if there are any hidden
problems or not.

Hope this helps
Jay
 
Thank you very much, I really appreciate your help!

Regards,
Dmitry.

Jay B. Harlow said:
Dmitry,
I believe so, I forget about AddMessageFilter.

I have not really used AddMessageFilter to say if there are any hidden
problems or not.

Hope this helps
Jay

Dmitry said:
Just one more thing - can I get away with using
Application.AddMessageFilter
instead of overriding Control.WndProc ? If, say, my implementation of the
filter
modified some GUI controls this would ultimately end up in sending some
"normal"
messages into my app's message queue etc. Is there any hidden problem with
this approach?

Thanks,
Dmitry.
http://msdn.microsoft.com/vbasic/us...ary/en-us/dnwinforms/html/wnf_richtextbox.asp if
 
How about solving the original problem instead :-)
To update your GUI from another thread you use
Invoke or BeginInvoke (sync. and async. resp.)

No need to call SendMessage

/claes
 
Back
Top