1
//============================================================================
3
// SSSS tt lll lll XX XX
4
// SS SS tt ll ll XX XX
5
// SS tttttt eeee ll ll aaaa XX XX
6
// SSSS tt ee ee ll ll aa XXX
7
// SS tt eeeeee ll ll aaaaa XX XX
8
// SS SS tt ee ll ll aa aa XX XX
9
// SSSS ttt eeeee llll llll aaaaa XX XX
11
// Copyright (c) 1995-2000 by Jeff Miller
12
// Copyright (c) 2004 by Stephen Anthony
14
// See the file "license" for information on usage and redistribution of
15
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
17
// $Id: PropertySheet.cxx,v 1.2 2004/07/15 03:03:27 stephena Exp $
18
//============================================================================
21
#include "PropertySheet.hxx"
23
#pragma comment(lib, "comctl32")
26
typedef struct DLGTEMPLATEEX
38
} DLGTEMPLATEEX, *LPDLGTEMPLATEEX;
42
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
43
CPropertyPage::CPropertyPage( UINT nIDTemplate, UINT nIDCaption /* = 0 */ )
45
UNUSED_ALWAYS( nIDCaption );
47
ZeroMemory(&m_psp, sizeof(m_psp));
48
m_psp.dwSize = sizeof(m_psp);
49
m_psp.dwFlags = PSP_USECALLBACK;
50
// m_psp.hInstance = hInstance;
51
m_psp.pszTemplate = MAKEINTRESOURCE(nIDTemplate);
52
m_psp.pfnDlgProc = StaticDlgProc;
53
m_psp.lParam = (LPARAM)this;
54
m_psp.pfnCallback = StaticCallback;
57
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59
CPropertyPage::StaticCallback( HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp )
61
UNUSED_ALWAYS( hwnd );
62
UNUSED_ALWAYS( ppsp );
67
// ppsp->lParam holds create lParam
77
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
79
CPropertyPage::StaticDlgProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
81
CPropertyPage* pPage = NULL;
86
pPage = reinterpret_cast<CPropertyPage*>(
87
reinterpret_cast<PROPSHEETPAGE*>( lParam )->lParam );
88
(void)::SetWindowLong( hwnd, DWL_USER, reinterpret_cast<LONG>( pPage ) );
92
pPage = reinterpret_cast<CPropertyPage*>( GetWindowLong( hwnd, DWL_USER ) );
98
return pPage->DlgProc( hwnd, uMsg, wParam, lParam );
101
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
103
CPropertyPage::DlgProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
108
OnActivate( (UINT)LOWORD(wParam), (HWND)lParam, (BOOL)HIWORD(wParam) );
112
return OnInitDialog( hwnd );
119
return OnCommand( HIWORD(wParam), LOWORD(wParam), (HWND)lParam );
122
// Handle PSN_QUERYCANCEL?
123
// Handle PSN_KILLACTIVE?
124
switch (((LPNMHDR)lParam)->code)
127
SetWindowLong(hwnd, DWL_MSGRESULT, OnSetActive( (LPPSHNOTIFY)lParam ) );
131
SetWindowLong(hwnd, DWL_MSGRESULT, OnKillActive( (LPPSHNOTIFY)lParam ) );
135
SetWindowLong( hwnd, DWL_MSGRESULT, OnApply( (LPPSHNOTIFY)lParam) );
139
OnReset( (LPPSHNOTIFY)lParam );
142
return OnNotify( (int)wParam, (LPNMHDR)lParam );
148
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
149
CPropertySheet::CPropertySheet( LPCTSTR pszCaption, HWND hwndParent,
150
UINT nStartPage /* = 0 */ )
151
: m_strCaption( pszCaption )
153
ZeroMemory(&m_psh, sizeof(m_psh));
154
m_psh.dwSize = sizeof(m_psh);
155
m_psh.dwFlags = PSH_NOAPPLYNOW | PSH_PROPSHEETPAGE | PSH_USECALLBACK;
156
m_psh.hwndParent = hwndParent;
157
m_psh.hInstance = (HINSTANCE)GetWindowLong(hwndParent, GWL_HINSTANCE);
158
m_psh.pszCaption = m_strCaption.c_str();
159
m_psh.nStartPage = nStartPage;
160
m_psh.pfnCallback = StaticCallback;
163
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
164
CPropertySheet::~CPropertySheet()
166
// BUGBUG: This is static!
168
/* if ( m_hfontLogo )
170
DeleteObject( m_hfontLogo );
175
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
176
void CPropertySheet::AddPage( CPropertyPage* pPage )
179
m_pages.push_back(pPage);
182
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
183
int CPropertySheet::DoModal()
185
int nSize = m_pages.size();
190
PROPSHEETPAGE* pspage = new PROPSHEETPAGE[nSize];
191
for (int i = 0; i < nSize; ++i)
193
CopyMemory(&(pspage[i]), m_pages[i]->GetPropSheetPage(),
194
sizeof(PROPSHEETPAGE));
195
pspage[i].hInstance = m_psh.hInstance;
198
m_psh.nPages = nSize;
201
int nRet = ::PropertySheet( &m_psh );
208
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
210
CPropertySheet::StaticCallback( HWND hwnd, UINT uMsg, LPARAM lParam )
212
UNUSED_ALWAYS( hwnd );
216
case PSCB_INITIALIZED:
217
// Property sheet is being initialized
221
// Property sheet is about to be created
222
// Remove the DS_CONTEXTHELP style from the dialog template
223
// (This will remove the "?" in the top right corner)
224
if ( ( (LPDLGTEMPLATEEX)lParam )->signature == 0xFFFF)
225
( (LPDLGTEMPLATEEX)lParam )->style &= ~DS_CONTEXTHELP;
227
( (LPDLGTEMPLATE)lParam )->style &= ~DS_CONTEXTHELP;