Messaging with SendMessage

my question is: how can I use SendMessage () to implement thread exchange between two threads, one with a window (GUI) and the other without a window?

Is the problem that SendMessage () requires a handle (HWND)?

Another detail about my project: two threads, one managed code (one with a user interface), and the other executable native code (one without a window)

Many thanks!

+5
source share
4 answers

I would suggest creating a hidden window. When using postthreadmessage, there is a possibility that your message may be lost (for example: if a message loop is running in the mailbox).

Additional information about this:

http://blogs.msdn.com/oldnewthing/archive/2005/04/26/412116.aspx

+4

, , . ( Windows Spy, ).

. .

+2

@jdigital . : , ( win32-talk, COM STA), , , , ), . ATL _AtlModule.RunMessageLoop(); , , , , , , . , MsgWaitForMultipleObjects, .

Here is an example of hidden windows if you are familiar with ATL / COM. I relived this pain a bit and thought there was a useful discussion about microsoft.public.vc.atl, but the best I can find now is this post . which discusses in detail options for message loops (what to do differently, if you have accelerators for keystrokes or weak windows, it looks like you're not in your application).

+2
source

All Articles