In order to implement menus like QQ, the menu of the master is optimized. After searching online for a long time, I finally found it in vckbase. The main principle is to move the window.
The tool I implemented uses two buttons and two listctrl, but the listctrl can be replaced by other controls, which is more diversified.
First, add events for the two buttons. The event response functions of these two buttons are
Afx_msg void onbnclicke1 (nmhdr * pnmhdr, lresult * presult );
Afx_msg void onbnclicke2 (nmhdr * pnmhdr, lresult * presult );
You also need a function for switching.
Void onchange ();
The implementation code of these three functions is as follows:
Onbnclicke1 (nmhdr * pnmhdr, lresult * presult) </P> <p >{< br/> m_clicknum = 1; <br/> If (m_topbuttonnum = 1) <br/>{< br/> onbnclickedbtndevdetect (); <br/> return; // The tool1 button is already in the upper layer. No response is returned when you click it again; <br/>}</P> <p> onchange (); <br/> m_topbuttonnum = 1; </P> <p >}< br/>
Onbnclickedbtndevdetect () <br/>{< br/> // todo: add the control notification handler code here <br/> m_clicknum = 2; <br/> If (m_topbuttonnum = 2) <br/> {<br/> return; // The tool3 button is already in the upper layer. No response is returned when you click the button again; <br/>}< br/> onchange (); </P> <p> m_topbuttonnum = 2; </P> <p>}
Onchange () <br/>{</P> <p> If (m_topbuttonnum! = 1 & m_clicknum = 1) <br/>{< br/> int nwidth; <br/> int nheight; </P> <p> // The first button is already placed in the top layer, so you do not need to move it. All the rest are placed below <br/> m_btn1t.movewindow (m_point0.x + 10, <br/> m_point1.y-20-m_rect1.height (), <br/> m_rect1.width (), <br/> m_rect1.height ()); </P> <p> // display the content of the button <br/> nwidth = m_rect0.width (); <br/> nheight = (m_point1.y-20-m_rect1.height ()) -(m_point0.y + 10 + m_rect0.height () + m_rectlogo.height (); </P> <P> m_list1.movewindow (m_point0.x + 10, <br/> m_point0.y + 10 + m_rect0.height () + m_rectlogo.height (), <br/> nwidth, nheight ); </P> <p> m_list1.showwindow (sw_show); <br/> m_list2.showwindow (sw_hide); </P> <p> // m_pcurrentdlg-> showwindow (true ); <br/> return; <br/>}</P> <p> If (m_topbuttonnum! = 2 & m_clicknum = 2) <br/>{</P> <p> int nwidth; <br/> int nheight; </P> <p> // click the button that is placed on the top of the dashboard. <br/> m_btn2.movewindow (m_point0.x + 10, <br/> m_point0.y + 10 + m_rect0.height () + m_rectlogo.height (), <br/> m_rect1.width (), <br/> m_rect1.height ()); </P> <p> nwidth = m_rect0.width (); <br/> nheight = (m_point1.y-20)-(m_point0.y + 10 + m_rect0.height () + m_rect1.height () + m_rectlogo.height (); <br/> m_list2.movewindow (m_point0.x + 10, <br/> m_point0.y + 10 + m_rect0.height () + m_rect1.height () + m_rectlogo.height (), <br/> nwidth, nheight); </P> <p> // display the content of the button <br/> m_list1.showwindow (sw_hide ); <br/> m_list2.showwindow (sw_show); </P> <p> // m_pcurrentdlg-> showwindow (true); <br/> return; <br/>}< br/>}