消息队列USER_MESSAGE_QUEUE
2023-10-26
29
0
消息队列有7种:
- SendMessagesListHead
- PostedMessagesListHead
- HardwareMessagesListHead
- NotifyMessagesListHead
GetMessage函数会处理SendMessage,但是不会处理PostMessage,HardwareMessagesListHead
GetMeesage中,会把SendMessagesList中的所有消处处理完成后,再从其6个消息队列中拿出一个消息返回。
HardwareMessagesListHead中的消息,会由DispatchMessage来处理,即DispatchMessage函数会根据窗口句柄调用相关的窗口过程。因为一个进程的所有的窗口共享一个消息队列,但不同的窗口却有不同有消息处理函数。故这里是分发。分发使用窗口句柄HWND来标识。
通过窗口句柄,找到窗口对象,再进一步找到窗口回调函数,再调用它。
TranslateMessage:用于处理键盘的按键消息的。如将WM_KEYDOWN加工为WM_CHAR消息消息。如屏蔽TranslateMessage,系统将会只会收到WM_KEYDOWN消息,不会收到WM_CHAR消息。
typedef struct _USER_MESSAGE_QUEUE
{
/* Owner of the message queue */
struct _ETHREAD *Thread;
/* Queue of messages sent to the queue. */
LIST_ENTRY SentMessagesListHead;
/* Queue of messages posted to the queue. */
LIST_ENTRY PostedMessagesListHead;
/* Queue of sent-message notifies for the queue. */
LIST_ENTRY NotifyMessagesListHead;
/* Queue for hardware messages for the queue. */
LIST_ENTRY HardwareMessagesListHead;
/* Lock for the hardware message list. */
FAST_MUTEX HardwareLock;
/* Lock for the queue. */
FAST_MUTEX Lock;
/* True if a WM_QUIT message is pending. */
BOOLEAN QuitPosted;
/* The quit exit code. */
ULONG QuitExitCode;
/* Set if there are new messages in any of the queues. */
KEVENT NewMessages;
/* FIXME: Unknown. */
ULONG QueueStatus;
/* Current window with focus (ie. receives keyboard input) for this queue. */
HWND FocusWindow;
/* True if a window needs painting. */
BOOLEAN PaintPosted;
/* Count of paints pending. */
ULONG PaintCount;
/* Current active window for this queue. */
HWND ActiveWindow;
/* Current capture window for this queue. */
HWND CaptureWindow;
/* Current move/size window for this queue */
HWND MoveSize;
/* Current menu owner window for this queue */
HWND MenuOwner;
/* Identifes the menu state */
BYTE MenuState;
/* Caret information for this queue */
PTHRDCARETINFO CaretInfo;
/* Window hooks */
PHOOKTABLE Hooks;
/* queue state tracking */
WORD WakeBits;
WORD WakeMask;
WORD ChangedBits;
WORD ChangedMask;
/* extra message information */
LPARAM ExtraInfo;
} USER_MESSAGE_QUEUE, *PUSER_MESSAGE_QUEUE;