1 //////////////////////////////////////////////
\r
2 // MyPropertySheet.cpp
\r
6 #include "MyPropertySheet.h"
\r
7 #include "resource.h"
\r
10 CButtonPage::CButtonPage(UINT nIDTemplate, LPCTSTR szTitle /* = NULL*/) : CPropertyPage(nIDTemplate, szTitle)
\r
14 INT_PTR CButtonPage::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
18 // on any command notification, tell the property sheet to enable the Apply button
\r
20 PropSheet_Changed(GetParent()->GetHwnd(), m_hWnd);
\r
27 return DialogProcDefault(uMsg, wParam, lParam);
\r
30 int CButtonPage::OnApply()
\r
32 TRACE (_T("Appy button pressed\n"));
\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
42 void CButtonPage::OnCancel()
\r
44 TRACE (_T("Cancel button pressed\n"));
\r
47 BOOL CButtonPage::OnInitDialog()
\r
49 TRACE (_T("Button page created\n"));
\r
53 int CButtonPage::OnOK()
\r
55 TRACE (_T("OK button pressed\n"));
\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
65 BOOL CButtonPage::OnQueryCancel()
\r
67 TRACE (_T("Ok to Cancel?\n"));
\r
69 return FALSE; // Allow cancel to proceed
\r
72 int CButtonPage::OnSetActive()
\r
74 TRACE(_T("Button page is now active\n"));
\r
76 // Set the wizard buttons
\r
77 SetWizardButtons(PSWIZB_NEXT);
\r
82 int CButtonPage::Validate()
\r
84 // This is where we validate (and save) the contents of this page before it is closed
\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
93 int nStatus = PSNRET_NOERROR;
\r
94 // int nStatus = PSNRET_INVALID;
\r
95 // int nStatus = PSNRET_INVALID_NOCHANGEPAGE;
\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
101 TRACE(_T("Button Page Validation passed\n"));
\r
106 CComboPage::CComboPage(UINT nIDTemplate, LPCTSTR szTitle /* = NULL*/) : CPropertyPage(nIDTemplate, szTitle)
\r
110 INT_PTR CComboPage::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
115 // on any command notification, tell the property sheet to enable the Apply button
\r
117 PropSheet_Changed(GetParent()->GetHwnd(), m_hWnd);
\r
124 return DialogProcDefault(uMsg, wParam, lParam);
\r
127 BOOL CComboPage::OnInitDialog()
\r
129 TRACE (_T("Combo page created\n"));
\r
131 // Put some text in the Combo Boxes
\r
132 for (int i = 0 ; i < 6 ; i++)
\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
142 int CComboPage::OnSetActive()
\r
144 TRACE(_T("Combo page is now active\n"));
\r
146 // Set the wizard buttons
\r
147 SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH);
\r
152 CMyPropertySheet::CMyPropertySheet(LPCTSTR pszCaption /*=NULL*/, CWnd* pParent /* = NULL*/) : CPropertySheet(pszCaption, pParent)
\r
154 SetIcon(IDI_DIALOG);
\r
157 inline void CMyPropertySheet::OnCreate()
\r
159 // Adjust layout for modeless property sheet
\r
160 if ((IsModeless()) && !(IsWizard()))
\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
168 DestroyButton(IDOK);
\r
169 DestroyButton(IDCANCEL);
\r
170 DestroyButton(ID_APPLY_NOW);
\r
171 DestroyButton(IDHELP);
\r
174 // Remove system menu for wizards
\r
177 DWORD dwStyle = (DWORD)GetWindowLongPtr(GWL_STYLE);
\r
178 dwStyle &= ~WS_SYSMENU;
\r
179 SetWindowLongPtr(GWL_STYLE, dwStyle);
\r
183 void CMyPropertySheet::OnInitialUpdate()
\r
188 LRESULT CMyPropertySheet::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
195 // pass unhandled messages on for default processing
\r
196 return WndProcDefault(uMsg, wParam, lParam);
\r