Windows消息范圍及意義
#define WM_USER 0x0400
#define WM_APP 0x8000
0到WM_USER-1
Messages reserved for use by the system
系統預留使用的消息
WM_USER到0x7FFF
Integer messages for use by private window classes
被私有窗口類使用的消息
WM_APP到0xBFFF
Messages available for use by applications
被應用程序使用的消息
0xC000到0xFFFF
String messages for use by applications
被應用程序使用的字符串消息
大於0xFFFF
Reserved by the system
系統預留
WM_USER與WM_APP的區別
WM_USER到0x7FFF:
僅在自己預定義的窗口內部使用
WM_APP到0xBFFF:
在應用程序的其他地方均可使用
注意:這只是一種約定俗成的規則,約定只是best practice,並不是說你不這么做就一定會出問題.
如果程序的所有窗口和所有控件完全由你一個人實現,你完全可以不遵守這一規則.
但若有其他人寫的代碼或加載了外來的控件,如果你不遵守這一規則,發生沖突的概率會明顯加大,可能會出現意想不到的結果.
RegisterWindowMessage
The RegisterWindowMessage function defines a new window message that is guaranteed to be unique throughout the system.
The message value can be used when sending or posting messages.
UINT RegisterWindowMessage(LPCTSTR lpString)
The RegisterWindowMessage function is typically used to register messages for communicating between two
cooperating applications.
If two different applications register the same message string, the applications return the same message value.
The message remains registered until the session ends.
Only use RegisterWindowMessage when more than one application must process the same message.
If the message is successfully registered,
the return value is a message identifier in the range 0xC000 through 0xFFFF.
http://blog.csdn.net/hisinwang/article/details/45771711