Commit before breaking everything
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / samples / Picture / 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++\\Picture Sample"));\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_NEW:\r
36                 OnFileNew();\r
37                 return TRUE;\r
38         case IDM_FILE_OPEN:\r
39                 OnFileOpen();\r
40                 return TRUE;\r
41         case IDM_FILE_SAVE:\r
42                 OnFileSaveAs();\r
43                 return TRUE;\r
44         case IDM_FILE_SAVEAS:\r
45                 OnFileSaveAs();\r
46                 return TRUE;\r
47         case IDM_FILE_EXIT:\r
48                 // End the application\r
49                 ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);\r
50                 return TRUE;\r
51         case IDW_VIEW_STATUSBAR:\r
52                 OnViewStatusBar();\r
53                 return TRUE;\r
54         case IDW_VIEW_TOOLBAR:\r
55                 OnViewToolBar();\r
56                 return TRUE;\r
57         case IDM_HELP_ABOUT:\r
58                 // Display the help dialog\r
59                 OnHelp();\r
60                 return TRUE;\r
61         }\r
62 \r
63         return FALSE;\r
64 }\r
65 \r
66 void CMainFrame::OnCreate()\r
67 {\r
68         CFrame::OnCreate();\r
69 }\r
70 \r
71 void CMainFrame::OnFileNew()\r
72 {\r
73         m_View.NewPictureFile();\r
74 }\r
75 \r
76 void CMainFrame::OnFileOpen()\r
77 {\r
78         TCHAR szFilter[] = _T("Supported Files Types(*.bmp;*.gif;*.jpg;*.ico;*.emf;*.wmf)\0*.bmp;*.gif;*.jpg;*.ico;*.emf;*.wmf\0Bitmaps (*.bmp)\0*.bmp\0GIF Files (*.gif)\0*.gif\0JPEG Files (*.jpg)\0*.jpg\0Icons (*.ico)\0*.ico\0Enhanced Metafiles (*.emf)\0*.emf\0Windows Metafiles (*.wmf)\0*.wmf\0\0");\r
79 \r
80         CFile File;\r
81         CString str = File.OpenFileDialog(0, OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, szFilter, this);\r
82         if (!str.IsEmpty())\r
83         {\r
84                 m_View.LoadPictureFile(str);\r
85                 CRect rcImage = m_View.GetImageRect();\r
86                 AdjustFrameRect(rcImage);\r
87         }\r
88 }\r
89 \r
90 void CMainFrame::OnFileSaveAs()\r
91 {\r
92         if (m_View.GetPicture())\r
93         {\r
94                 TCHAR szFilter[] = _T("*.bmp\0");\r
95                 CFile File;\r
96                 CString str = File.SaveFileDialog(0, OFN_SHOWHELP | OFN_OVERWRITEPROMPT, szFilter, _T("bmp"), this);\r
97                 \r
98                 if (!str.IsEmpty())\r
99                 {\r
100                         m_View.SavePicture(str);\r
101                 }\r
102         }\r
103 }\r
104 \r
105 void CMainFrame::SetupToolBar()\r
106 {       \r
107         // Set the Resource IDs for the toolbar buttons\r
108         AddToolBarButton( IDM_FILE_NEW   );\r
109         AddToolBarButton( IDM_FILE_OPEN  );\r
110         AddToolBarButton( IDM_FILE_SAVE  );\r
111         \r
112         AddToolBarButton( 0 );  // Separator\r
113         AddToolBarButton( IDM_EDIT_CUT,   FALSE );\r
114         AddToolBarButton( IDM_EDIT_COPY,  FALSE );\r
115         AddToolBarButton( IDM_EDIT_PASTE, FALSE );\r
116 \r
117         AddToolBarButton( 0 );  // Separator\r
118         AddToolBarButton( IDM_FILE_PRINT, FALSE );\r
119         \r
120         AddToolBarButton( 0 );  // Separator\r
121         AddToolBarButton( IDM_HELP_ABOUT );\r
122 \r
123         // Set the image lists for normal, hot and disabled buttons\r
124         SetToolBarImages(RGB(192,192,192), IDB_TOOLBAR_NORM, IDB_TOOLBAR_HOT, IDB_TOOLBAR_DIS);\r
125 }\r
126 \r
127 LRESULT CMainFrame::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
128 {\r
129 //      switch (uMsg)\r
130 //      {\r
131                 // Add case statements for each messages to be handled here\r
132 //      }\r
133 \r
134         // pass unhandled messages on for default processing\r
135         return WndProcDefault(uMsg, wParam, lParam);\r
136 }\r
137 \r

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