WM

xiaoxiao2021-03-06  27

Windows sends a message to the window, which means the Windows calls window message handler. However, the Windows program also has a message loop, which calls getMessage to remove the message from the message queue, and call DispatchMessage to send the message to the window message handler. Then, the Windows program is waiting for the message (similar to the same keyboard input in a normal program), then send the message to a certain place? Or, do it receive messages directly from the program? In fact, both situations exist. The message can be divided into "queue" and "non-queue". Queue messages are in the Windows in the program message queue. In the message loop of the program, it is retransmond and assigned to the window message handler. Non-queued messages directly to the window message handler when the Windows call window. That is, the queue's message is "Send" to the message queue, not the queue, "Send" to the window message handler. In any case, the window message handler will get all the messages of the window - including queue and non-queue. The window message handler is the "Message Center" of the window. Queue messages are basically the result of the user input to hit the key (such as a WM_KEYDOWN and WM_KEYUP message), the word generated by the keys (WM_CHAR), the mouse movement (WM_MOUSEMOVE) and the mouse button (WM_LButtondown) are given. Queue messages also include clock messages (WM_TIMER), update messages (WM_PAINT), and exit messages (WM_QUIT). Non-queen messages are other messages. In many cases, non-queen messages come from calling a specific Windows function. For example, when WinMain calls CREATEWINDOW, Windows will create a window and send a WM_CREATE message to the window message handler in the process. When WinMain calls ShowWindow, Windows will send WM_SIZE and WM_SHOWWINDOW messages to the window message handler. When WinMain calls UpdateWindow, Windows will send a WM_PAINT message to the window message handler. The queue message signal issued when the keyboard or mouse input can also appear in the non-queue message. For example, when selecting a menu item with a keyboard or mouse, the keyboard or mouse message is queue, and the WM_COMMAND message selected by the menu item may be non-queue. Several methods of sending a WM_PAINT message to Windows 1 with postMessage (), sendM_PAINT messages to the WM_PAINT message to send a WM_PAINT message to the Windows program message queue, when Windows will be sent to the Windows program message queue When sending to a specific message processing function, if Windows will ignore the message if the invalid area of ​​the window is empty. If there is an invalid area, the window processing function processing is called. 2 invalidate (), invalidateect (), invalidatergn (); The above function is calibrated to invalidate the specific area of ​​the window. When Windows detects that there is an invalid area in the window, the WM_PAINT message will be sent to the message queue. 3 updateWindow () This function call After Windows sends a non-queued WM_PAINT message to the window, which does not send the message loop to the window message processing function directly. If the window invalid area does not exist, Windows will ignore this message.

转载请注明原文地址:https://www.9cbs.com/read-65402.html

New Post(0)