Windows SDK 两种消息类型(Message Types)的区别

本文介绍了Windows系统中系统定义消息和应用定义消息的工作原理及使用规范。系统定义消息由系统发送给应用程序,用于控制应用程序的操作并提供输入信息。每种消息都有独特的标识符和符号常量,用于指示消息的目的。此外,文章还详细列举了不同前缀所对应的窗口类别。对于应用定义的消息,文章解释了如何创建私有消息,并规定了消息标识符的分配范围。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

System-Defined Messages

The system sends or posts a system-defined message when it communicates with an application. It uses these messages to control the operations of applications and to provide input and other information for applications to process. An application can also send or post system-defined messages. Applications generally use these messages to control the operation of control windows created by using preregistered window classes.

Each system-defined message has a unique message identifier and a corresponding symbolic constant (defined in the SDK header files) that states the purpose of the message. For example, the WM_PAINT constant requests that a window paint its contents.

Symbolic constants specify the category to which system-defined messages belong. The prefix of the constant identifies the type of window that can interpret and process the message. Following are the prefixes and their related message categories.

PrefixMessage category
ABMApplication desktop toolbar
BMButton control
CBCombo box control
CBEMExtended combo box control
CDMCommon dialog box
DBTDevice
DLDrag list box
DMDefault push button control
DTMDate and time picker control
EMEdit control
HDMHeader control
HKMHot key control
IPMIP address control
LBList box control
LVMList view control
MCMMonth calendar control
PBMProgress bar
PGMPager control
PSMProperty sheet
RBRebar control
SBStatus bar window
SBMScroll bar control
STMStatic control
TBToolbar
TBMTrackbar
TCMTab control
TTMTooltip control
TVMTree-view control
UDMUp-down control
WMGeneral window

 

General window messages cover a wide range of information and requests, including messages for mouse and keyboard input, menu and dialog box input, window creation and management, and dynamic data exchange (DDE).

 

 


 

 

Application-Defined Messages

An application can create messages to be used by its own windows or to communicate with windows in other processes. If an application creates its own messages, the window procedure that receives them must interpret the messages and provide appropriate processing.

Message-identifier values are used as follows:

  • The system reserves message-identifier values in the range 0x0000 through 0x03FF (the value of WM_USER – 1) for system-defined messages. Applications cannot use these values for private messages.
  • Values in the range 0x0400 (the value of WM_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 0xBFFF for private messages.
  • The system returns a message identifier in the range 0xC000 through 0xFFFF when an application calls the RegisterWindowMessage function 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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值