Recently, I have been working on the game startup interface after the revision, and added a tree control in the main window. A ctree class is designed to inherit from ctreectrl, and a tree control object m_treectrl is placed as a member of the main cserver class.
The problem is how to set the corresponding data to a control on the main interface by clicking a node of the tree control. Click events respond in the ctree class, but you need to call an interface setstate (data) in cserver to set the corresponding data.
At the beginning, I always wanted to solve this problem in the design mode, but I had to think about it. Later I thought about the windows mechanism and quickly found a solution.
Add two members in ctree: cwnd * mp_wnd; uint m_msg; define a macro wm_tree_click in cserver, and add on_message (wm_tree_click, & cserver: setstate) between begin_message_map and end_message_map ). Then, when initializing the tree control, set its member m_treectrl.mp_wnd = This; m_treectrl.m_msg = wm_tree_click; finally, add mp_wnd-> sendmessage (m_msg) to the mouse click event in ctree ), you can respond in the setstate () interface of cserver.
A little new discoveries every day make you feel better.