-
Notifications
You must be signed in to change notification settings - Fork 1
/
Queues.md
61 lines (47 loc) · 2.8 KB
/
Queues.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# [Message Queues](https://learn.microsoft.com/en-us/windows/win32/winmsg/about-messages-and-message-queues)
The system maintains a single system message queue and one thread-specific message queue for each GUI thread. Whenever the user moves the mouse, clicks the mouse buttons, or types on the keyboard, the device driver for the mouse or keyboard converts the input into messages and places them in the system message queue. The system removes the messages, one at a time, from the system message queue, examines them to determine the destination window, and then posts them to the message queue of the thread that created the destination window. A thread's message queue receives all mouse and keyboard messages for the windows created by the thread. The thread removes messages from its queue and directs the system to send them to the appropriate window procedure for processing.
Message → Foreground → Active
## Implementation
```cpp
// Windows XP SP1
/*
* Message Queue structure.
*
* Note, if you need to add a WORD sized value,
* do so after xbtnDblClk.
*/
typedef struct tagQ {
MLIST mlInput; // raw mouse and key message list.
PTHREADINFO ptiSysLock; // Thread currently allowed to process input
ULONG_PTR idSysLock; // Last message removed or to be removed before unlocking
ULONG_PTR idSysPeek; // Last message peeked
PTHREADINFO ptiMouse; // Last thread to get mouse msg.
PTHREADINFO ptiKeyboard;
PWND spwndCapture;
PWND spwndFocus;
PWND spwndActive;
PWND spwndActivePrev;
UINT codeCapture; // type of captue. See *_CAP* defines in this file
UINT msgDblClk; // last mouse down message removed
WORD xbtnDblClk; // last xbutton down
DWORD timeDblClk; // max time for next button down to be taken as double click
HWND hwndDblClk; // window that got last button down
POINT ptDblClk; // last button down position. See SYSMET(C?DOUBLECLK)
BYTE afKeyRecentDown[CBKEYSTATERECENTDOWN];
BYTE afKeyState[CBKEYSTATE];
CARET caret;
PCURSOR spcurCurrent;
int iCursorLevel; // show/hide count. < 0 if the cursor is not visible
DWORD QF_flags; // QF_ flags go here
USHORT cThreads; // Count of threads using this queue
USHORT cLockCount; // Count of threads that don't want this queue freed
UINT msgJournal; // See SetJournalTimer. Journal message to be delivered when timer goes off
LONG_PTR ExtraInfo; // Extra info for last qmsg read. See GetMessageExtraInfo
} Q;
/*
* Queue Variables
*/
PQ gpqForeground;
PQ gpqForegroundPrev;
PQ gpqCursor;
```