www.gusucode.com > 含多种窗体元素的VC++演示对话框-源码程序 > 含多种窗体元素的VC++演示对话框-源码程序/code/LayoutManagerView.cpp
// LayoutManagerView.cpp : Implementierung der Klasse CLayoutManagerView // Download by http://www.NewXing.com #include "stdafx.h" #include "LayoutManager.h" #include "LayoutManagerDoc.h" #include "LayoutManagerView.h" #include "MyDialog.h" #include "TabDialog.h" #include "CtrlDialog.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CLayoutManagerView IMPLEMENT_DYNCREATE(CLayoutManagerView, CFormViewMgr) BEGIN_MESSAGE_MAP(CLayoutManagerView, CFormViewMgr) //{{AFX_MSG_MAP(CLayoutManagerView) ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_BUTTON2, OnButton2) ON_BN_CLICKED(IDC_BUTTON3, OnButton3) ON_BN_CLICKED(IDC_BUTTON4, OnButton4) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CLayoutManagerView Konstruktion/Destruktion CLayoutManagerView::CLayoutManagerView() : CFormViewMgr(CLayoutManagerView::IDD) { //{{AFX_DATA_INIT(CLayoutManagerView) // HINWEIS: Der Klassenassistent f黦t hier Member-Initialisierung ein //}}AFX_DATA_INIT // ZU ERLEDIGEN: Hier Code zur Konstruktion einf黦en, } CLayoutManagerView::~CLayoutManagerView() { } void CLayoutManagerView::DoDataExchange(CDataExchange* pDX) { CFormViewMgr::DoDataExchange(pDX); //{{AFX_DATA_MAP(CLayoutManagerView) // HINWEIS: Der Klassenassistent f黦t an dieser Stelle DDX- und DDV-Aufrufe ein //}}AFX_DATA_MAP } BOOL CLayoutManagerView::PreCreateWindow(CREATESTRUCT& cs) { // ZU ERLEDIGEN: 膎dern Sie hier die Fensterklasse oder das Erscheinungsbild, indem Sie // CREATESTRUCT cs modifizieren. return CFormViewMgr::PreCreateWindow(cs); } void CLayoutManagerView::OnInitialUpdate() { CFormViewMgr::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(); /* DialogMgr: Add this: */ // We want to have a disign like this // --------------------------- // | ---------- ---------- | // | | Button 1 | | Button 2 | | Pane1 // | ---------- ---------- | // --------------------------- // --------------------------- // | ---------- ---------- | // | | Button 3 | | Button 4 | | Pane2 // | ---------- ---------- | // --------------------------- // --------------------------- // | ----------------------- | // | | Text | | Pane 3 // | ----------------------- | // --------------------------- CPane* pPane1 = new CPane( this, HORIZONTAL ); // Add Button 1+2 to the first pane pPane1->addItem( IDC_BUTTON1, GREEDY, 0, 0, -1, -1 ); pPane1->addItem( IDC_BUTTON2, GREEDY, 0, 0, -1, -1 ); CPane* pPane2 = new CPane( this, HORIZONTAL ); // Add Button 3+4 to the second pane pPane2->addItem( IDC_BUTTON3, GREEDY, 0, 0, -1, -1 ); pPane2->addItem( IDC_BUTTON4, GREEDY, 0, 0, -1, -1 ); CPane* pPane3 = new CPane( this, HORIZONTAL ); // Add Text to the third pane, no resizing vertically! pPane3->addItem( IDC_STATIC_TEXT, ABSOLUTE_VERT ); // Add all the Panes to the Root m_pRootPane=new CPane ( this, VERTICAL ); m_pRootPane->addPane ( pPane1 ); m_pRootPane->addPane ( pPane2 ); m_pRootPane->addPane ( pPane3, ABSOLUTE_VERT ); // Do the real layouting UpdateLayout(); /************************/ } ///////////////////////////////////////////////////////////////////////////// // CLayoutManagerView Diagnose #ifdef _DEBUG void CLayoutManagerView::AssertValid() const { CFormViewMgr::AssertValid(); } void CLayoutManagerView::Dump(CDumpContext& dc) const { CFormViewMgr::Dump(dc); } CLayoutManagerDoc* CLayoutManagerView::GetDocument() // Die endg黮tige (nicht zur Fehlersuche kompilierte) Version ist Inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CLayoutManagerDoc))); return (CLayoutManagerDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CLayoutManagerView Nachrichten-Handler void CLayoutManagerView::OnButton1() { CMyDialog dlg; dlg.DoModal(); } void CLayoutManagerView::OnButton2() { CTabDialog dlg; dlg.DoModal(); } void CLayoutManagerView::OnButton3() { CCtrlDialog dlg; dlg.DoModal(); } void CLayoutManagerView::OnButton4() { CMyDialogHorz dlg; dlg.DoModal(); }