1 //////////////////////////////////////////////
\r
2 // SimpleMDIChild.cpp
\r
3 // Definitions for the CSimpleView and CSimpleMDIChild classes
\r
8 #include "SimpleMDIChild.h"
\r
9 #include "resource.h"
\r
12 // CSimpleView definitions
\r
13 CSimpleView::CSimpleView() : m_Color(RGB(0,0,255))
\r
17 void CSimpleView::OnDraw(CDC* pDC)
\r
19 //Centre some text in our view window
\r
20 CRect rc = GetClientRect();
\r
21 pDC->SetTextColor(m_Color);
\r
22 pDC->DrawText(_T("View Window"), -1, rc, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
\r
25 LRESULT CSimpleView::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
30 // Force the window to be repainted
\r
32 break; // Also do default processing
\r
35 // Do default processing for other messages
\r
36 return WndProcDefault(uMsg, wParam, lParam);
\r
39 // CSimpleMDIChild definitions
\r
40 CSimpleMDIChild::CSimpleMDIChild()
\r
42 // Set m_View as the view window of the MDI child
\r
45 // Set the menu for this MDI child
\r
46 SetHandles(LoadMenu(GetApp()->GetResourceHandle(), _T("MdiMenuView")), NULL);
\r
49 CSimpleMDIChild::~CSimpleMDIChild()
\r
53 void CSimpleMDIChild::OnInitialUpdate()
\r
55 // Set the window caption
\r
56 SetWindowText(_T("Simple Window"));
\r
58 // Set the window icons
\r
59 SetIconLarge(IDI_VIEW);
\r
60 SetIconSmall(IDI_VIEW);
\r
62 // Add Child dockers
\r
63 DWORD dwStyle = DS_CLIENTEDGE | DS_NO_CAPTION | DS_NO_UNDOCK;
\r
64 m_View.SetDockStyle(dwStyle);
\r
65 CDocker* pDockLeft = m_View.AddDockedChild(new CDockOutput, DS_DOCKED_LEFT | dwStyle, 200, 0);
\r
66 CDocker* pDockRight = m_View.AddDockedChild(new CDockOutput, DS_DOCKED_RIGHT | dwStyle, 200, 0);
\r
67 pDockLeft->AddDockedChild(new CDockFiles, DS_DOCKED_CONTAINER | dwStyle, 0, 0);
\r
68 pDockRight->AddDockedChild(new CDockFiles, DS_DOCKED_CONTAINER | dwStyle, 0, 0);
\r
72 BOOL CSimpleMDIChild::OnCommand(WPARAM wParam, LPARAM lParam)
\r
74 // Respond to menu and toolbar input
\r
76 UNREFERENCED_PARAMETER(lParam);
\r
77 CDockSimple* pDockSimple = (CDockSimple*)GetView();
\r
78 CSimpleView* pView = (CSimpleView*)pDockSimple->GetView();
\r
80 switch (LOWORD(wParam))
\r
82 case IDM_COLOR_BLACK:
\r
83 pView->SetColor(RGB(0,0,0));
\r
84 pView->Invalidate();
\r
87 pView->SetColor(RGB(255, 0, 0));
\r
88 pView->Invalidate();
\r
90 case IDM_COLOR_GREEN:
\r
91 pView->SetColor(RGB(0, 255, 0));
\r
92 pView->Invalidate();
\r
94 case IDM_COLOR_BLUE:
\r
95 pView->SetColor(RGB(0, 0, 255));
\r
96 pView->Invalidate();
\r
98 case IDM_COLOR_WHITE:
\r
99 pView->SetColor(RGB(255, 255, 255));
\r
100 pView->Invalidate();
\r
107 LRESULT CSimpleMDIChild::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
112 CDocker* pDock = (CDocker*)GetView();
\r
113 pDock->RecalcDockLayout();
\r
117 // Do default processing for other messages
\r
118 return WndProcDefault(uMsg, wParam, lParam);
\r