--- /dev/null
+////////////////////////////////////////////////////\r
+// Mainfrm.cpp\r
+\r
+#include "stdafx.h"\r
+#include "resource.h"\r
+#include "mainfrm.h"\r
+\r
+\r
+// Definitions for the CMainFrame class\r
+CMainFrame::CMainFrame()\r
+{\r
+ // Constructor for CMainFrame. Its called after CFrame's constructor\r
+\r
+ //Set m_View as the view window of the frame\r
+ SetView(m_View);\r
+\r
+ // Set the registry key name, and load the initial window position\r
+ // Use a registry key name like "CompanyName\\Application"\r
+ LoadRegistrySettings(_T("Win32++\\Frame"));\r
+}\r
+\r
+CMainFrame::~CMainFrame()\r
+{\r
+ // Destructor for CMainFrame.\r
+}\r
+\r
+BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)\r
+{\r
+ // OnCommand responds to menu and and toolbar input\r
+\r
+ UNREFERENCED_PARAMETER(lParam);\r
+\r
+ switch(LOWORD(wParam))\r
+ {\r
+ case IDM_FILE_OPEN:\r
+ // Refer to the tutorial for an example of OnFileOpen\r
+ OnFileOpen();\r
+ return TRUE;\r
+ case IDM_FILE_SAVE:\r
+ // Refer to the tutorial for an example of OnFileSave\r
+ OnFileSave();\r
+ return TRUE;\r
+ case IDM_FILE_SAVEAS:\r
+ // Refer to the tutorial for an example of OnFileSaveAs\r
+ OnFileSave();\r
+ return TRUE;\r
+ case IDM_FILE_PRINT:\r
+ OnFilePrint();\r
+ return TRUE;\r
+ case IDM_FILE_EXIT:\r
+ // End the application\r
+ PostQuitMessage(0);\r
+ return TRUE;\r
+ case IDW_VIEW_STATUSBAR:\r
+ OnViewStatusBar();\r
+ return TRUE;\r
+ case IDW_VIEW_TOOLBAR:\r
+ OnViewToolBar();\r
+ return TRUE;\r
+ case IDM_HELP_ABOUT:\r
+ // Display the help dialog\r
+ OnHelp();\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+void CMainFrame::OnCreate()\r
+{\r
+ // OnCreate controls the way the frame is created.\r
+ // Overriding CFrame::Oncreate is optional.\r
+ // The default for the following variables is TRUE\r
+\r
+ // m_bShowIndicatorStatus = FALSE; // Don't show statusbar indicators\r
+ // m_bShowMenuStatus = FALSE; // Don't show toolbar or menu status\r
+ // m_bUseReBar = FALSE; // Don't use rebars\r
+ // m_bUseThemes = FALSE; // Don't use themes\r
+ // m_bUseToolBar = FALSE; // Don't use a toolbar\r
+\r
+ // call the base class function\r
+ CFrame::OnCreate();\r
+}\r
+\r
+void CMainFrame::OnInitialUpdate()\r
+{\r
+ // The frame is now created.\r
+ // Place any additional startup code here.\r
+\r
+ TRACE(_T("Frame created\n"));\r
+}\r
+\r
+void CMainFrame::OnFileOpen()\r
+{\r
+ // Bring up the file open dialog\r
+ CFile File;\r
+ CString str = File.OpenFileDialog(0, 0, 0, 0);\r
+\r
+ // TODO:\r
+ // Add your own code here. Refer to the tutorial for additional information \r
+}\r
+\r
+void CMainFrame::OnFileSave()\r
+{\r
+ // Bring up the file save dialog.\r
+ CFile File;\r
+ CString str = File.SaveFileDialog(0, 0, 0, 0, 0);\r
+\r
+ // TODO:\r
+ // Add your own code here. Refer to the tutorial for additional information \r
+}\r
+\r
+void CMainFrame::OnFilePrint()\r
+{\r
+ // Bring up a dialog to choose the printer\r
+ PRINTDLG pd = {0};\r
+ pd.lStructSize = sizeof( pd );\r
+ pd.Flags = PD_RETURNDC;\r
+ pd.hwndOwner = m_hWnd;\r
+\r
+ // Retrieve the printer DC\r
+ PrintDlg( &pd );\r
+ \r
+ // TODO:\r
+ // Add your own code here. Refer to the tutorial for additional information \r
+}\r
+\r
+LRESULT CMainFrame::OnNotify(WPARAM wParam, LPARAM lParam)\r
+{\r
+ // Process notification messages sent by child windows\r
+// switch(((LPNMHDR)lParam)->code)\r
+// {\r
+ //Add case statments for each notification message here\r
+// }\r
+\r
+ // Some notifications should return a value when handled\r
+ return CFrame::OnNotify(wParam, lParam);\r
+}\r
+\r
+void CMainFrame::SetupToolBar()\r
+{\r
+ // Set the Resource IDs for the toolbar buttons\r
+ AddToolBarButton( IDM_FILE_NEW );\r
+ AddToolBarButton( IDM_FILE_OPEN );\r
+ AddToolBarButton( IDM_FILE_SAVE );\r
+ \r
+ AddToolBarButton( 0 ); // Separator\r
+ AddToolBarButton( IDM_EDIT_CUT, FALSE ); // disabled button\r
+ AddToolBarButton( IDM_EDIT_COPY, FALSE ); // disabled button\r
+ AddToolBarButton( IDM_EDIT_PASTE, FALSE ); // disabled button\r
+ \r
+ AddToolBarButton( 0 ); // Separator\r
+ AddToolBarButton( IDM_FILE_PRINT );\r
+ \r
+ AddToolBarButton( 0 ); // Separator\r
+ AddToolBarButton( IDM_HELP_ABOUT );\r
+}\r
+\r
+LRESULT CMainFrame::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+{\r
+ switch (uMsg)\r
+ {\r
+ case WM_DESTROY:\r
+ PostThreadMessage(m_View.GetThreadID(), WM_QUIT, 0, 0);\r
+ ::WaitForSingleObject(m_View.GetThread(), INFINITE);\r
+ break;\r
+ case UWM_VIEWCREATED:\r
+ RecalcLayout();\r
+ break;\r
+ }\r
+\r
+ // pass unhandled messages on for default processing\r
+ return WndProcDefault(uMsg, wParam, lParam);\r
+}\r
+\r