--- /dev/null
+//////////////////////////////////////////////\r
+// SimpleMDIChild.cpp\r
+// Definitions for the CSimpleView and CSimpleMDIChild classes\r
+\r
+#include "stdafx.h"\r
+#include "SimpleMDIChild.h"\r
+#include "resource.h"\r
+\r
+\r
+// CSimpleView definitions\r
+CSimpleView::CSimpleView() : m_Color(RGB(0,0,255))\r
+{\r
+}\r
+\r
+void CSimpleView::OnDraw(CDC* pDC)\r
+{\r
+ //Centre some text in our view window\r
+ CRect rc = GetClientRect();\r
+ pDC->SetTextColor(m_Color);\r
+ pDC->DrawText(_T("View Window"), -1, rc, DT_CENTER|DT_VCENTER|DT_SINGLELINE);\r
+}\r
+\r
+LRESULT CSimpleView::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+{\r
+ switch (uMsg)\r
+ {\r
+ case WM_SIZE:\r
+ // Force the window to be repainted\r
+ ::InvalidateRect(m_hWnd, NULL, TRUE);\r
+ break; // Also do default processing\r
+ }\r
+\r
+ // Do default processing for other messages\r
+ return WndProcDefault(uMsg, wParam, lParam);\r
+}\r
+\r
+// CSimpleMDIChild definitions\r
+CSimpleMDIChild::CSimpleMDIChild()\r
+{\r
+ // Set m_View as the view window of the MDI child\r
+ SetView(m_View);\r
+ \r
+ // Set the menu for this MDI child\r
+ HINSTANCE hResource = GetApp()->GetResourceHandle();\r
+ HMENU hChildMenu = LoadMenu(hResource, _T("MdiMenuView"));\r
+ SetHandles(hChildMenu, NULL);\r
+}\r
+\r
+CSimpleMDIChild::~CSimpleMDIChild()\r
+{\r
+}\r
+\r
+void CSimpleMDIChild::OnInitialUpdate()\r
+{\r
+ // Set the window caption\r
+ ::SetWindowText(m_hWnd, _T("Simple Window"));\r
+ \r
+ // Set the window icons\r
+ SetIconLarge(IDI_VIEW);\r
+ SetIconSmall(IDI_VIEW);\r
+}\r
+\r
+BOOL CSimpleMDIChild::OnCommand(WPARAM wParam, LPARAM lParam)\r
+{\r
+ // Respond to menu and toolbar input\r
+\r
+ UNREFERENCED_PARAMETER(lParam);\r
+\r
+ switch (LOWORD(wParam))\r
+ {\r
+ case IDM_COLOR_BLACK:\r
+ m_View.SetColor(RGB(0,0,0));\r
+ Invalidate();\r
+ return TRUE;\r
+ case IDM_COLOR_RED:\r
+ m_View.SetColor(RGB(255, 0, 0));\r
+ Invalidate();\r
+ return TRUE;\r
+ case IDM_COLOR_GREEN:\r
+ m_View.SetColor(RGB(0, 255, 0));\r
+ Invalidate();\r
+ return TRUE;\r
+ case IDM_COLOR_BLUE:\r
+ m_View.SetColor(RGB(0, 0, 255));\r
+ Invalidate();\r
+ return TRUE;\r
+ case IDM_COLOR_WHITE:\r
+ m_View.SetColor(RGB(255, 255, 255));\r
+ Invalidate();\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+LRESULT CSimpleMDIChild::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+{\r
+// switch (uMsg)\r
+// {\r
+\r
+// }\r
+\r
+ // Do default processing for other messages\r
+ return WndProcDefault(uMsg, wParam, lParam);\r
+}\r