Windows消息地址定义

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.
转载于:https://www.cnblogs.com/findumars/p/8306946.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值