Knowledge is read and summed up in a book, the title: MFC Windows Programming (2nd edition). Beauty Jeff Prosise, Beijing Beyondsoft Technology Development Co., Ltd. translation
The procedure for capturing window events and adding event handlers can be implemented in the following two ways (for example, with a mouse click event):
1.
H file Add:
Protectedvoid OnLButtonDown (UINT nflags, CPoint point);D eclare_message_map ()
CPP file add:
Begin_message_map (subclass name, base class name) On_wm_lbuttondown () End_message_map ( ) ... void Subclass Name:: OnLButtonDown (UINT nflags, CPoint point) {...}
2.
H file Add:
protected : afx_msg LRESULT onlbuttondown (WPARAM wparam,lparam LPARAM);D eclare_message_map ()
CPP file add
Begin_message_map (subclass name, base class name) on_message (Wm_lbuttondown, OnLButtonDown) End_message_map () ... LRESULT Subclass Name:: OnLButtonDown (WPARAM wparam,lparam LPARAM) {...}
The effect is the same for both implementations. But they belong to different methods. The second method can also be used in the process of adding custom messages.
Implementation of message Map in MFC