Merge branch 'master' of git.ucc.asn.au:/matches/honours
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / samples / DirectX / src / Mainfrm.cpp
1 ////////////////////////////////////////////////////\r
2 // Mainfrm.cpp\r
3 \r
4 #include "stdafx.h"\r
5 #include "resource.h"\r
6 #include "mainfrm.h"\r
7 \r
8 \r
9 // Definitions for the CMainFrame class\r
10 CMainFrame::CMainFrame()\r
11 {\r
12         // Constructor for CMainFrame. Its called after CFrame's constructor\r
13 \r
14         //Set m_View as the view window of the frame\r
15         SetView(m_View);\r
16 \r
17         // Set the registry key name, and load the initial window position\r
18         // Use a registry key name like "CompanyName\\Application"\r
19         LoadRegistrySettings(_T("Win32++\\Frame"));\r
20 }\r
21 \r
22 CMainFrame::~CMainFrame()\r
23 {\r
24         // Destructor for CMainFrame.\r
25 }\r
26 \r
27 BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)\r
28 {\r
29         // OnCommand responds to menu and and toolbar input\r
30 \r
31         UNREFERENCED_PARAMETER(lParam);\r
32 \r
33         switch(LOWORD(wParam))\r
34         {\r
35         case IDM_FILE_OPEN:\r
36                 // Refer to the tutorial for an example of OnFileOpen\r
37                 OnFileOpen();\r
38                 return TRUE;\r
39         case IDM_FILE_SAVE:\r
40                 // Refer to the tutorial for an example of OnFileSave\r
41                 OnFileSave();\r
42                 return TRUE;\r
43         case IDM_FILE_SAVEAS:\r
44                 // Refer to the tutorial for an example of OnFileSaveAs\r
45                 OnFileSave();\r
46                 return TRUE;\r
47         case IDM_FILE_PRINT:\r
48                 OnFilePrint();\r
49                 return TRUE;\r
50         case IDM_FILE_EXIT:\r
51                 // End the application\r
52                 PostQuitMessage(0);\r
53                 return TRUE;\r
54         case IDW_VIEW_STATUSBAR:\r
55                 OnViewStatusBar();\r
56                 return TRUE;\r
57         case IDW_VIEW_TOOLBAR:\r
58                 OnViewToolBar();\r
59                 return TRUE;\r
60         case IDM_HELP_ABOUT:\r
61                 // Display the help dialog\r
62                 OnHelp();\r
63                 return TRUE;\r
64         }\r
65 \r
66         return FALSE;\r
67 }\r
68 \r
69 void CMainFrame::OnCreate()\r
70 {\r
71         // OnCreate controls the way the frame is created.\r
72         // Overriding CFrame::Oncreate is optional.\r
73         // The default for the following variables is TRUE\r
74 \r
75         // m_bShowIndicatorStatus = FALSE;      // Don't show statusbar indicators\r
76         // m_bShowMenuStatus = FALSE;           // Don't show toolbar or menu status\r
77         // m_bUseReBar = FALSE;                         // Don't use rebars\r
78         // m_bUseThemes = FALSE;            // Don't use themes\r
79         // m_bUseToolBar = FALSE;                       // Don't use a toolbar\r
80 \r
81         // call the base class function\r
82         CFrame::OnCreate();\r
83 }\r
84 \r
85 void CMainFrame::OnInitialUpdate()\r
86 {\r
87         // The frame is now created.\r
88         // Place any additional startup code here.\r
89 \r
90         TRACE(_T("Frame created\n"));\r
91 }\r
92 \r
93 void CMainFrame::OnFileOpen()\r
94 {\r
95         // Bring up the file open dialog\r
96         CFile File;\r
97         CString str = File.OpenFileDialog(0, 0, 0, 0);\r
98 \r
99         // TODO:\r
100         // Add your own code here. Refer to the tutorial for additional information \r
101 }\r
102 \r
103 void CMainFrame::OnFileSave()\r
104 {\r
105         // Bring up the file save dialog.\r
106         CFile File;\r
107         CString str = File.SaveFileDialog(0, 0, 0, 0, 0);\r
108 \r
109         // TODO:\r
110         // Add your own code here. Refer to the tutorial for additional information \r
111 }\r
112 \r
113 void CMainFrame::OnFilePrint()\r
114 {\r
115         // Bring up a dialog to choose the printer\r
116         PRINTDLG pd = {0};\r
117         pd.lStructSize = sizeof( pd );\r
118         pd.Flags = PD_RETURNDC;\r
119         pd.hwndOwner = m_hWnd;\r
120 \r
121         // Retrieve the printer DC\r
122         PrintDlg( &pd );\r
123         \r
124         // TODO:\r
125         // Add your own code here. Refer to the tutorial for additional information \r
126 }\r
127 \r
128 LRESULT CMainFrame::OnNotify(WPARAM wParam, LPARAM lParam)\r
129 {\r
130         // Process notification messages sent by child windows\r
131 //      switch(((LPNMHDR)lParam)->code)\r
132 //      {\r
133                 //Add case statments for each notification message here\r
134 //      }\r
135 \r
136         // Some notifications should return a value when handled\r
137         return CFrame::OnNotify(wParam, lParam);\r
138 }\r
139 \r
140 void CMainFrame::SetupToolBar()\r
141 {\r
142         // Set the Resource IDs for the toolbar buttons\r
143         AddToolBarButton( IDM_FILE_NEW   );\r
144         AddToolBarButton( IDM_FILE_OPEN  );\r
145         AddToolBarButton( IDM_FILE_SAVE  );\r
146         \r
147         AddToolBarButton( 0 );                          // Separator\r
148         AddToolBarButton( IDM_EDIT_CUT,   FALSE );      // disabled button\r
149         AddToolBarButton( IDM_EDIT_COPY,  FALSE );      // disabled button\r
150         AddToolBarButton( IDM_EDIT_PASTE, FALSE );      // disabled button\r
151         \r
152         AddToolBarButton( 0 );                          // Separator\r
153         AddToolBarButton( IDM_FILE_PRINT );\r
154         \r
155         AddToolBarButton( 0 );                          // Separator\r
156         AddToolBarButton( IDM_HELP_ABOUT );\r
157 }\r
158 \r
159 LRESULT CMainFrame::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
160 {\r
161         switch (uMsg)\r
162         {\r
163         case WM_DESTROY:\r
164                 PostThreadMessage(m_View.GetThreadID(), WM_QUIT, 0, 0);\r
165                 ::WaitForSingleObject(m_View.GetThread(), INFINITE);\r
166                 break;\r
167         case UWM_VIEWCREATED:\r
168                 RecalcLayout();\r
169                 break;\r
170         }\r
171 \r
172         // pass unhandled messages on for default processing\r
173         return WndProcDefault(uMsg, wParam, lParam);\r
174 }\r
175 \r

UCC git Repository :: git.ucc.asn.au