ON_NOTIFY用法

摘自:http://msdn.microsoft.com/zh-cn/library/749htf6k(v=VS.100).aspx

 

ON_NOTIFY: Handling WM_NOTIFY Messages in MFC Applications


The function CWnd::OnNotify handles notification messages. Its default implementation checks the message map for notification handlers to call. In general, you do not override OnNotify. Instead, you provide a handler function and add a message-map entry for that handler to the message map of your owner window's class.

ClassWizard, via the ClassWizard property sheet, can create the ON_NOTIFY message-map entry and provide you with a skeleton handler function. For more information on using ClassWizard to make this easier, see Mapping Messages to Functions.

The ON_NOTIFY message-map macro has the following syntax:


where the italicized parameters are replaced with:

wNotifyCode

The code for the notification message to be handled, such as LVN_KEYDOWN.

id

The child identifier of the control for which the notification is sent.

memberFxn

The member function to be called when this notification is sent.

Your member function must be declared with the following prototype:

 
 
备注

where the italicized parameters are:

pNotifyStruct

A pointer to the notification structure, as described in the section above.

result

A pointer to the result code you'll set before you return.

示例

To specify that you want the member function OnKeydownList1 to handle LVN_KEYDOWN messages from the CListCtrl whose ID is IDC_LIST1, you would use ClassWizard to add the following to your message map:

 

In the example above, the function provided by ClassWizard is:

 

Note that ClassWizard provides a pointer of the proper type automatically. You can access the notification structure through either pNMHDR or pLVKeyDow.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值