In a dialog program, a sub-interface is usually a child control that, when toggled, usually hides the other, displaying the controls to be displayed.
The following example has two buttons to control the display of two static text (click the button 1 will display the text 1, click on the text 2 will display the text 2)
The implementation is divided into the following steps:
1 Add static text and button member variables to dialog.
Private
CButton m_btn_1;
CButton m_btn_2;
CStatic m_static_1;
CStatic m_static_2;
2 Creating a control dynamically when the program is initialized
M_btn_1. Create(_t ("dynamic button 1"), Ws_child | Ws_visible,crect ( +,--), this,idc_mybtn_1);M_btn_2. Create(_t ("dynamic button 2"), Ws_child | Ws_visible,crect (max., this,idc_mybtn_2);M_static_1. Create(_t ("Hello world1"), ws_child| ws_border| Ss_simple | ss_center| Ws_visible,crect (a), this ); M_static_2. Create(_t ("Hello world2"), ws_child| ws_border| Ss_simple | Ss_center,crect (a), this );
3 procedure reference for adding a dynamic button machine response function:
http://blog.csdn.net/calmreason/article/details/43791757
4 switching controls in the response function
void CmfcDlg::ClickBtn1(){ m_static_1.ShowWindow(TRUE); m_static_2.ShowWindow(FALSE); m_static_1.SetWindowText(_T("111111111111111111111111111111111111111111"));}void CmfcDlg::ClickBtn2(){ m_static_1.ShowWindow(FALSE); m_static_2.ShowWindow(TRUE); m_static_2.SetWindowText(_T("2222222222222222222222222222222222222222222"));}
MFC switch sub-interface