Merge branch 'master' of git.ucc.asn.au:/matches/honours
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / samples / PropertySheet / src / MyPropertySheet.cpp
1 //////////////////////////////////////////////\r
2 // MyPropertySheet.cpp\r
3 \r
4 #include "stdafx.h"\r
5 #include "Mainfrm.h"\r
6 #include "MyPropertySheet.h"\r
7 #include "resource.h"\r
8 \r
9 \r
10 CButtonPage::CButtonPage(UINT nIDTemplate, LPCTSTR szTitle /* = NULL*/) : CPropertyPage(nIDTemplate, szTitle)\r
11 {\r
12 }\r
13 \r
14 INT_PTR CButtonPage::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
15 {\r
16         switch (uMsg)\r
17         {\r
18         // on any command notification, tell the property sheet to enable the Apply button\r
19         case WM_COMMAND:\r
20                 PropSheet_Changed(GetParent()->GetHwnd(), m_hWnd);\r
21                 break;\r
22 \r
23         default:\r
24                 break;\r
25         }\r
26 \r
27         return DialogProcDefault(uMsg, wParam, lParam);\r
28 }\r
29 \r
30 int CButtonPage::OnApply()\r
31\r
32         TRACE (_T("Appy button pressed\n")); \r
33         \r
34         // The possible return values are:\r
35         // PSNRET_NOERROR. The changes made to this page are valid and have been applied\r
36         // PSNRET_INVALID. The property sheet will not be destroyed, and focus will be returned to this page.\r
37         // PSNRET_INVALID_NOCHANGEPAGE. The property sheet will not be destroyed, and focus will be returned;\r
38 \r
39         return Validate();\r
40 }\r
41 \r
42 void CButtonPage::OnCancel()\r
43\r
44         TRACE (_T("Cancel button pressed\n")); \r
45 }\r
46 \r
47 BOOL CButtonPage::OnInitDialog()\r
48\r
49         TRACE (_T("Button page created\n")); \r
50         return TRUE; \r
51 }\r
52 \r
53 int CButtonPage::OnOK()\r
54\r
55         TRACE (_T("OK button pressed\n"));\r
56 \r
57         // The possible return values are:\r
58         // PSNRET_NOERROR. The changes made to this page are valid and have been applied\r
59         // PSNRET_INVALID. The property sheet will not be destroyed, and focus will be returned to this page.\r
60         // PSNRET_INVALID_NOCHANGEPAGE. The property sheet will not be destroyed, and focus will be returned;\r
61 \r
62         return Validate(); \r
63 }\r
64 \r
65 BOOL CButtonPage::OnQueryCancel()\r
66\r
67         TRACE (_T("Ok to Cancel?\n")); \r
68         \r
69         return FALSE;    // Allow cancel to proceed\r
70 }\r
71 \r
72 int CButtonPage::OnSetActive()\r
73 {\r
74         TRACE(_T("Button page is now active\n"));\r
75 \r
76         // Set the wizard buttons\r
77         SetWizardButtons(PSWIZB_NEXT);\r
78 \r
79         return 0;\r
80 }\r
81 \r
82 int CButtonPage::Validate()\r
83 {\r
84         // This is where we validate (and save) the contents of this page before it is closed\r
85         \r
86         // return one of these values:\r
87         // PSNRET_NOERROR. The changes made to this page are valid and have been applied\r
88         // PSNRET_INVALID. The property sheet will not be destroyed, and focus will be returned to this page.\r
89         // PSNRET_INVALID_NOCHANGEPAGE. The property sheet will not be destroyed, and focus will be returned \r
90         //                               to the page that had focus when the button was pressed.\r
91 \r
92 \r
93         int nStatus = PSNRET_NOERROR;\r
94 //      int nStatus = PSNRET_INVALID;\r
95 //      int nStatus = PSNRET_INVALID_NOCHANGEPAGE;\r
96 \r
97 // Tell the user what went wrong\r
98         if (nStatus != PSNRET_NOERROR)\r
99                 MessageBox(_T("Button Page Validation Failed"), _T("PageSheet Check"), MB_OK);\r
100         else\r
101                 TRACE(_T("Button Page Validation passed\n"));\r
102         \r
103         return nStatus;\r
104 }\r
105 \r
106 CComboPage::CComboPage(UINT nIDTemplate, LPCTSTR szTitle /* = NULL*/) : CPropertyPage(nIDTemplate, szTitle)\r
107 {\r
108 }\r
109 \r
110 INT_PTR CComboPage::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
111 {\r
112 \r
113         switch (uMsg)\r
114         {\r
115         // on any command notification, tell the property sheet to enable the Apply button\r
116         case WM_COMMAND:\r
117                 PropSheet_Changed(GetParent()->GetHwnd(), m_hWnd);\r
118                 break;\r
119 \r
120         default:\r
121                 break;\r
122         }\r
123 \r
124         return DialogProcDefault(uMsg, wParam, lParam);\r
125 }\r
126 \r
127 BOOL CComboPage::OnInitDialog()\r
128 {\r
129         TRACE (_T("Combo page created\n"));\r
130 \r
131         // Put some text in the Combo Boxes\r
132         for (int i = 0 ; i < 6 ; i++)\r
133         {\r
134                 SendDlgItemMessage( IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM) _T("C Box 1") );\r
135                 SendDlgItemMessage( IDC_COMBO2, CB_ADDSTRING, 0, (LPARAM) _T("C Box 2") );\r
136                 SendDlgItemMessage( IDC_COMBO3, CB_ADDSTRING, 0, (LPARAM) _T("C Box 3") );\r
137         }\r
138 \r
139         return TRUE;\r
140 }\r
141 \r
142 int CComboPage::OnSetActive()\r
143 {\r
144         TRACE(_T("Combo page is now active\n"));\r
145 \r
146         // Set the wizard buttons\r
147         SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH);\r
148 \r
149         return 0;\r
150 }\r
151 \r
152 CMyPropertySheet::CMyPropertySheet(LPCTSTR pszCaption /*=NULL*/, CWnd* pParent /* = NULL*/) : CPropertySheet(pszCaption, pParent)\r
153 {\r
154         SetIcon(IDI_DIALOG);\r
155 }\r
156 \r
157 inline void CMyPropertySheet::OnCreate()\r
158 {\r
159         // Adjust layout for modeless property sheet\r
160         if ((IsModeless()) && !(IsWizard()))\r
161         {\r
162                 // Reposition windows\r
163                 RECT rc = GetWindowRect();\r
164                 RECT rcButton = GetDlgItem(IDOK)->GetWindowRect();\r
165                 SetWindowPos(NULL, 0, 0, rc.right - rc.left, rcButton.top - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);\r
166 \r
167                 // Remove buttons\r
168                 DestroyButton(IDOK);\r
169                 DestroyButton(IDCANCEL);\r
170                 DestroyButton(ID_APPLY_NOW);\r
171                 DestroyButton(IDHELP);\r
172         }\r
173 \r
174         // Remove system menu for wizards\r
175         if (IsWizard())\r
176         {\r
177                 DWORD dwStyle = (DWORD)GetWindowLongPtr(GWL_STYLE);\r
178                 dwStyle &= ~WS_SYSMENU;\r
179                 SetWindowLongPtr(GWL_STYLE, dwStyle);\r
180         }\r
181 }\r
182 \r
183 void CMyPropertySheet::OnInitialUpdate()\r
184 {\r
185         CenterWindow();\r
186 }\r
187 \r
188 LRESULT CMyPropertySheet::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
189 {\r
190 //      switch (uMsg)\r
191 //      {\r
192 //\r
193 //      }\r
194 \r
195         // pass unhandled messages on for default processing\r
196         return WndProcDefault(uMsg, wParam, lParam);    \r
197 }\r
198 \r

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