MFC的CDialogBar和Rollup Control

1.首先,创建对话框资源:在对话框资源编辑器内生成一个Dialog资源,并将其风格(Style)属性必须设置为Child,不能设置为Overlapped或Popup,否则运行肯定出错;至于边界属性则随用户自己喜欢,一般都是选择None。其余属性也随用户选择,一般没有特殊要求还是选择默认的好。

2. CMainFrame的头文件里添加CDialogBar m_wndDlgBar;

3. CMainFrame的实现文件里:

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)函数里面添加:

BOOL bRet = m_wndDlgBar.Create(this, IDD_DIALOG1, WS_VISIBLE|WS_CHILD|CBRS_LEFT, 1);
m_wndDlgBar.EnableDocking(CBRS_ALIGN_RIGHT|CBRS_ALIGN_LEFT);
DockControlBar(&m_wndDlgBar);

就可以加入一个CDialogBar。

 

Rollup Control的来源:http://www.codeproject.com/Articles/1058/Rollup-Control

  1. RUNTIME_CLASS method

    Create a dialog box in the resource editor 'ex. IDD_PAGE1' with the WS_CHILD style. Generate the declaration and implementation files class (ex. CPage1Dlg) of your dialog box with the assistance of the MFC Classwizard. Then add DECLARE_DYNCREATE(CPage1Dlg) in the declaration of the class andIMPLEMENT_DYNCREATE(CPage1Dlg, CDialog) in the implementation.

    Then insert the page in this way pwndRollupCtrl->InsertPage("Caption", IDD_PAGE1, RUNTIME_CLASS(CPage1Dlg) );

  2. CDialog::Create method

    As RUNTIME_CLASS method, create a dialog box in the resource editor. Generate the declaration and implementation files class of your dialog box. Then create the dialog box like this

    CPage1Dlg* pwndPage1 = new CPage1Dlg;
    pwndPage1->Create(MAKEINTRESOURCE(IDD_PAGE1), pwndRollupCtrl);

    and insert the page as follows

    pwndRollupCtrl->InsertPage("Caption", pwndPage1 );

     

    改动在MainFrame.h MainFrame.cpp

     



你可能感兴趣的:(dialog)