MFC Switch Sub-interface

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.