home Tech Library Tech Forum
Publisher
 
Custom Controls in MFC       
 
 
Notification Messages by Common Controls
 
 

 

The common controls use WM_NOTIFY messages to send notification messages to their parent rather than the usual WM_COMMAND messages. A WM_NOTIFY message’s wParam is the child window ID of the control that sent the message, and lParam is a pointer to an NMHDR structure. The NMHDR structure holds the pointer to the control sending the message, the ID of the control sending the message, and the control-specific notification code. Many controls send WM_NOTIFY messages with pointers to structures larger than NMHDR (a structure that is a superset of NMHDR). Those larger structures hold the three information items previously mentioned plus other control-specific items. When ClassWizard maps a WM_NOTIFY message, it generates a pointer to the appropriate structure.

There are numerous notification messages that can be sent from the control to its parent. Some notification messages can be used by all of the new common controls; these are denoted by the prefix of NM_. For example, the NM_CLICK message is sent when the control is clicked with the left mouse button. In addition to the NM_ messages that apply to any of the new common controls, each control has control-specific messages that it can send. Slider notification messages are denoted by TB_. Spinner notification messages are denoted by UDN_. List view notification messages are denoted by LVN_. Tree view notification messages are denoted by TVN_.

The WM_NOTIFY messages are mapped to response functions by the ON_NOTIFY() and ON_NOTIFY_RANGE() message map macros. The ON_NOTIFY_RANGE() macro is used when you have a set of controls for which you want to perform the same action for a certain notification message; you specify a contiguous range of child identifiers for which to handle the notification message by specifying the beginning and ending child identifiers of the range.
 
   
   
  RELATED TOPICS  
Custom Controls in MFC
SubClassing a Window
Common Custom Controls in MFC
Creating the Common Controls
Slider Control and Styles
Spin Control and Styles
List View Control and Styles
Tree View Control and Styles
Property Sheets
How to create a Modal Property Sheet
 


 
           
Home | Profile | Users | Library | Publisher | Tech Forum | News | Contact Us