Home > Back-end >  Lined up on news
Lined up on news

Time:10-27

As is known to all, general Windows programs running mechanism is, first create a message queue, and then through the getmessage (HWND,,,,) this function from marched out of the news, once again, from the getmessage (HWND,,,,) this function as you can see, the program from a specific window to retrieve messages, does this explains, message queue belongs to the window, the program will create a message for each window lined up??????? When the system generated message in this program, put in this message is sent to the program's message queue???????
Still say, message queue belongs to the thread, thread to create a main window, and then create a thread message queue, system to send the message to the thread lined up, and then in turn processing messages???????
Ah! Do not understand the threads window message lined up ah, good relationship complicated, asked the great spirit guide!!!

CodePudding user response:

Windows has a public message queue, message queue here first, then go into the thread the message queue, rather than the window message queue (actually, there is no message queue window), if your application is only one main thread, so, all the messages you get into this thread's message queue, if there is the child thread also created window, the child thread also have a separate message queue, that is to say, the message is corresponding to a thread, not corresponding to a window, even though each message has a specific window handle markers,

That should be easy to understand, Windows operating mode is message-driven, when activated, each application is constantly running one or more threads there, check your arrival if there is a message in the queue, no news is there idle waiting, information processing, and then continue to wait for, so, the message must be under the jurisdiction of the thread, rather than to the jurisdiction of the window,

CodePudding user response:

Message queue window, do not belong to the thread; Window does not belong to the thread, the thread does not necessarily have a window, it's as simple as that,

CodePudding user response:

But if I create multiple Windows in a program, from getmessage (HWND,,,) this function, the parameters of the HWND which a window should be?? And, if filed belongs to the thread, then getmessage function and window should it doesn't matter!! Why have the HWND parameter??

CodePudding user response:

Will receive when you create a window of the application of a HWND, used to distinguish the window, so you should know which window corresponds to which HWND, if you want to remove all the message window, you can put this parameter is set to NULL, you get the MSG structure will have is HWND indicate which window message, subsequent code could do with a message to a specific window corresponding to the operation, for example, it's a keyboard message, you will be according to the corresponding window HWND complete keyboard input operation,

CodePudding user response:

Good cold and cheerless, lu had rubbed points

CodePudding user response:

Windows message queue has two kinds, one kind is window of, the other is a thread, the thread's message queue to have a build process,
  • Related