1 //////////////////////////////////////////////
\r
2 // SimpleMDIChild.cpp
\r
3 // Definitions for the CSimpleView and CSimpleMDIChild classes
\r
6 #include "SimpleMDIChild.h"
\r
7 #include "resource.h"
\r
10 // CSimpleView definitions
\r
11 CSimpleView::CSimpleView() : m_Color(RGB(0,0,255))
\r
15 void CSimpleView::OnDraw(CDC* pDC)
\r
17 //Centre some text in our view window
\r
18 CRect rc = GetClientRect();
\r
19 pDC->SetTextColor(m_Color);
\r
20 pDC->DrawText(_T("View Window"), -1, rc, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
\r
23 LRESULT CSimpleView::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
28 // Force the window to be repainted
\r
29 ::InvalidateRect(m_hWnd, NULL, TRUE);
\r
30 break; // Also do default processing
\r
33 // Do default processing for other messages
\r
34 return WndProcDefault(uMsg, wParam, lParam);
\r
37 // CSimpleMDIChild definitions
\r
38 CSimpleMDIChild::CSimpleMDIChild()
\r
40 // Set m_View as the view window of the MDI child
\r
43 // Set the menu for this MDI child
\r
44 HINSTANCE hResource = GetApp()->GetResourceHandle();
\r
45 HMENU hChildMenu = LoadMenu(hResource, _T("MdiMenuView"));
\r
46 SetHandles(hChildMenu, NULL);
\r
49 CSimpleMDIChild::~CSimpleMDIChild()
\r
53 void CSimpleMDIChild::OnInitialUpdate()
\r
55 // Set the window caption
\r
56 ::SetWindowText(m_hWnd, _T("Simple Window"));
\r
58 // Set the window icons
\r
59 SetIconLarge(IDI_VIEW);
\r
60 SetIconSmall(IDI_VIEW);
\r
63 BOOL CSimpleMDIChild::OnCommand(WPARAM wParam, LPARAM lParam)
\r
65 // Respond to menu and toolbar input
\r
67 UNREFERENCED_PARAMETER(lParam);
\r
69 switch (LOWORD(wParam))
\r
71 case IDM_COLOR_BLACK:
\r
72 m_View.SetColor(RGB(0,0,0));
\r
76 m_View.SetColor(RGB(255, 0, 0));
\r
79 case IDM_COLOR_GREEN:
\r
80 m_View.SetColor(RGB(0, 255, 0));
\r
83 case IDM_COLOR_BLUE:
\r
84 m_View.SetColor(RGB(0, 0, 255));
\r
87 case IDM_COLOR_WHITE:
\r
88 m_View.SetColor(RGB(255, 255, 255));
\r
96 LRESULT CSimpleMDIChild::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
103 // Do default processing for other messages
\r
104 return WndProcDefault(uMsg, wParam, lParam);
\r