1 ////////////////////////////////////////////////////
\r
2 // MainMDIfrm.cpp - definitions for the CMainMDIFrame class
\r
5 #include "mainMDIfrm.h"
\r
6 #include "SimpleMDIChild.h"
\r
7 #include "resource.h"
\r
10 CMainMDIFrame::CMainMDIFrame()
\r
12 // Set the registry key name, and load the initial window position
\r
13 // Use a registry key name like "CompanyName\\Application"
\r
14 LoadRegistrySettings(_T("Win32++\\MDI Frame"));
\r
17 CMainMDIFrame::~CMainMDIFrame()
\r
21 void CMainMDIFrame::OnFileOpen()
\r
23 // Bring up the file open dialog
\r
25 CString str = File.OpenFileDialog(0, 0, 0, 0);
\r
28 // Add your own code here. Refer to the tutorial for additional information
\r
31 void CMainMDIFrame::OnFileSave()
\r
33 // Bring up the file save dialog.
\r
35 CString str = File.SaveFileDialog(0, 0, 0, 0, 0);
\r
38 // Add your own code here. Refer to the tutorial for additional information
\r
41 void CMainMDIFrame::OnFilePrint()
\r
43 // Bring up a dialog to choose the printer
\r
45 pd.lStructSize = sizeof( pd );
\r
46 pd.Flags = PD_RETURNDC;
\r
47 pd.hwndOwner = m_hWnd;
\r
49 // Retrieve the printer DC
\r
53 // Add your own code here. Refer to the tutorial for additional information
\r
57 void CMainMDIFrame::OnInitialUpdate()
\r
59 TRACE(_T("MDI Frame started \n"));
\r
60 //The frame is now created.
\r
61 //Place any additional startup code here.
\r
64 BOOL CMainMDIFrame::OnCommand(WPARAM wParam, LPARAM lParam)
\r
66 switch (LOWORD(wParam))
\r
69 AddMDIChild(new CSimpleMDIChild); // CMDIFrame::RemoveMDIChild deletes this pointer
\r
71 case IDM_FILE_CLOSE: // Close the active MDI window
\r
72 GetActiveMDIChild()->SendMessage(WM_CLOSE, 0, 0);
\r
78 // Refer to the tutorial for an example of OnFileSave()
\r
80 case IDM_FILE_SAVEAS:
\r
81 // Refer to the tutorial for an example of OnFileSaveAs()
\r
83 case IDM_FILE_PRINT:
\r
86 case IDW_VIEW_STATUSBAR:
\r
89 case IDW_VIEW_TOOLBAR:
\r
92 case IDW_MDI_ARRANGE:
\r
95 case IDW_MDI_CASCADE:
\r
98 case IDW_MDI_CLOSEALL:
\r
99 RemoveAllMDIChildren();
\r
104 default: // Pass to active child...
\r
106 if (GetActiveMDIChild())
\r
107 GetActiveMDIChild()->SendMessage(WM_COMMAND, wParam, lParam);
\r
110 case IDM_FILE_EXIT:
\r
111 SendMessage(WM_CLOSE, 0, 0);
\r
113 case IDM_HELP_ABOUT:
\r
120 void CMainMDIFrame::OnCreate()
\r
122 // OnCreate controls the way the frame is created.
\r
123 // Overriding CFrame::Oncreate is optional.
\r
124 // The default for the following variables is TRUE
\r
126 // m_bShowIndicatorStatus = FALSE; // Don't show statusbar indicators
\r
127 // m_bShowMenuStatus = FALSE; // Don't show toolbar or menu status
\r
128 // m_bUseReBar = FALSE; // Don't use rebars
\r
129 // m_bUseThemes = FALSE; // Don't use themes
\r
130 // m_bUseToolBar = FALSE; // Don't use a toolbar
\r
131 // m_bUseCustomDraw = FALSE; // Don't use custom draw for menu items
\r
133 // call the base class function
\r
134 CMDIFrame::OnCreate();
\r
137 void CMainMDIFrame::SetupToolBar()
\r
139 // Define the resource IDs for the toolbar
\r
140 AddToolBarButton( IDM_FILE_NEW );
\r
141 AddToolBarButton( IDM_FILE_OPEN );
\r
142 AddToolBarButton( IDM_FILE_SAVE );
\r
143 AddToolBarButton( 0 ); // Separator
\r
144 AddToolBarButton( IDM_EDIT_CUT );
\r
145 AddToolBarButton( IDM_EDIT_COPY );
\r
146 AddToolBarButton( IDM_EDIT_PASTE );
\r
147 AddToolBarButton( 0 ); // Separator
\r
148 AddToolBarButton( IDM_FILE_PRINT );
\r
149 AddToolBarButton( 0 ); // Separator
\r
150 AddToolBarButton( IDM_HELP_ABOUT );
\r
153 LRESULT CMainMDIFrame::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
157 // Add case statements for each messages to be handled here
\r
160 // pass unhandled messages on for default processing
\r
161 return WndProcDefault(uMsg, wParam, lParam);
\r