user1091856
user1091856

Reputation: 3158

Win32: Messages sent to thread?

I understand that when a message is sent, it has hwnd value so that the systems knows which window is responsible for dealing with that message. And when hwnd is NULL then it means that this is a thread message. So what is the procedure function that is called to deal with that message?

Upvotes: 0

Views: 2083

Answers (1)

Mike Kwan
Mike Kwan

Reputation: 24447

Note that it is only documented under PostMessage (not SendMessage) that sending with HWND as NULL will cause the function to "behave like PostThreadMessage with dwThreadId as the current thread".

See here for how a thread can implement a message queue.

In response to your original question:

So what is the procedure function that is called to deal with that message?

PostThreadMessage posts to the message queue of the thread.

Note for PostThreadMessage: "The function fails if the specified thread does not have a message queue. The system creates a thread's message queue when the thread makes its first call to one of the User or GDI functions."

Upvotes: 3

Related Questions