1. Do all messages start with WM?
No, and
Prefix |
Message category |
Documentation |
ABM and ABN |
Application desktop Toolbar |
Shell messages and notifications |
ACM and ACN |
Animation Control |
Animation control messages and animation control notifications |
BCM, BCN, BM, and BN |
Button Control |
Button Control Messages and button control notifications |
CB and CBN |
ComboBox control |
ComboBox control messages and ComboBox control specifications |
Cbem and cben |
Comboboxex Control |
Comboboxex messages and comboboxex notifications |
CCM |
General Control |
Control Messages |
CDM |
Common Dialog Box |
Common Dialog Box messages |
DFM |
Default context menu |
Shell messages and notifications |
DL |
Drag list box |
Drag list box configurations |
DM |
Default push button control |
Dialog Box messages |
DTM and dtn |
Date and Time picker Control |
Date and Time picker messages and date and time picker notifications |
Em and EN |
Edit Control |
Edit Control Messages, Edit Control notifications, rich edit messages, and rich edit notifications |
HDM AND HDN |
Header Control |
Header control messages and header control notifications |
Hkm |
Hot Key Control |
Hot Key Control Messages |
IPM and IPN |
IP address control |
IP address messages and IP address communications |
LB and LBN |
List box Control |
List box messages and list box notifications |
Lm |
Syslink Control |
Syslink Control Messages |
LVM and LVN |
List View Control |
List View Messages and List View notifications |
MCM and MCN |
Month calendar Control |
Month calendar messages and month calendar notifications |
PBM |
Progress bar |
Progress bar messages |
PGM and PGN |
Pager Control |
Pager control messages and pager control notifications |
PSM and pSN |
Property sheet |
Property sheet messages and property sheet notifications |
Rb and rBN |
Rebar Control |
Rebar control messages and rebar control notifications |
SB and SBN |
Status Bar window |
Status Bar messages and status bar notifications |
SBM |
Scroll bar Control |
Scroll bar messages |
SMC |
Shell menu |
Shell messages and notifications |
STM and STN |
Static Control |
Static Control Messages and static control configurations |
TB and TBN |
Toolbar |
Toolbar Control Messages and Toolbar Control notifications |
TBM and trbn |
Trackbar Control |
Trackbar control messages and trackbar control notifications |
TCM and TCN |
Tab Control |
Tab control messages and Tab control notifications |
TDM and TDN |
Task Dialog |
Task dialog messages and task dialog notifications |
TTM and ttn |
Tooltip Control |
Tooltip control messages and tooltip control notifications |
TVM and TVN |
Tree-View Control |
Tree View Messages and Tree View notifications |
UDM and UDN |
Up-down control |
Up-down messages and up-down notifications |
2. range I of message numbers and custom messages
Message-identifier values are used as follows:
- The system reserves message-identifier values in the range 0x0000 through 0x03ff (the valueWm_user-1) for system-defined messages. applications cannot use these values for private messages.
- Values in the range 0x0400 (the valueWm_user) Through 0x7fff are available for message identifiers for private window classes.
- If your application is marked version 4.0, you can use message-identifier values in the range 0x8000 (Wm_app) Through 0 xbfff for private messages.
- The system returns a message identifier in the range 0xc000 through 0 xFFFF when an application calltheRegisterwindowmessageFunction to register a message. the message identifier returned by this function is guaranteed to be unique throughout the system. use of this function prevents conflicts that can arise if other applications use the same message identifier for different purposes.
That is: 0x0000 to 0x03ff (WM_USER-1) is system retained and applications cannot use
0x0400 (wm_user) to 0x07ff, which can be used in the private window class, that is, internal application
After windows95 and nt3.5 (there is a windows3.1 and nt3.1 in front, I am lucky to spend a few days, ah, I am also old enough) 0x0800 (wm_app) to 0xbff will also be used by the program.
0xc000 to 0xffff are global custom messages that can be used between unused applications. For such a message, you must callRegisterwindowmessageThe system allocates a number. Therefore, when the program runs twice, registering the same message may have different numbers.
3. Are message queues owned by windows, threads, and processes?
The system maintains a single system message queue and one thread-specific message queue for each GUI thread.
The system has a system queue, and each GUI thread has a queue of its own.
4. When will a Message Queue be created?
To avoid the overhead of creating a message queue for non-Gui threads, all threads are created initially without a message queue. the system creates a thread-specific message queue only when the thread makes its first call to one of the specific user functions; no GUI function callresult in the creation of a message queue.
No message queue is generated for all wired threads. When a thread calls a specific function for the first time, a message queue is created.
System messages (such as keyboard, mouse, wm_quit, and wm_paint) are first sent to the system message queue. Then, the system extracts messages from the queue one by one to see the window to which the message is sent, put the message in the queue of the Creation thread in this window.
The system creates a thread's message queue when the thread makes its first call
To one of the user or GDI functions.
5. Are all messages in the message queue?
No. Divided into queued message and none queued message. The former includes the mouse, keyboard event, wm_paint, wm_quit, wm_timer, and so on. The latter includes wm_active and wm_setfocus. None queued message is sent through sendmessage. The sending of these messages directly calls the processing function of the corresponding window (the statement is not rigorous, and only the window of the same thread can be called directly; otherwise, wait for the target window to complete the call. Cross-thread transmission involves the issue of callback alling)
Notification message,SendpolicymessageThe sent message is not placed in the message queue. The behavior of this function is the same as that of sendmessage when the target window belongs to the sending thread. It is returned only after the message is processed. When the target window is in another thread, the behavior is the same as that of postmessage, and the message is returned after the message processing is complete.
6. What is the size of a message queue?
There is a limit of 10,000 posted messages per message queue. this limit shoshould be sufficiently large. if your application exceeds the limit, it shoshould be redesigned to avoid consuming so far system resources. to adjust this limit, modify the following registry key.
HKEY_LOCAL_MACHINE SOFTWARE Microsoft Windows NT CurrentVersion Windows USERPostMessageLimit
The default value is 10000.
Refer:
1. http://msdn.microsoft.com/en-us/library/ms644927(v=vs.85).aspx
2. msdn description of attatchthreadinput
3. Refer to the msdn documentation for related APIs in 1.