1 | /*
|
---|
2 | * Property Sheets
|
---|
3 | *
|
---|
4 | * Copyright 1998 Francis Beaudet
|
---|
5 | * Copyright 1999 Thuy Nguyen
|
---|
6 | *
|
---|
7 | * This library is free software; you can redistribute it and/or
|
---|
8 | * modify it under the terms of the GNU Lesser General Public
|
---|
9 | * License as published by the Free Software Foundation; either
|
---|
10 | * version 2.1 of the License, or (at your option) any later version.
|
---|
11 | *
|
---|
12 | * This library is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
15 | * Lesser General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU Lesser General Public
|
---|
18 | * License along with this library; if not, write to the Free Software
|
---|
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
20 | *
|
---|
21 | * TODO:
|
---|
22 | * - Tab order
|
---|
23 | * - Unicode property sheets
|
---|
24 | */
|
---|
25 |
|
---|
26 | #include <string.h>
|
---|
27 |
|
---|
28 | #include "winbase.h"
|
---|
29 | #include "commctrl.h"
|
---|
30 | #include "prsht.h"
|
---|
31 | #include "winnls.h"
|
---|
32 | #include "comctl32.h"
|
---|
33 | #include "heap.h"
|
---|
34 |
|
---|
35 | #include "wine/debug.h"
|
---|
36 | #include "wine/unicode.h"
|
---|
37 |
|
---|
38 | /******************************************************************************
|
---|
39 | * Data structures
|
---|
40 | */
|
---|
41 | #include "pshpack2.h"
|
---|
42 |
|
---|
43 | typedef struct
|
---|
44 | {
|
---|
45 | WORD dlgVer;
|
---|
46 | WORD signature;
|
---|
47 | DWORD helpID;
|
---|
48 | DWORD exStyle;
|
---|
49 | DWORD style;
|
---|
50 | } MyDLGTEMPLATEEX;
|
---|
51 |
|
---|
52 | typedef struct
|
---|
53 | {
|
---|
54 | DWORD helpid;
|
---|
55 | DWORD exStyle;
|
---|
56 | DWORD style;
|
---|
57 | short x;
|
---|
58 | short y;
|
---|
59 | short cy;
|
---|
60 | DWORD id;
|
---|
61 | } MyDLGITEMTEMPLATEEX;
|
---|
62 | #include "poppack.h"
|
---|
63 |
|
---|
64 | typedef struct tagPropPageInfo
|
---|
65 | {
|
---|
66 | HPROPSHEETPAGE hpage; /* to keep track of pages not passed to PropertySheet */
|
---|
67 | HWND hwndPage;
|
---|
68 | BOOL isDirty;
|
---|
69 | LPCWSTR pszText;
|
---|
70 | BOOL hasHelp;
|
---|
71 | BOOL useCallback;
|
---|
72 | BOOL hasIcon;
|
---|
73 | } PropPageInfo;
|
---|
74 |
|
---|
75 | typedef struct tagPropSheetInfo
|
---|
76 | {
|
---|
77 | HWND hwnd;
|
---|
78 | PROPSHEETHEADERW ppshheader;
|
---|
79 | LPWSTR strPropertiesFor;
|
---|
80 | int nPages;
|
---|
81 | int active_page;
|
---|
82 | BOOL isModeless;
|
---|
83 | BOOL hasHelp;
|
---|
84 | BOOL hasApply;
|
---|
85 | BOOL useCallback;
|
---|
86 | BOOL restartWindows;
|
---|
87 | BOOL rebootSystem;
|
---|
88 | BOOL activeValid;
|
---|
89 | PropPageInfo* proppage;
|
---|
90 | int x;
|
---|
91 | int y;
|
---|
92 | int width;
|
---|
93 | int height;
|
---|
94 | HIMAGELIST hImageList;
|
---|
95 | } PropSheetInfo;
|
---|
96 |
|
---|
97 | typedef struct
|
---|
98 | {
|
---|
99 | int x;
|
---|
100 | int y;
|
---|
101 | } PADDING_INFO;
|
---|
102 |
|
---|
103 | /******************************************************************************
|
---|
104 | * Defines and global variables
|
---|
105 | */
|
---|
106 |
|
---|
107 | const WCHAR PropSheetInfoStr[] =
|
---|
108 | {'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0 };
|
---|
109 |
|
---|
110 | #define MAX_CAPTION_LENGTH 255
|
---|
111 | #define MAX_TABTEXT_LENGTH 255
|
---|
112 | #define MAX_BUTTONTEXT_LENGTH 64
|
---|
113 |
|
---|
114 | #define PSH_WIZARD97_OLD 0x00002000
|
---|
115 | #define PSH_WIZARD97_NEW 0x01000000
|
---|
116 | #define INTRNL_ANY_WIZARD (PSH_WIZARD | PSH_WIZARD97_OLD | PSH_WIZARD97_NEW | PSH_WIZARD_LITE)
|
---|
117 |
|
---|
118 | /******************************************************************************
|
---|
119 | * Prototypes
|
---|
120 | */
|
---|
121 | static BOOL PROPSHEET_CreateDialog(PropSheetInfo* psInfo);
|
---|
122 | static BOOL PROPSHEET_SizeMismatch(HWND hwndDlg, PropSheetInfo* psInfo);
|
---|
123 | static BOOL PROPSHEET_AdjustSize(HWND hwndDlg, PropSheetInfo* psInfo);
|
---|
124 | static BOOL PROPSHEET_AdjustButtons(HWND hwndParent, PropSheetInfo* psInfo);
|
---|
125 | static BOOL PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh,
|
---|
126 | PropSheetInfo * psInfo);
|
---|
127 | static BOOL PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh,
|
---|
128 | PropSheetInfo * psInfo);
|
---|
129 | static BOOL PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp,
|
---|
130 | PropSheetInfo * psInfo,
|
---|
131 | int index);
|
---|
132 | static BOOL PROPSHEET_CreateTabControl(HWND hwndParent,
|
---|
133 | PropSheetInfo * psInfo);
|
---|
134 | static BOOL PROPSHEET_CreatePage(HWND hwndParent, int index,
|
---|
135 | const PropSheetInfo * psInfo,
|
---|
136 | LPCPROPSHEETPAGEW ppshpage);
|
---|
137 | static BOOL PROPSHEET_ShowPage(HWND hwndDlg, int index, PropSheetInfo * psInfo);
|
---|
138 | static PADDING_INFO PROPSHEET_GetPaddingInfo(HWND hwndDlg);
|
---|
139 | static BOOL PROPSHEET_Back(HWND hwndDlg);
|
---|
140 | static BOOL PROPSHEET_Next(HWND hwndDlg);
|
---|
141 | static BOOL PROPSHEET_Finish(HWND hwndDlg);
|
---|
142 | static BOOL PROPSHEET_Apply(HWND hwndDlg, LPARAM lParam);
|
---|
143 | static void PROPSHEET_Cancel(HWND hwndDlg, LPARAM lParam);
|
---|
144 | static void PROPSHEET_Help(HWND hwndDlg);
|
---|
145 | static void PROPSHEET_Changed(HWND hwndDlg, HWND hwndDirtyPage);
|
---|
146 | static void PROPSHEET_UnChanged(HWND hwndDlg, HWND hwndCleanPage);
|
---|
147 | static void PROPSHEET_PressButton(HWND hwndDlg, int buttonID);
|
---|
148 | static void PROPSHEET_SetFinishTextA(HWND hwndDlg, LPCSTR lpszText);
|
---|
149 | static void PROPSHEET_SetFinishTextW(HWND hwndDlg, LPCWSTR lpszText);
|
---|
150 | static void PROPSHEET_SetTitleA(HWND hwndDlg, DWORD dwStyle, LPCSTR lpszText);
|
---|
151 | static void PROPSHEET_SetTitleW(HWND hwndDlg, DWORD dwStyle, LPCWSTR lpszText);
|
---|
152 | static BOOL PROPSHEET_CanSetCurSel(HWND hwndDlg);
|
---|
153 | static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
|
---|
154 | int index,
|
---|
155 | int skipdir,
|
---|
156 | HPROPSHEETPAGE hpage);
|
---|
157 | static void PROPSHEET_SetCurSelId(HWND hwndDlg, int id);
|
---|
158 | static LRESULT PROPSHEET_QuerySiblings(HWND hwndDlg,
|
---|
159 | WPARAM wParam, LPARAM lParam);
|
---|
160 | static BOOL PROPSHEET_AddPage(HWND hwndDlg,
|
---|
161 | HPROPSHEETPAGE hpage);
|
---|
162 |
|
---|
163 | static BOOL PROPSHEET_RemovePage(HWND hwndDlg,
|
---|
164 | int index,
|
---|
165 | HPROPSHEETPAGE hpage);
|
---|
166 | static void PROPSHEET_CleanUp();
|
---|
167 | static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage, PropSheetInfo* psInfo);
|
---|
168 | static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags);
|
---|
169 | static PADDING_INFO PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg, const PropSheetInfo* psInfo);
|
---|
170 | static BOOL PROPSHEET_IsDialogMessage(HWND hwnd, LPMSG lpMsg);
|
---|
171 | static BOOL PROPSHEET_DoCommand(HWND hwnd, WORD wID);
|
---|
172 |
|
---|
173 | BOOL WINAPI
|
---|
174 | PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
---|
175 |
|
---|
176 | WINE_DEFAULT_DEBUG_CHANNEL(propsheet);
|
---|
177 |
|
---|
178 | #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");}
|
---|
179 | /******************************************************************************
|
---|
180 | * PROPSHEET_UnImplementedFlags
|
---|
181 | *
|
---|
182 | * Document use of flags we don't implement yet.
|
---|
183 | */
|
---|
184 | static VOID PROPSHEET_UnImplementedFlags(DWORD dwFlags)
|
---|
185 | {
|
---|
186 | CHAR string[256];
|
---|
187 |
|
---|
188 | string[0] = '\0';
|
---|
189 |
|
---|
190 | /*
|
---|
191 | * unhandled header flags:
|
---|
192 | * PSH_DEFAULT 0x00000000
|
---|
193 | * PSH_WIZARDHASFINISH 0x00000010
|
---|
194 | * PSH_RTLREADING 0x00000800
|
---|
195 | * PSH_WIZARDCONTEXTHELP 0x00001000
|
---|
196 | * PSH_WIZARD97 0x00002000 (pre IE 5)
|
---|
197 | * PSH_WATERMARK 0x00008000
|
---|
198 | * PSH_USEHBMWATERMARK 0x00010000
|
---|
199 | * PSH_USEHPLWATERMARK 0x00020000
|
---|
200 | * PSH_STRETCHWATERMARK 0x00040000
|
---|
201 | * PSH_HEADER 0x00080000
|
---|
202 | * PSH_USEHBMHEADER 0x00100000
|
---|
203 | * PSH_USEPAGELANG 0x00200000
|
---|
204 | * PSH_WIZARD_LITE 0x00400000 also not in .h
|
---|
205 | * PSH_WIZARD97 0x01000000 (IE 5 and above)
|
---|
206 | * PSH_NOCONTEXTHELP 0x02000000 also not in .h
|
---|
207 | */
|
---|
208 |
|
---|
209 | add_flag(PSH_WIZARDHASFINISH);
|
---|
210 | add_flag(PSH_RTLREADING);
|
---|
211 | add_flag(PSH_WIZARDCONTEXTHELP);
|
---|
212 | add_flag(PSH_WIZARD97_OLD);
|
---|
213 | add_flag(PSH_WATERMARK);
|
---|
214 | add_flag(PSH_USEHBMWATERMARK);
|
---|
215 | add_flag(PSH_USEHPLWATERMARK);
|
---|
216 | add_flag(PSH_STRETCHWATERMARK);
|
---|
217 | add_flag(PSH_HEADER);
|
---|
218 | add_flag(PSH_USEHBMHEADER);
|
---|
219 | add_flag(PSH_USEPAGELANG);
|
---|
220 | add_flag(PSH_WIZARD_LITE);
|
---|
221 | add_flag(PSH_WIZARD97_NEW);
|
---|
222 | add_flag(PSH_NOCONTEXTHELP);
|
---|
223 | if (string[0] != '\0')
|
---|
224 | FIXME("%s\n", string);
|
---|
225 | }
|
---|
226 | #undef add_flag
|
---|
227 |
|
---|
228 | /******************************************************************************
|
---|
229 | * PROPSHEET_GetPageRect
|
---|
230 | *
|
---|
231 | * Retrieve rect from tab control and map into the dialog for SetWindowPos
|
---|
232 | */
|
---|
233 | static void PROPSHEET_GetPageRect(const PropSheetInfo * psInfo, HWND hwndDlg, RECT *rc)
|
---|
234 | {
|
---|
235 | HWND hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
---|
236 |
|
---|
237 | GetClientRect(hwndTabCtrl, rc);
|
---|
238 | SendMessageW(hwndTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM)rc);
|
---|
239 | MapWindowPoints(hwndTabCtrl, hwndDlg, (LPPOINT)rc, 2);
|
---|
240 | }
|
---|
241 |
|
---|
242 | /******************************************************************************
|
---|
243 | * PROPSHEET_FindPageByResId
|
---|
244 | *
|
---|
245 | * Find page index corresponding to page resource id.
|
---|
246 | */
|
---|
247 | INT PROPSHEET_FindPageByResId(PropSheetInfo * psInfo, LRESULT resId)
|
---|
248 | {
|
---|
249 | INT i;
|
---|
250 |
|
---|
251 | for (i = 0; i < psInfo->nPages; i++)
|
---|
252 | {
|
---|
253 | LPCPROPSHEETPAGEA lppsp = (LPCPROPSHEETPAGEA)psInfo->proppage[i].hpage;
|
---|
254 |
|
---|
255 | /* Fixme: if resource ID is a string shall we use strcmp ??? */
|
---|
256 | if (lppsp->u.pszTemplate == (LPVOID)resId)
|
---|
257 | break;
|
---|
258 | }
|
---|
259 |
|
---|
260 | return i;
|
---|
261 | }
|
---|
262 |
|
---|
263 | /******************************************************************************
|
---|
264 | * PROPSHEET_AtoW
|
---|
265 | *
|
---|
266 | * Convert ASCII to Unicode since all data is saved as Unicode.
|
---|
267 | */
|
---|
268 | static void PROPSHEET_AtoW(LPCWSTR *tostr, LPCSTR frstr)
|
---|
269 | {
|
---|
270 | INT len;
|
---|
271 |
|
---|
272 | TRACE("<%s>\n", frstr);
|
---|
273 | len = MultiByteToWideChar(CP_ACP, 0, frstr, -1, 0, 0);
|
---|
274 | *tostr = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
---|
275 | MultiByteToWideChar(CP_ACP, 0, frstr, -1, (LPWSTR)*tostr, len);
|
---|
276 | }
|
---|
277 |
|
---|
278 | /******************************************************************************
|
---|
279 | * PROPSHEET_CollectSheetInfoA
|
---|
280 | *
|
---|
281 | * Collect relevant data.
|
---|
282 | */
|
---|
283 | static BOOL PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh,
|
---|
284 | PropSheetInfo * psInfo)
|
---|
285 | {
|
---|
286 | DWORD dwSize = min(lppsh->dwSize,sizeof(PROPSHEETHEADERA));
|
---|
287 | DWORD dwFlags = lppsh->dwFlags;
|
---|
288 |
|
---|
289 | psInfo->hasHelp = dwFlags & PSH_HASHELP;
|
---|
290 | psInfo->hasApply = !(dwFlags & PSH_NOAPPLYNOW);
|
---|
291 | psInfo->useCallback = dwFlags & PSH_USECALLBACK;
|
---|
292 | psInfo->isModeless = dwFlags & PSH_MODELESS;
|
---|
293 |
|
---|
294 | memcpy(&psInfo->ppshheader,lppsh,dwSize);
|
---|
295 | TRACE("\n** PROPSHEETHEADER **\ndwSize\t\t%ld\ndwFlags\t\t%08lx\nhwndParent\t%p\nhInstance\t%p\npszCaption\t'%s'\nnPages\t\t%d\npfnCallback\t%p\n",
|
---|
296 | lppsh->dwSize, lppsh->dwFlags, lppsh->hwndParent, lppsh->hInstance,
|
---|
297 | debugstr_a(lppsh->pszCaption), lppsh->nPages, lppsh->pfnCallback);
|
---|
298 |
|
---|
299 | PROPSHEET_UnImplementedFlags(lppsh->dwFlags);
|
---|
300 |
|
---|
301 | if (HIWORD(lppsh->pszCaption))
|
---|
302 | {
|
---|
303 | int len = strlen(lppsh->pszCaption);
|
---|
304 | psInfo->ppshheader.pszCaption = HeapAlloc( GetProcessHeap(), 0, (len+1)*sizeof (WCHAR) );
|
---|
305 | MultiByteToWideChar(CP_ACP, 0, lppsh->pszCaption, -1, (LPWSTR) psInfo->ppshheader.pszCaption, len+1);
|
---|
306 | /* strcpy( (char *)psInfo->ppshheader.pszCaption, lppsh->pszCaption ); */
|
---|
307 | }
|
---|
308 | psInfo->nPages = lppsh->nPages;
|
---|
309 |
|
---|
310 | if (dwFlags & PSH_USEPSTARTPAGE)
|
---|
311 | {
|
---|
312 | TRACE("PSH_USEPSTARTPAGE is on");
|
---|
313 | psInfo->active_page = 0;
|
---|
314 | }
|
---|
315 | else
|
---|
316 | psInfo->active_page = lppsh->u2.nStartPage;
|
---|
317 |
|
---|
318 | if (psInfo->active_page < 0 || psInfo->active_page >= psInfo->nPages)
|
---|
319 | psInfo->active_page = 0;
|
---|
320 |
|
---|
321 | psInfo->restartWindows = FALSE;
|
---|
322 | psInfo->rebootSystem = FALSE;
|
---|
323 | psInfo->hImageList = 0;
|
---|
324 | psInfo->activeValid = FALSE;
|
---|
325 |
|
---|
326 | return TRUE;
|
---|
327 | }
|
---|
328 |
|
---|
329 | /******************************************************************************
|
---|
330 | * PROPSHEET_CollectSheetInfoW
|
---|
331 | *
|
---|
332 | * Collect relevant data.
|
---|
333 | */
|
---|
334 | static BOOL PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh,
|
---|
335 | PropSheetInfo * psInfo)
|
---|
336 | {
|
---|
337 | DWORD dwSize = min(lppsh->dwSize,sizeof(PROPSHEETHEADERW));
|
---|
338 | DWORD dwFlags = lppsh->dwFlags;
|
---|
339 |
|
---|
340 | psInfo->hasHelp = dwFlags & PSH_HASHELP;
|
---|
341 | psInfo->hasApply = !(dwFlags & PSH_NOAPPLYNOW);
|
---|
342 | psInfo->useCallback = dwFlags & PSH_USECALLBACK;
|
---|
343 | psInfo->isModeless = dwFlags & PSH_MODELESS;
|
---|
344 |
|
---|
345 | memcpy(&psInfo->ppshheader,lppsh,dwSize);
|
---|
346 | TRACE("\n** PROPSHEETHEADER **\ndwSize\t\t%ld\ndwFlags\t\t%08lx\nhwndParent\t%p\nhInstance\t%p\npszCaption\t'%s'\nnPages\t\t%d\npfnCallback\t%p\n",
|
---|
347 | lppsh->dwSize, lppsh->dwFlags, lppsh->hwndParent, lppsh->hInstance, debugstr_w(lppsh->pszCaption), lppsh->nPages, lppsh->pfnCallback);
|
---|
348 |
|
---|
349 | PROPSHEET_UnImplementedFlags(lppsh->dwFlags);
|
---|
350 |
|
---|
351 | if (HIWORD(lppsh->pszCaption))
|
---|
352 | {
|
---|
353 | int len = strlenW(lppsh->pszCaption);
|
---|
354 | psInfo->ppshheader.pszCaption = HeapAlloc( GetProcessHeap(), 0, (len+1)*sizeof(WCHAR) );
|
---|
355 | strcpyW( (WCHAR *)psInfo->ppshheader.pszCaption, lppsh->pszCaption );
|
---|
356 | }
|
---|
357 | psInfo->nPages = lppsh->nPages;
|
---|
358 |
|
---|
359 | if (dwFlags & PSH_USEPSTARTPAGE)
|
---|
360 | {
|
---|
361 | TRACE("PSH_USEPSTARTPAGE is on");
|
---|
362 | psInfo->active_page = 0;
|
---|
363 | }
|
---|
364 | else
|
---|
365 | psInfo->active_page = lppsh->u2.nStartPage;
|
---|
366 |
|
---|
367 | if (psInfo->active_page < 0 || psInfo->active_page >= psInfo->nPages)
|
---|
368 | psInfo->active_page = 0;
|
---|
369 |
|
---|
370 | psInfo->restartWindows = FALSE;
|
---|
371 | psInfo->rebootSystem = FALSE;
|
---|
372 | psInfo->hImageList = 0;
|
---|
373 | psInfo->activeValid = FALSE;
|
---|
374 |
|
---|
375 | return TRUE;
|
---|
376 | }
|
---|
377 |
|
---|
378 | /******************************************************************************
|
---|
379 | * PROPSHEET_CollectPageInfo
|
---|
380 | *
|
---|
381 | * Collect property sheet data.
|
---|
382 | * With code taken from DIALOG_ParseTemplate32.
|
---|
383 | */
|
---|
384 | BOOL PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp,
|
---|
385 | PropSheetInfo * psInfo,
|
---|
386 | int index)
|
---|
387 | {
|
---|
388 | DLGTEMPLATE* pTemplate;
|
---|
389 | const WORD* p;
|
---|
390 | DWORD dwFlags;
|
---|
391 | int width, height;
|
---|
392 |
|
---|
393 | TRACE("\n");
|
---|
394 | psInfo->proppage[index].hpage = (HPROPSHEETPAGE)lppsp;
|
---|
395 | psInfo->proppage[index].hwndPage = 0;
|
---|
396 | psInfo->proppage[index].isDirty = FALSE;
|
---|
397 |
|
---|
398 | /*
|
---|
399 | * Process property page flags.
|
---|
400 | */
|
---|
401 | dwFlags = lppsp->dwFlags;
|
---|
402 | psInfo->proppage[index].useCallback = (dwFlags & PSP_USECALLBACK) && (lppsp->pfnCallback);
|
---|
403 | psInfo->proppage[index].hasHelp = dwFlags & PSP_HASHELP;
|
---|
404 | psInfo->proppage[index].hasIcon = dwFlags & (PSP_USEHICON | PSP_USEICONID);
|
---|
405 |
|
---|
406 | /* as soon as we have a page with the help flag, set the sheet flag on */
|
---|
407 | if (psInfo->proppage[index].hasHelp)
|
---|
408 | psInfo->hasHelp = TRUE;
|
---|
409 |
|
---|
410 | /*
|
---|
411 | * Process page template.
|
---|
412 | */
|
---|
413 | if (dwFlags & PSP_DLGINDIRECT)
|
---|
414 | pTemplate = (DLGTEMPLATE*)lppsp->u.pResource;
|
---|
415 | else
|
---|
416 | {
|
---|
417 | HRSRC hResource = FindResourceW(lppsp->hInstance,
|
---|
418 | lppsp->u.pszTemplate,
|
---|
419 | RT_DIALOGW);
|
---|
420 | HGLOBAL hTemplate = LoadResource(lppsp->hInstance,
|
---|
421 | hResource);
|
---|
422 | pTemplate = (LPDLGTEMPLATEW)LockResource(hTemplate);
|
---|
423 | }
|
---|
424 |
|
---|
425 | /*
|
---|
426 | * Extract the size of the page and the caption.
|
---|
427 | */
|
---|
428 | if (!pTemplate)
|
---|
429 | return FALSE;
|
---|
430 |
|
---|
431 | p = (const WORD *)pTemplate;
|
---|
432 |
|
---|
433 | if (((MyDLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF)
|
---|
434 | {
|
---|
435 | /* DIALOGEX template */
|
---|
436 |
|
---|
437 | p++; /* dlgVer */
|
---|
438 | p++; /* signature */
|
---|
439 | p += 2; /* help ID */
|
---|
440 | p += 2; /* ext style */
|
---|
441 | p += 2; /* style */
|
---|
442 | }
|
---|
443 | else
|
---|
444 | {
|
---|
445 | /* DIALOG template */
|
---|
446 |
|
---|
447 | p += 2; /* style */
|
---|
448 | p += 2; /* ext style */
|
---|
449 | }
|
---|
450 |
|
---|
451 | p++; /* nb items */
|
---|
452 | p++; /* x */
|
---|
453 | p++; /* y */
|
---|
454 | width = (WORD)*p; p++;
|
---|
455 | height = (WORD)*p; p++;
|
---|
456 |
|
---|
457 | /* remember the largest width and height */
|
---|
458 | if (width > psInfo->width)
|
---|
459 | psInfo->width = width;
|
---|
460 |
|
---|
461 | if (height > psInfo->height)
|
---|
462 | psInfo->height = height;
|
---|
463 |
|
---|
464 | /* menu */
|
---|
465 | switch ((WORD)*p)
|
---|
466 | {
|
---|
467 | case 0x0000:
|
---|
468 | p++;
|
---|
469 | break;
|
---|
470 | case 0xffff:
|
---|
471 | p += 2;
|
---|
472 | break;
|
---|
473 | default:
|
---|
474 | p += lstrlenW( (LPCWSTR)p ) + 1;
|
---|
475 | break;
|
---|
476 | }
|
---|
477 |
|
---|
478 | /* class */
|
---|
479 | switch ((WORD)*p)
|
---|
480 | {
|
---|
481 | case 0x0000:
|
---|
482 | p++;
|
---|
483 | break;
|
---|
484 | case 0xffff:
|
---|
485 | p += 2;
|
---|
486 | break;
|
---|
487 | default:
|
---|
488 | p += lstrlenW( (LPCWSTR)p ) + 1;
|
---|
489 | break;
|
---|
490 | }
|
---|
491 |
|
---|
492 | /* Extract the caption */
|
---|
493 | psInfo->proppage[index].pszText = (LPCWSTR)p;
|
---|
494 | TRACE("Tab %d %s\n",index,debugstr_w((LPCWSTR)p));
|
---|
495 | p += lstrlenW((LPCWSTR)p) + 1;
|
---|
496 |
|
---|
497 | if (dwFlags & PSP_USETITLE)
|
---|
498 | {
|
---|
499 | WCHAR szTitle[256];
|
---|
500 | const WCHAR *pTitle;
|
---|
501 | static WCHAR pszNull[] = { '(','n','u','l','l',')',0 };
|
---|
502 | int len;
|
---|
503 |
|
---|
504 | if ( !HIWORD( lppsp->pszTitle ) )
|
---|
505 | {
|
---|
506 | if (!LoadStringW( lppsp->hInstance, (UINT)lppsp->pszTitle,szTitle,sizeof szTitle ))
|
---|
507 | {
|
---|
508 | pTitle = pszNull;
|
---|
509 | FIXME("Could not load resource #%04x?\n",LOWORD(lppsp->pszTitle));
|
---|
510 | }
|
---|
511 | else
|
---|
512 | pTitle = szTitle;
|
---|
513 | }
|
---|
514 | else
|
---|
515 | pTitle = lppsp->pszTitle;
|
---|
516 |
|
---|
517 | len = strlenW(pTitle);
|
---|
518 | psInfo->proppage[index].pszText = COMCTL32_Alloc( (len+1)*sizeof (WCHAR) );
|
---|
519 | strcpyW( (LPWSTR)psInfo->proppage[index].pszText,pTitle);
|
---|
520 | }
|
---|
521 |
|
---|
522 | /*
|
---|
523 | * Build the image list for icons
|
---|
524 | */
|
---|
525 | if ((dwFlags & PSP_USEHICON) || (dwFlags & PSP_USEICONID))
|
---|
526 | {
|
---|
527 | HICON hIcon;
|
---|
528 | int icon_cx = GetSystemMetrics(SM_CXSMICON);
|
---|
529 | int icon_cy = GetSystemMetrics(SM_CYSMICON);
|
---|
530 |
|
---|
531 | if (dwFlags & PSP_USEICONID)
|
---|
532 | hIcon = LoadImageW(lppsp->hInstance, lppsp->u2.pszIcon, IMAGE_ICON,
|
---|
533 | icon_cx, icon_cy, LR_DEFAULTCOLOR);
|
---|
534 | else
|
---|
535 | hIcon = lppsp->u2.hIcon;
|
---|
536 |
|
---|
537 | if ( hIcon )
|
---|
538 | {
|
---|
539 | if (psInfo->hImageList == 0 )
|
---|
540 | psInfo->hImageList = ImageList_Create(icon_cx, icon_cy, ILC_COLOR, 1, 1);
|
---|
541 |
|
---|
542 | ImageList_AddIcon(psInfo->hImageList, hIcon);
|
---|
543 | }
|
---|
544 |
|
---|
545 | }
|
---|
546 |
|
---|
547 | return TRUE;
|
---|
548 | }
|
---|
549 |
|
---|
550 | /******************************************************************************
|
---|
551 | * PROPSHEET_CreateDialog
|
---|
552 | *
|
---|
553 | * Creates the actual property sheet.
|
---|
554 | */
|
---|
555 | BOOL PROPSHEET_CreateDialog(PropSheetInfo* psInfo)
|
---|
556 | {
|
---|
557 | LRESULT ret;
|
---|
558 | LPCVOID template;
|
---|
559 | LPVOID temp = 0;
|
---|
560 | HRSRC hRes;
|
---|
561 | DWORD resSize;
|
---|
562 | WORD resID = IDD_PROPSHEET;
|
---|
563 |
|
---|
564 | TRACE("\n");
|
---|
565 | if (psInfo->ppshheader.dwFlags & INTRNL_ANY_WIZARD)
|
---|
566 | resID = IDD_WIZARD;
|
---|
567 |
|
---|
568 | if(!(hRes = FindResourceW(COMCTL32_hModule,
|
---|
569 | MAKEINTRESOURCEW(resID),
|
---|
570 | RT_DIALOGW)))
|
---|
571 | return FALSE;
|
---|
572 |
|
---|
573 | if(!(template = (LPVOID)LoadResource(COMCTL32_hModule, hRes)))
|
---|
574 | return FALSE;
|
---|
575 |
|
---|
576 | /*
|
---|
577 | * Make a copy of the dialog template.
|
---|
578 | */
|
---|
579 | resSize = SizeofResource(COMCTL32_hModule, hRes);
|
---|
580 |
|
---|
581 | temp = COMCTL32_Alloc(resSize);
|
---|
582 |
|
---|
583 | if (!temp)
|
---|
584 | return FALSE;
|
---|
585 |
|
---|
586 | memcpy(temp, template, resSize);
|
---|
587 |
|
---|
588 | if (psInfo->useCallback)
|
---|
589 | (*(psInfo->ppshheader.pfnCallback))(0, PSCB_PRECREATE, (LPARAM)temp);
|
---|
590 |
|
---|
591 | if (!(psInfo->ppshheader.dwFlags & PSH_MODELESS))
|
---|
592 | ret = DialogBoxIndirectParamW(psInfo->ppshheader.hInstance,
|
---|
593 | (LPDLGTEMPLATEW) temp,
|
---|
594 | psInfo->ppshheader.hwndParent,
|
---|
595 | (DLGPROC) PROPSHEET_DialogProc,
|
---|
596 | (LPARAM)psInfo);
|
---|
597 | else
|
---|
598 | ret = CreateDialogIndirectParamW(psInfo->ppshheader.hInstance,
|
---|
599 | (LPDLGTEMPLATEW) temp,
|
---|
600 | psInfo->ppshheader.hwndParent,
|
---|
601 | (DLGPROC) PROPSHEET_DialogProc,
|
---|
602 | (LPARAM)psInfo) ? TRUE : FALSE;
|
---|
603 |
|
---|
604 | COMCTL32_Free(temp);
|
---|
605 |
|
---|
606 | return ret;
|
---|
607 | }
|
---|
608 |
|
---|
609 | /******************************************************************************
|
---|
610 | * PROPSHEET_SizeMismatch
|
---|
611 | *
|
---|
612 | * Verify that the tab control and the "largest" property sheet page dlg. template
|
---|
613 | * match in size.
|
---|
614 | */
|
---|
615 | static BOOL PROPSHEET_SizeMismatch(HWND hwndDlg, PropSheetInfo* psInfo)
|
---|
616 | {
|
---|
617 | HWND hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
---|
618 | RECT rcOrigTab, rcPage;
|
---|
619 |
|
---|
620 | /*
|
---|
621 | * Original tab size.
|
---|
622 | */
|
---|
623 | GetClientRect(hwndTabCtrl, &rcOrigTab);
|
---|
624 | TRACE("orig tab %d %d %d %d\n", rcOrigTab.left, rcOrigTab.top,
|
---|
625 | rcOrigTab.right, rcOrigTab.bottom);
|
---|
626 |
|
---|
627 | /*
|
---|
628 | * Biggest page size.
|
---|
629 | */
|
---|
630 | rcPage.left = psInfo->x;
|
---|
631 | rcPage.top = psInfo->y;
|
---|
632 | rcPage.right = psInfo->width;
|
---|
633 | rcPage.bottom = psInfo->height;
|
---|
634 |
|
---|
635 | MapDialogRect(hwndDlg, &rcPage);
|
---|
636 | TRACE("biggest page %d %d %d %d\n", rcPage.left, rcPage.top,
|
---|
637 | rcPage.right, rcPage.bottom);
|
---|
638 |
|
---|
639 | if ( (rcPage.right - rcPage.left) != (rcOrigTab.right - rcOrigTab.left) )
|
---|
640 | return TRUE;
|
---|
641 | if ( (rcPage.bottom - rcPage.top) != (rcOrigTab.bottom - rcOrigTab.top) )
|
---|
642 | return TRUE;
|
---|
643 |
|
---|
644 | return FALSE;
|
---|
645 | }
|
---|
646 |
|
---|
647 | /******************************************************************************
|
---|
648 | * PROPSHEET_IsTooSmallWizard
|
---|
649 | *
|
---|
650 | * Verify that the default property sheet is big enough.
|
---|
651 | */
|
---|
652 | static BOOL PROPSHEET_IsTooSmallWizard(HWND hwndDlg, PropSheetInfo* psInfo)
|
---|
653 | {
|
---|
654 | RECT rcSheetRect, rcPage, rcLine, rcSheetClient;
|
---|
655 | HWND hwndLine = GetDlgItem(hwndDlg, IDC_SUNKEN_LINE);
|
---|
656 | PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndDlg, psInfo);
|
---|
657 |
|
---|
658 | GetClientRect(hwndDlg, &rcSheetClient);
|
---|
659 | GetWindowRect(hwndDlg, &rcSheetRect);
|
---|
660 | GetWindowRect(hwndLine, &rcLine);
|
---|
661 |
|
---|
662 | /* Remove the space below the sunken line */
|
---|
663 | rcSheetClient.bottom -= (rcSheetRect.bottom - rcLine.top);
|
---|
664 |
|
---|
665 | /* Remove the buffer zone all around the edge */
|
---|
666 | rcSheetClient.bottom -= (padding.y * 2);
|
---|
667 | rcSheetClient.right -= (padding.x * 2);
|
---|
668 |
|
---|
669 | /*
|
---|
670 | * Biggest page size.
|
---|
671 | */
|
---|
672 | rcPage.left = psInfo->x;
|
---|
673 | rcPage.top = psInfo->y;
|
---|
674 | rcPage.right = psInfo->width;
|
---|
675 | rcPage.bottom = psInfo->height;
|
---|
676 |
|
---|
677 | MapDialogRect(hwndDlg, &rcPage);
|
---|
678 | TRACE("biggest page %d %d %d %d\n", rcPage.left, rcPage.top,
|
---|
679 | rcPage.right, rcPage.bottom);
|
---|
680 |
|
---|
681 | if (rcPage.right > rcSheetClient.right)
|
---|
682 | return TRUE;
|
---|
683 |
|
---|
684 | if (rcPage.bottom > rcSheetClient.bottom)
|
---|
685 | return TRUE;
|
---|
686 |
|
---|
687 | return FALSE;
|
---|
688 | }
|
---|
689 |
|
---|
690 | /******************************************************************************
|
---|
691 | * PROPSHEET_AdjustSize
|
---|
692 | *
|
---|
693 | * Resizes the property sheet and the tab control to fit the largest page.
|
---|
694 | */
|
---|
695 | static BOOL PROPSHEET_AdjustSize(HWND hwndDlg, PropSheetInfo* psInfo)
|
---|
696 | {
|
---|
697 | HWND hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
---|
698 | HWND hwndButton = GetDlgItem(hwndDlg, IDOK);
|
---|
699 | RECT rc,tabRect;
|
---|
700 | int tabOffsetX, tabOffsetY, buttonHeight;
|
---|
701 | PADDING_INFO padding = PROPSHEET_GetPaddingInfo(hwndDlg);
|
---|
702 | RECT units;
|
---|
703 |
|
---|
704 | /* Get the height of buttons */
|
---|
705 | GetClientRect(hwndButton, &rc);
|
---|
706 | buttonHeight = rc.bottom;
|
---|
707 |
|
---|
708 | /*
|
---|
709 | * Biggest page size.
|
---|
710 | */
|
---|
711 | rc.left = psInfo->x;
|
---|
712 | rc.top = psInfo->y;
|
---|
713 | rc.right = psInfo->width;
|
---|
714 | rc.bottom = psInfo->height;
|
---|
715 |
|
---|
716 | MapDialogRect(hwndDlg, &rc);
|
---|
717 |
|
---|
718 | /* retrieve the dialog units */
|
---|
719 | units.left = units.right = 4;
|
---|
720 | units.top = units.bottom = 8;
|
---|
721 | MapDialogRect(hwndDlg, &units);
|
---|
722 |
|
---|
723 | /*
|
---|
724 | * Resize the tab control.
|
---|
725 | */
|
---|
726 | GetClientRect(hwndTabCtrl,&tabRect);
|
---|
727 |
|
---|
728 | SendMessageW(hwndTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM)&tabRect);
|
---|
729 |
|
---|
730 | if ((rc.bottom - rc.top) < (tabRect.bottom - tabRect.top))
|
---|
731 | {
|
---|
732 | rc.bottom = rc.top + tabRect.bottom - tabRect.top;
|
---|
733 | psInfo->height = MulDiv((rc.bottom - rc.top),8,units.top);
|
---|
734 | }
|
---|
735 |
|
---|
736 | if ((rc.right - rc.left) < (tabRect.right - tabRect.left))
|
---|
737 | {
|
---|
738 | rc.right = rc.left + tabRect.right - tabRect.left;
|
---|
739 | psInfo->width = MulDiv((rc.right - rc.left),4,units.left);
|
---|
740 | }
|
---|
741 |
|
---|
742 | SendMessageW(hwndTabCtrl, TCM_ADJUSTRECT, TRUE, (LPARAM)&rc);
|
---|
743 |
|
---|
744 | tabOffsetX = -(rc.left);
|
---|
745 | tabOffsetY = -(rc.top);
|
---|
746 |
|
---|
747 | rc.right -= rc.left;
|
---|
748 | rc.bottom -= rc.top;
|
---|
749 | TRACE("setting tab %08lx, rc (0,0)-(%d,%d)\n",
|
---|
750 | (DWORD)hwndTabCtrl, rc.right, rc.bottom);
|
---|
751 | SetWindowPos(hwndTabCtrl, 0, 0, 0, rc.right, rc.bottom,
|
---|
752 | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
753 |
|
---|
754 | GetClientRect(hwndTabCtrl, &rc);
|
---|
755 |
|
---|
756 | TRACE("tab client rc %d %d %d %d\n",
|
---|
757 | rc.left, rc.top, rc.right, rc.bottom);
|
---|
758 |
|
---|
759 | rc.right += ((padding.x * 2) + tabOffsetX);
|
---|
760 | rc.bottom += (buttonHeight + (3 * padding.y) + tabOffsetY);
|
---|
761 |
|
---|
762 | /*
|
---|
763 | * Resize the property sheet.
|
---|
764 | */
|
---|
765 | TRACE("setting dialog %08lx, rc (0,0)-(%d,%d)\n",
|
---|
766 | (DWORD)hwndDlg, rc.right, rc.bottom);
|
---|
767 | SetWindowPos(hwndDlg, 0, 0, 0, rc.right, rc.bottom,
|
---|
768 | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
769 | return TRUE;
|
---|
770 | }
|
---|
771 |
|
---|
772 | /******************************************************************************
|
---|
773 | * PROPSHEET_AdjustSizeWizard
|
---|
774 | *
|
---|
775 | * Resizes the property sheet to fit the largest page.
|
---|
776 | */
|
---|
777 | static BOOL PROPSHEET_AdjustSizeWizard(HWND hwndDlg, PropSheetInfo* psInfo)
|
---|
778 | {
|
---|
779 | HWND hwndButton = GetDlgItem(hwndDlg, IDCANCEL);
|
---|
780 | HWND hwndLine = GetDlgItem(hwndDlg, IDC_SUNKEN_LINE);
|
---|
781 | HWND hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
---|
782 | RECT rc,tabRect;
|
---|
783 | int buttonHeight, lineHeight;
|
---|
784 | PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndDlg, psInfo);
|
---|
785 | RECT units;
|
---|
786 |
|
---|
787 | /* Get the height of buttons */
|
---|
788 | GetClientRect(hwndButton, &rc);
|
---|
789 | buttonHeight = rc.bottom;
|
---|
790 |
|
---|
791 | GetClientRect(hwndLine, &rc);
|
---|
792 | lineHeight = rc.bottom;
|
---|
793 |
|
---|
794 | /* retrieve the dialog units */
|
---|
795 | units.left = units.right = 4;
|
---|
796 | units.top = units.bottom = 8;
|
---|
797 | MapDialogRect(hwndDlg, &units);
|
---|
798 |
|
---|
799 | /*
|
---|
800 | * Biggest page size.
|
---|
801 | */
|
---|
802 | rc.left = psInfo->x;
|
---|
803 | rc.top = psInfo->y;
|
---|
804 | rc.right = psInfo->width;
|
---|
805 | rc.bottom = psInfo->height;
|
---|
806 |
|
---|
807 | MapDialogRect(hwndDlg, &rc);
|
---|
808 |
|
---|
809 | GetClientRect(hwndTabCtrl,&tabRect);
|
---|
810 |
|
---|
811 | if ((rc.bottom - rc.top) < (tabRect.bottom - tabRect.top))
|
---|
812 | {
|
---|
813 | rc.bottom = rc.top + tabRect.bottom - tabRect.top;
|
---|
814 | psInfo->height = MulDiv((rc.bottom - rc.top), 8, units.top);
|
---|
815 | }
|
---|
816 |
|
---|
817 | if ((rc.right - rc.left) < (tabRect.right - tabRect.left))
|
---|
818 | {
|
---|
819 | rc.right = rc.left + tabRect.right - tabRect.left;
|
---|
820 | psInfo->width = MulDiv((rc.right - rc.left), 4, units.left);
|
---|
821 | }
|
---|
822 |
|
---|
823 | TRACE("Biggest page %d %d %d %d\n", rc.left, rc.top, rc.right, rc.bottom);
|
---|
824 | TRACE(" constants padx=%d, pady=%d, butH=%d, lH=%d\n",
|
---|
825 | padding.x, padding.y, buttonHeight, lineHeight);
|
---|
826 |
|
---|
827 | /* Make room */
|
---|
828 | rc.right += (padding.x * 2);
|
---|
829 | rc.bottom += (buttonHeight + (5 * padding.y) + lineHeight);
|
---|
830 |
|
---|
831 | /*
|
---|
832 | * Resize the property sheet.
|
---|
833 | */
|
---|
834 | TRACE("setting dialog %08lx, rc (0,0)-(%d,%d)\n",
|
---|
835 | (DWORD)hwndDlg, rc.right, rc.bottom);
|
---|
836 | SetWindowPos(hwndDlg, 0, 0, 0, rc.right, rc.bottom,
|
---|
837 | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
838 | return TRUE;
|
---|
839 | }
|
---|
840 |
|
---|
841 | /******************************************************************************
|
---|
842 | * PROPSHEET_AdjustButtons
|
---|
843 | *
|
---|
844 | * Adjusts the buttons' positions.
|
---|
845 | */
|
---|
846 | static BOOL PROPSHEET_AdjustButtons(HWND hwndParent, PropSheetInfo* psInfo)
|
---|
847 | {
|
---|
848 | HWND hwndButton = GetDlgItem(hwndParent, IDOK);
|
---|
849 | RECT rcSheet;
|
---|
850 | int x, y;
|
---|
851 | int num_buttons = 2;
|
---|
852 | int buttonWidth, buttonHeight;
|
---|
853 | PADDING_INFO padding = PROPSHEET_GetPaddingInfo(hwndParent);
|
---|
854 |
|
---|
855 | if (psInfo->hasApply)
|
---|
856 | num_buttons++;
|
---|
857 |
|
---|
858 | if (psInfo->hasHelp)
|
---|
859 | num_buttons++;
|
---|
860 |
|
---|
861 | /*
|
---|
862 | * Obtain the size of the buttons.
|
---|
863 | */
|
---|
864 | GetClientRect(hwndButton, &rcSheet);
|
---|
865 | buttonWidth = rcSheet.right;
|
---|
866 | buttonHeight = rcSheet.bottom;
|
---|
867 |
|
---|
868 | /*
|
---|
869 | * Get the size of the property sheet.
|
---|
870 | */
|
---|
871 | GetClientRect(hwndParent, &rcSheet);
|
---|
872 |
|
---|
873 | /*
|
---|
874 | * All buttons will be at this y coordinate.
|
---|
875 | */
|
---|
876 | y = rcSheet.bottom - (padding.y + buttonHeight);
|
---|
877 |
|
---|
878 | /*
|
---|
879 | * Position OK button.
|
---|
880 | */
|
---|
881 | hwndButton = GetDlgItem(hwndParent, IDOK);
|
---|
882 |
|
---|
883 | x = rcSheet.right - ((padding.x + buttonWidth) * num_buttons);
|
---|
884 |
|
---|
885 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
---|
886 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
887 |
|
---|
888 | /*
|
---|
889 | * Position Cancel button.
|
---|
890 | */
|
---|
891 | hwndButton = GetDlgItem(hwndParent, IDCANCEL);
|
---|
892 |
|
---|
893 | x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 1));
|
---|
894 |
|
---|
895 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
---|
896 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
897 |
|
---|
898 | /*
|
---|
899 | * Position Apply button.
|
---|
900 | */
|
---|
901 | hwndButton = GetDlgItem(hwndParent, IDC_APPLY_BUTTON);
|
---|
902 |
|
---|
903 | if (psInfo->hasApply)
|
---|
904 | {
|
---|
905 | if (psInfo->hasHelp)
|
---|
906 | x = rcSheet.right - ((padding.x + buttonWidth) * 2);
|
---|
907 | else
|
---|
908 | x = rcSheet.right - (padding.x + buttonWidth);
|
---|
909 |
|
---|
910 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
---|
911 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
912 |
|
---|
913 | EnableWindow(hwndButton, FALSE);
|
---|
914 | }
|
---|
915 | else
|
---|
916 | ShowWindow(hwndButton, SW_HIDE);
|
---|
917 |
|
---|
918 | /*
|
---|
919 | * Position Help button.
|
---|
920 | */
|
---|
921 | hwndButton = GetDlgItem(hwndParent, IDHELP);
|
---|
922 |
|
---|
923 | if (psInfo->hasHelp)
|
---|
924 | {
|
---|
925 | x = rcSheet.right - (padding.x + buttonWidth);
|
---|
926 |
|
---|
927 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
---|
928 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
929 | }
|
---|
930 | else
|
---|
931 | ShowWindow(hwndButton, SW_HIDE);
|
---|
932 |
|
---|
933 | return TRUE;
|
---|
934 | }
|
---|
935 |
|
---|
936 | /******************************************************************************
|
---|
937 | * PROPSHEET_AdjustButtonsWizard
|
---|
938 | *
|
---|
939 | * Adjusts the buttons' positions.
|
---|
940 | */
|
---|
941 | static BOOL PROPSHEET_AdjustButtonsWizard(HWND hwndParent,
|
---|
942 | PropSheetInfo* psInfo)
|
---|
943 | {
|
---|
944 | HWND hwndButton = GetDlgItem(hwndParent, IDCANCEL);
|
---|
945 | HWND hwndLine = GetDlgItem(hwndParent, IDC_SUNKEN_LINE);
|
---|
946 | RECT rcSheet;
|
---|
947 | int x, y;
|
---|
948 | int num_buttons = 3;
|
---|
949 | int buttonWidth, buttonHeight, lineHeight, lineWidth;
|
---|
950 | PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndParent, psInfo);
|
---|
951 |
|
---|
952 | if (psInfo->hasHelp)
|
---|
953 | num_buttons++;
|
---|
954 |
|
---|
955 | /*
|
---|
956 | * Obtain the size of the buttons.
|
---|
957 | */
|
---|
958 | GetClientRect(hwndButton, &rcSheet);
|
---|
959 | buttonWidth = rcSheet.right;
|
---|
960 | buttonHeight = rcSheet.bottom;
|
---|
961 |
|
---|
962 | GetClientRect(hwndLine, &rcSheet);
|
---|
963 | lineHeight = rcSheet.bottom;
|
---|
964 |
|
---|
965 | /*
|
---|
966 | * Get the size of the property sheet.
|
---|
967 | */
|
---|
968 | GetClientRect(hwndParent, &rcSheet);
|
---|
969 |
|
---|
970 | /*
|
---|
971 | * All buttons will be at this y coordinate.
|
---|
972 | */
|
---|
973 | y = rcSheet.bottom - (padding.y + buttonHeight);
|
---|
974 |
|
---|
975 | /*
|
---|
976 | * Position the Next and the Finish buttons.
|
---|
977 | */
|
---|
978 | hwndButton = GetDlgItem(hwndParent, IDC_NEXT_BUTTON);
|
---|
979 |
|
---|
980 | x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 1));
|
---|
981 |
|
---|
982 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
---|
983 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
984 |
|
---|
985 | hwndButton = GetDlgItem(hwndParent, IDC_FINISH_BUTTON);
|
---|
986 |
|
---|
987 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
---|
988 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
989 |
|
---|
990 | ShowWindow(hwndButton, SW_HIDE);
|
---|
991 |
|
---|
992 | /*
|
---|
993 | * Position the Back button.
|
---|
994 | */
|
---|
995 | hwndButton = GetDlgItem(hwndParent, IDC_BACK_BUTTON);
|
---|
996 |
|
---|
997 | x -= buttonWidth;
|
---|
998 |
|
---|
999 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
---|
1000 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
1001 |
|
---|
1002 | /*
|
---|
1003 | * Position the Cancel button.
|
---|
1004 | */
|
---|
1005 | hwndButton = GetDlgItem(hwndParent, IDCANCEL);
|
---|
1006 |
|
---|
1007 | x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 2));
|
---|
1008 |
|
---|
1009 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
---|
1010 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
1011 |
|
---|
1012 | /*
|
---|
1013 | * Position Help button.
|
---|
1014 | */
|
---|
1015 | hwndButton = GetDlgItem(hwndParent, IDHELP);
|
---|
1016 |
|
---|
1017 | if (psInfo->hasHelp)
|
---|
1018 | {
|
---|
1019 | x = rcSheet.right - (padding.x + buttonWidth);
|
---|
1020 |
|
---|
1021 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
---|
1022 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
1023 | }
|
---|
1024 | else
|
---|
1025 | ShowWindow(hwndButton, SW_HIDE);
|
---|
1026 |
|
---|
1027 | /*
|
---|
1028 | * Position and resize the sunken line.
|
---|
1029 | */
|
---|
1030 | x = padding.x;
|
---|
1031 | y = rcSheet.bottom - ((padding.y * 2) + buttonHeight + lineHeight);
|
---|
1032 |
|
---|
1033 | GetClientRect(hwndParent, &rcSheet);
|
---|
1034 | lineWidth = rcSheet.right - (padding.x * 2);
|
---|
1035 |
|
---|
1036 | SetWindowPos(hwndLine, 0, x, y, lineWidth, 2,
|
---|
1037 | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
1038 |
|
---|
1039 | return TRUE;
|
---|
1040 | }
|
---|
1041 |
|
---|
1042 | /******************************************************************************
|
---|
1043 | * PROPSHEET_GetPaddingInfo
|
---|
1044 | *
|
---|
1045 | * Returns the layout information.
|
---|
1046 | */
|
---|
1047 | static PADDING_INFO PROPSHEET_GetPaddingInfo(HWND hwndDlg)
|
---|
1048 | {
|
---|
1049 | HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
---|
1050 | RECT rcTab;
|
---|
1051 | POINT tl;
|
---|
1052 | PADDING_INFO padding;
|
---|
1053 |
|
---|
1054 | GetWindowRect(hwndTab, &rcTab);
|
---|
1055 |
|
---|
1056 | tl.x = rcTab.left;
|
---|
1057 | tl.y = rcTab.top;
|
---|
1058 |
|
---|
1059 | ScreenToClient(hwndDlg, &tl);
|
---|
1060 |
|
---|
1061 | padding.x = tl.x;
|
---|
1062 | padding.y = tl.y;
|
---|
1063 |
|
---|
1064 | return padding;
|
---|
1065 | }
|
---|
1066 |
|
---|
1067 | /******************************************************************************
|
---|
1068 | * PROPSHEET_GetPaddingInfoWizard
|
---|
1069 | *
|
---|
1070 | * Returns the layout information.
|
---|
1071 | * Vertical spacing is the distance between the line and the buttons.
|
---|
1072 | * Do NOT use the Help button to gather padding information when it isn't mapped
|
---|
1073 | * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
|
---|
1074 | * for it in this case !
|
---|
1075 | * FIXME: I'm not sure about any other coordinate problems with these evil
|
---|
1076 | * buttons. Fix it in case additional problems appear or maybe calculate
|
---|
1077 | * a padding in a completely different way, as this is somewhat messy.
|
---|
1078 | */
|
---|
1079 | static PADDING_INFO PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg, const PropSheetInfo*
|
---|
1080 | psInfo)
|
---|
1081 | {
|
---|
1082 | PADDING_INFO padding;
|
---|
1083 | RECT rc;
|
---|
1084 | HWND hwndControl;
|
---|
1085 | INT idButton;
|
---|
1086 | POINT ptButton, ptLine;
|
---|
1087 |
|
---|
1088 | TRACE("\n");
|
---|
1089 | if (psInfo->hasHelp)
|
---|
1090 | {
|
---|
1091 | idButton = IDHELP;
|
---|
1092 | }
|
---|
1093 | else
|
---|
1094 | {
|
---|
1095 | if (psInfo->ppshheader.dwFlags & INTRNL_ANY_WIZARD)
|
---|
1096 | {
|
---|
1097 | idButton = IDC_NEXT_BUTTON;
|
---|
1098 | }
|
---|
1099 | else
|
---|
1100 | {
|
---|
1101 | /* hopefully this is ok */
|
---|
1102 | idButton = IDCANCEL;
|
---|
1103 | }
|
---|
1104 | }
|
---|
1105 |
|
---|
1106 | hwndControl = GetDlgItem(hwndDlg, idButton);
|
---|
1107 | GetWindowRect(hwndControl, &rc);
|
---|
1108 |
|
---|
1109 | ptButton.x = rc.left;
|
---|
1110 | ptButton.y = rc.top;
|
---|
1111 |
|
---|
1112 | ScreenToClient(hwndDlg, &ptButton);
|
---|
1113 |
|
---|
1114 | /* Line */
|
---|
1115 | hwndControl = GetDlgItem(hwndDlg, IDC_SUNKEN_LINE);
|
---|
1116 | GetWindowRect(hwndControl, &rc);
|
---|
1117 |
|
---|
1118 | ptLine.x = 0;
|
---|
1119 | ptLine.y = rc.bottom;
|
---|
1120 |
|
---|
1121 | ScreenToClient(hwndDlg, &ptLine);
|
---|
1122 |
|
---|
1123 | padding.y = ptButton.y - ptLine.y;
|
---|
1124 |
|
---|
1125 | if (padding.y < 0)
|
---|
1126 | ERR("padding negative ! Please report this !\n");
|
---|
1127 |
|
---|
1128 | /* this is most probably not correct, but the best we have now */
|
---|
1129 | padding.x = padding.y;
|
---|
1130 | return padding;
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 | /******************************************************************************
|
---|
1134 | * PROPSHEET_CreateTabControl
|
---|
1135 | *
|
---|
1136 | * Insert the tabs in the tab control.
|
---|
1137 | */
|
---|
1138 | static BOOL PROPSHEET_CreateTabControl(HWND hwndParent,
|
---|
1139 | PropSheetInfo * psInfo)
|
---|
1140 | {
|
---|
1141 | HWND hwndTabCtrl = GetDlgItem(hwndParent, IDC_TABCONTROL);
|
---|
1142 | TCITEMW item;
|
---|
1143 | int i, nTabs;
|
---|
1144 | int iImage = 0;
|
---|
1145 |
|
---|
1146 | TRACE("\n");
|
---|
1147 | item.mask = TCIF_TEXT;
|
---|
1148 | item.cchTextMax = MAX_TABTEXT_LENGTH;
|
---|
1149 |
|
---|
1150 | nTabs = psInfo->nPages;
|
---|
1151 |
|
---|
1152 | /*
|
---|
1153 | * Set the image list for icons.
|
---|
1154 | */
|
---|
1155 | if (psInfo->hImageList)
|
---|
1156 | {
|
---|
1157 | SendMessageW(hwndTabCtrl, TCM_SETIMAGELIST, 0, (LPARAM)psInfo->hImageList);
|
---|
1158 | }
|
---|
1159 |
|
---|
1160 | for (i = 0; i < nTabs; i++)
|
---|
1161 | {
|
---|
1162 | if ( psInfo->proppage[i].hasIcon )
|
---|
1163 | {
|
---|
1164 | item.mask |= TCIF_IMAGE;
|
---|
1165 | item.iImage = iImage++;
|
---|
1166 | }
|
---|
1167 | else
|
---|
1168 | {
|
---|
1169 | item.mask &= ~TCIF_IMAGE;
|
---|
1170 | }
|
---|
1171 |
|
---|
1172 | item.pszText = (LPWSTR) psInfo->proppage[i].pszText;
|
---|
1173 | SendMessageW(hwndTabCtrl, TCM_INSERTITEMW, (WPARAM)i, (LPARAM)&item);
|
---|
1174 | }
|
---|
1175 |
|
---|
1176 | return TRUE;
|
---|
1177 | }
|
---|
1178 | /*
|
---|
1179 | * Get the size of an in-memory Template
|
---|
1180 | *
|
---|
1181 | *( Based on the code of PROPSHEET_CollectPageInfo)
|
---|
1182 | */
|
---|
1183 |
|
---|
1184 | static UINT GetTemplateSize(DLGTEMPLATE* pTemplate)
|
---|
1185 |
|
---|
1186 | {
|
---|
1187 | const WORD* p = (const WORD *)pTemplate;
|
---|
1188 | BOOL istemplateex = (((MyDLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF);
|
---|
1189 | WORD nrofitems;
|
---|
1190 |
|
---|
1191 | if (istemplateex)
|
---|
1192 | {
|
---|
1193 | /* DIALOGEX template */
|
---|
1194 |
|
---|
1195 | p++; /* dlgVer */
|
---|
1196 | p++; /* signature */
|
---|
1197 | p += 2; /* help ID */
|
---|
1198 | p += 2; /* ext style */
|
---|
1199 | p += 2; /* style */
|
---|
1200 | }
|
---|
1201 | else
|
---|
1202 | {
|
---|
1203 | /* DIALOG template */
|
---|
1204 |
|
---|
1205 | p += 2; /* style */
|
---|
1206 | p += 2; /* ext style */
|
---|
1207 | }
|
---|
1208 |
|
---|
1209 | nrofitems = (WORD)*p; p++; /* nb items */
|
---|
1210 | p++; /* x */
|
---|
1211 | p++; /* y */
|
---|
1212 | p++; /* width */
|
---|
1213 | p++; /* height */
|
---|
1214 |
|
---|
1215 | /* menu */
|
---|
1216 | switch ((WORD)*p)
|
---|
1217 | {
|
---|
1218 | case 0x0000:
|
---|
1219 | p++;
|
---|
1220 | break;
|
---|
1221 | case 0xffff:
|
---|
1222 | p += 2;
|
---|
1223 | break;
|
---|
1224 | default:
|
---|
1225 | TRACE("menu %s\n",debugstr_w((LPCWSTR)p));
|
---|
1226 | p += lstrlenW( (LPCWSTR)p ) + 1;
|
---|
1227 | break;
|
---|
1228 | }
|
---|
1229 |
|
---|
1230 | /* class */
|
---|
1231 | switch ((WORD)*p)
|
---|
1232 | {
|
---|
1233 | case 0x0000:
|
---|
1234 | p++;
|
---|
1235 | break;
|
---|
1236 | case 0xffff:
|
---|
1237 | p += 2;
|
---|
1238 | break;
|
---|
1239 | default:
|
---|
1240 | TRACE("class %s\n",debugstr_w((LPCWSTR)p));
|
---|
1241 | p += lstrlenW( (LPCWSTR)p ) + 1;
|
---|
1242 | break;
|
---|
1243 | }
|
---|
1244 |
|
---|
1245 | /*title */
|
---|
1246 | TRACE("title %s\n",debugstr_w((LPCWSTR)p));
|
---|
1247 | p += lstrlenW((LPCWSTR)p) + 1;
|
---|
1248 |
|
---|
1249 | /* font, if DS_FONT set */
|
---|
1250 | if ((DS_SETFONT & ((istemplateex)? ((MyDLGTEMPLATEEX*)pTemplate)->style :
|
---|
1251 | pTemplate->style)))
|
---|
1252 | {
|
---|
1253 | p+=(istemplateex)?3:1;
|
---|
1254 | TRACE("font %s\n",debugstr_w((LPCWSTR)p));
|
---|
1255 | p += lstrlenW( (LPCWSTR)p ) + 1; /* the font name*/
|
---|
1256 | }
|
---|
1257 |
|
---|
1258 | TRACE("%d items\n",nrofitems);
|
---|
1259 | while (nrofitems > 0)
|
---|
1260 | {
|
---|
1261 | p = (WORD*)(((DWORD)p + 3) & ~3); /* DWORD align */
|
---|
1262 |
|
---|
1263 | p += (istemplateex ? sizeof(MyDLGITEMTEMPLATEEX) : sizeof(DLGITEMTEMPLATE))/sizeof(WORD);
|
---|
1264 |
|
---|
1265 | switch ((WORD)*p)
|
---|
1266 | {
|
---|
1267 | case 0x0000:
|
---|
1268 | p++;
|
---|
1269 | break;
|
---|
1270 | case 0xffff:
|
---|
1271 | TRACE("class ordinal 0x%08lx\n",*(DWORD*)p);
|
---|
1272 | p += 2;
|
---|
1273 | break;
|
---|
1274 | default:
|
---|
1275 | TRACE("class %s\n",debugstr_w((LPCWSTR)p));
|
---|
1276 | p += lstrlenW( (LPCWSTR)p ) + 1;
|
---|
1277 | break;
|
---|
1278 | }
|
---|
1279 | switch ((WORD)*p)
|
---|
1280 | {
|
---|
1281 | case 0x0000:
|
---|
1282 | p++;
|
---|
1283 | break;
|
---|
1284 | case 0xffff:
|
---|
1285 | TRACE("text ordinal 0x%08lx\n",*(DWORD*)p);
|
---|
1286 | p += 2;
|
---|
1287 | break;
|
---|
1288 | default:
|
---|
1289 | TRACE("text %s\n",debugstr_w((LPCWSTR)p));
|
---|
1290 | p += lstrlenW( (LPCWSTR)p ) + 1;
|
---|
1291 | break;
|
---|
1292 | }
|
---|
1293 | p += *p + 1; /* Skip extra data */
|
---|
1294 | --nrofitems;
|
---|
1295 | }
|
---|
1296 |
|
---|
1297 | TRACE("%p %p size 0x%08x\n",p, (WORD*)pTemplate,sizeof(WORD)*(p - (WORD*)pTemplate));
|
---|
1298 | return (p - (WORD*)pTemplate)*sizeof(WORD);
|
---|
1299 |
|
---|
1300 | }
|
---|
1301 |
|
---|
1302 | /******************************************************************************
|
---|
1303 | * PROPSHEET_CreatePage
|
---|
1304 | *
|
---|
1305 | * Creates a page.
|
---|
1306 | */
|
---|
1307 | static BOOL PROPSHEET_CreatePage(HWND hwndParent,
|
---|
1308 | int index,
|
---|
1309 | const PropSheetInfo * psInfo,
|
---|
1310 | LPCPROPSHEETPAGEW ppshpage)
|
---|
1311 | {
|
---|
1312 | DLGTEMPLATE* pTemplate;
|
---|
1313 | HWND hwndPage;
|
---|
1314 | RECT rc;
|
---|
1315 | PropPageInfo* ppInfo = psInfo->proppage;
|
---|
1316 | PADDING_INFO padding;
|
---|
1317 | UINT pageWidth,pageHeight;
|
---|
1318 | DWORD resSize;
|
---|
1319 | LPVOID temp = NULL;
|
---|
1320 |
|
---|
1321 | TRACE("index %d\n", index);
|
---|
1322 |
|
---|
1323 | if (ppshpage == NULL)
|
---|
1324 | {
|
---|
1325 | return FALSE;
|
---|
1326 | }
|
---|
1327 |
|
---|
1328 | if (ppshpage->dwFlags & PSP_DLGINDIRECT)
|
---|
1329 | {
|
---|
1330 | pTemplate = (DLGTEMPLATE*)ppshpage->u.pResource;
|
---|
1331 | resSize = GetTemplateSize(pTemplate);
|
---|
1332 | }
|
---|
1333 | else
|
---|
1334 | {
|
---|
1335 | HRSRC hResource;
|
---|
1336 | HANDLE hTemplate;
|
---|
1337 |
|
---|
1338 | hResource = FindResourceW(ppshpage->hInstance,
|
---|
1339 | ppshpage->u.pszTemplate,
|
---|
1340 | RT_DIALOGW);
|
---|
1341 | if(!hResource)
|
---|
1342 | return FALSE;
|
---|
1343 |
|
---|
1344 | resSize = SizeofResource(ppshpage->hInstance, hResource);
|
---|
1345 |
|
---|
1346 | hTemplate = LoadResource(ppshpage->hInstance, hResource);
|
---|
1347 | if(!hTemplate)
|
---|
1348 | return FALSE;
|
---|
1349 |
|
---|
1350 | pTemplate = (LPDLGTEMPLATEW)LockResource(hTemplate);
|
---|
1351 | /*
|
---|
1352 | * Make a copy of the dialog template to make it writable
|
---|
1353 | */
|
---|
1354 | }
|
---|
1355 | temp = COMCTL32_Alloc(resSize);
|
---|
1356 | if (!temp)
|
---|
1357 | return FALSE;
|
---|
1358 |
|
---|
1359 | memcpy(temp, pTemplate, resSize);
|
---|
1360 | pTemplate = temp;
|
---|
1361 |
|
---|
1362 | if (((MyDLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF)
|
---|
1363 | {
|
---|
1364 | ((MyDLGTEMPLATEEX*)pTemplate)->style |= WS_CHILD | DS_CONTROL;
|
---|
1365 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~DS_MODALFRAME;
|
---|
1366 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_CAPTION;
|
---|
1367 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_SYSMENU;
|
---|
1368 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_POPUP;
|
---|
1369 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_DISABLED;
|
---|
1370 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_VISIBLE;
|
---|
1371 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_THICKFRAME;
|
---|
1372 | }
|
---|
1373 | else
|
---|
1374 | {
|
---|
1375 | pTemplate->style |= WS_CHILD | DS_CONTROL;
|
---|
1376 | pTemplate->style &= ~DS_MODALFRAME;
|
---|
1377 | pTemplate->style &= ~WS_CAPTION;
|
---|
1378 | pTemplate->style &= ~WS_SYSMENU;
|
---|
1379 | pTemplate->style &= ~WS_POPUP;
|
---|
1380 | pTemplate->style &= ~WS_DISABLED;
|
---|
1381 | pTemplate->style &= ~WS_VISIBLE;
|
---|
1382 | pTemplate->style &= ~WS_THICKFRAME;
|
---|
1383 | }
|
---|
1384 |
|
---|
1385 | if (psInfo->proppage[index].useCallback)
|
---|
1386 | (*(ppshpage->pfnCallback))(hwndParent,
|
---|
1387 | PSPCB_CREATE,
|
---|
1388 | (LPPROPSHEETPAGEW)ppshpage);
|
---|
1389 |
|
---|
1390 | hwndPage = CreateDialogIndirectParamW(ppshpage->hInstance,
|
---|
1391 | pTemplate,
|
---|
1392 | hwndParent,
|
---|
1393 | ppshpage->pfnDlgProc,
|
---|
1394 | (LPARAM)ppshpage);
|
---|
1395 | /* Free a no more needed copy */
|
---|
1396 | if(temp)
|
---|
1397 | COMCTL32_Free(temp);
|
---|
1398 |
|
---|
1399 | ppInfo[index].hwndPage = hwndPage;
|
---|
1400 |
|
---|
1401 | if (psInfo->ppshheader.dwFlags & INTRNL_ANY_WIZARD) {
|
---|
1402 | /* FIXME: This code may no longer be correct.
|
---|
1403 | * It was not for the non-wizard path. (GLA 6/02)
|
---|
1404 | */
|
---|
1405 | rc.left = psInfo->x;
|
---|
1406 | rc.top = psInfo->y;
|
---|
1407 | rc.right = psInfo->width;
|
---|
1408 | rc.bottom = psInfo->height;
|
---|
1409 |
|
---|
1410 | MapDialogRect(hwndParent, &rc);
|
---|
1411 |
|
---|
1412 | pageWidth = rc.right - rc.left;
|
---|
1413 | pageHeight = rc.bottom - rc.top;
|
---|
1414 |
|
---|
1415 | padding = PROPSHEET_GetPaddingInfoWizard(hwndParent, psInfo);
|
---|
1416 | TRACE("setting page %08lx, rc (%d,%d)-(%d,%d) w=%d, h=%d, padx=%d, pady=%d\n",
|
---|
1417 | (DWORD)hwndPage, rc.left, rc.top, rc.right, rc.bottom,
|
---|
1418 | pageWidth, pageHeight, padding.x, padding.y);
|
---|
1419 | SetWindowPos(hwndPage, HWND_TOP,
|
---|
1420 | rc.left + padding.x/2,
|
---|
1421 | rc.top + padding.y/2,
|
---|
1422 | pageWidth, pageHeight, 0);
|
---|
1423 | }
|
---|
1424 | else {
|
---|
1425 | /*
|
---|
1426 | * Ask the Tab control to reduce the client rectangle to that
|
---|
1427 | * it has available.
|
---|
1428 | */
|
---|
1429 | PROPSHEET_GetPageRect(psInfo, hwndParent, &rc);
|
---|
1430 | pageWidth = rc.right - rc.left;
|
---|
1431 | pageHeight = rc.bottom - rc.top;
|
---|
1432 | TRACE("setting page %08lx, rc (%d,%d)-(%d,%d) w=%d, h=%d\n",
|
---|
1433 | (DWORD)hwndPage, rc.left, rc.top, rc.right, rc.bottom,
|
---|
1434 | pageWidth, pageHeight);
|
---|
1435 | SetWindowPos(hwndPage, HWND_TOP,
|
---|
1436 | rc.left, rc.top,
|
---|
1437 | pageWidth, pageHeight, 0);
|
---|
1438 | }
|
---|
1439 |
|
---|
1440 | return TRUE;
|
---|
1441 | }
|
---|
1442 |
|
---|
1443 | /******************************************************************************
|
---|
1444 | * PROPSHEET_ShowPage
|
---|
1445 | *
|
---|
1446 | * Displays or creates the specified page.
|
---|
1447 | */
|
---|
1448 | static BOOL PROPSHEET_ShowPage(HWND hwndDlg, int index, PropSheetInfo * psInfo)
|
---|
1449 | {
|
---|
1450 | HWND hwndTabCtrl;
|
---|
1451 |
|
---|
1452 | TRACE("active_page %d, index %d\n", psInfo->active_page, index);
|
---|
1453 | if (index == psInfo->active_page)
|
---|
1454 | {
|
---|
1455 | if (GetTopWindow(hwndDlg) != psInfo->proppage[index].hwndPage)
|
---|
1456 | SetWindowPos(psInfo->proppage[index].hwndPage, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
---|
1457 | return TRUE;
|
---|
1458 | }
|
---|
1459 |
|
---|
1460 | if (psInfo->proppage[index].hwndPage == 0)
|
---|
1461 | {
|
---|
1462 | LPCPROPSHEETPAGEW ppshpage;
|
---|
1463 |
|
---|
1464 | ppshpage = (LPCPROPSHEETPAGEW)psInfo->proppage[index].hpage;
|
---|
1465 | PROPSHEET_CreatePage(hwndDlg, index, psInfo, ppshpage);
|
---|
1466 | }
|
---|
1467 |
|
---|
1468 | if (psInfo->active_page != -1)
|
---|
1469 | ShowWindow(psInfo->proppage[psInfo->active_page].hwndPage, SW_HIDE);
|
---|
1470 |
|
---|
1471 | ShowWindow(psInfo->proppage[index].hwndPage, SW_SHOW);
|
---|
1472 |
|
---|
1473 | /* Synchronize current selection with tab control
|
---|
1474 | * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
|
---|
1475 | hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
---|
1476 | SendMessageW(hwndTabCtrl, TCM_SETCURSEL, index, 0);
|
---|
1477 |
|
---|
1478 | psInfo->active_page = index;
|
---|
1479 | psInfo->activeValid = TRUE;
|
---|
1480 |
|
---|
1481 | return TRUE;
|
---|
1482 | }
|
---|
1483 |
|
---|
1484 | /******************************************************************************
|
---|
1485 | * PROPSHEET_Back
|
---|
1486 | */
|
---|
1487 | static BOOL PROPSHEET_Back(HWND hwndDlg)
|
---|
1488 | {
|
---|
1489 | PSHNOTIFY psn;
|
---|
1490 | HWND hwndPage;
|
---|
1491 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg,
|
---|
1492 | PropSheetInfoStr);
|
---|
1493 | LRESULT result;
|
---|
1494 | int idx;
|
---|
1495 |
|
---|
1496 | TRACE("active_page %d\n", psInfo->active_page);
|
---|
1497 | if (psInfo->active_page < 0)
|
---|
1498 | return FALSE;
|
---|
1499 |
|
---|
1500 | psn.hdr.code = PSN_WIZBACK;
|
---|
1501 | psn.hdr.hwndFrom = hwndDlg;
|
---|
1502 | psn.hdr.idFrom = 0;
|
---|
1503 | psn.lParam = 0;
|
---|
1504 |
|
---|
1505 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
---|
1506 |
|
---|
1507 | result = SendMessageW(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
---|
1508 | if (result == -1)
|
---|
1509 | return FALSE;
|
---|
1510 | else if (result == 0)
|
---|
1511 | idx = psInfo->active_page - 1;
|
---|
1512 | else
|
---|
1513 | idx = PROPSHEET_FindPageByResId(psInfo, result);
|
---|
1514 |
|
---|
1515 | if (idx >= 0 && idx < psInfo->nPages)
|
---|
1516 | {
|
---|
1517 | if (PROPSHEET_CanSetCurSel(hwndDlg))
|
---|
1518 | PROPSHEET_SetCurSel(hwndDlg, idx, -1, 0);
|
---|
1519 | }
|
---|
1520 | return TRUE;
|
---|
1521 | }
|
---|
1522 |
|
---|
1523 | /******************************************************************************
|
---|
1524 | * PROPSHEET_Next
|
---|
1525 | */
|
---|
1526 | static BOOL PROPSHEET_Next(HWND hwndDlg)
|
---|
1527 | {
|
---|
1528 | PSHNOTIFY psn;
|
---|
1529 | HWND hwndPage;
|
---|
1530 | LRESULT msgResult = 0;
|
---|
1531 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg,
|
---|
1532 | PropSheetInfoStr);
|
---|
1533 | int idx;
|
---|
1534 |
|
---|
1535 | TRACE("active_page %d\n", psInfo->active_page);
|
---|
1536 | if (psInfo->active_page < 0)
|
---|
1537 | return FALSE;
|
---|
1538 |
|
---|
1539 | psn.hdr.code = PSN_WIZNEXT;
|
---|
1540 | psn.hdr.hwndFrom = hwndDlg;
|
---|
1541 | psn.hdr.idFrom = 0;
|
---|
1542 | psn.lParam = 0;
|
---|
1543 |
|
---|
1544 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
---|
1545 |
|
---|
1546 | msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
---|
1547 | if (msgResult == -1)
|
---|
1548 | return FALSE;
|
---|
1549 | else if (msgResult == 0)
|
---|
1550 | idx = psInfo->active_page + 1;
|
---|
1551 | else
|
---|
1552 | idx = PROPSHEET_FindPageByResId(psInfo, msgResult);
|
---|
1553 |
|
---|
1554 | if (idx < psInfo->nPages )
|
---|
1555 | {
|
---|
1556 | if (PROPSHEET_CanSetCurSel(hwndDlg) != FALSE)
|
---|
1557 | PROPSHEET_SetCurSel(hwndDlg, idx, 1, 0);
|
---|
1558 | }
|
---|
1559 |
|
---|
1560 | return TRUE;
|
---|
1561 | }
|
---|
1562 |
|
---|
1563 | /******************************************************************************
|
---|
1564 | * PROPSHEET_Finish
|
---|
1565 | */
|
---|
1566 | static BOOL PROPSHEET_Finish(HWND hwndDlg)
|
---|
1567 | {
|
---|
1568 | PSHNOTIFY psn;
|
---|
1569 | HWND hwndPage;
|
---|
1570 | LRESULT msgResult = 0;
|
---|
1571 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg,
|
---|
1572 | PropSheetInfoStr);
|
---|
1573 |
|
---|
1574 | TRACE("active_page %d\n", psInfo->active_page);
|
---|
1575 | if (psInfo->active_page < 0)
|
---|
1576 | return FALSE;
|
---|
1577 |
|
---|
1578 | psn.hdr.code = PSN_WIZFINISH;
|
---|
1579 | psn.hdr.hwndFrom = hwndDlg;
|
---|
1580 | psn.hdr.idFrom = 0;
|
---|
1581 | psn.lParam = 0;
|
---|
1582 |
|
---|
1583 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
---|
1584 |
|
---|
1585 | msgResult = SendMessageW(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
---|
1586 |
|
---|
1587 | TRACE("msg result %ld\n", msgResult);
|
---|
1588 |
|
---|
1589 | if (msgResult != 0)
|
---|
1590 | return FALSE;
|
---|
1591 |
|
---|
1592 | if (psInfo->isModeless)
|
---|
1593 | psInfo->activeValid = FALSE;
|
---|
1594 | else
|
---|
1595 | EndDialog(hwndDlg, TRUE);
|
---|
1596 |
|
---|
1597 | return TRUE;
|
---|
1598 | }
|
---|
1599 |
|
---|
1600 | /******************************************************************************
|
---|
1601 | * PROPSHEET_Apply
|
---|
1602 | */
|
---|
1603 | static BOOL PROPSHEET_Apply(HWND hwndDlg, LPARAM lParam)
|
---|
1604 | {
|
---|
1605 | int i;
|
---|
1606 | HWND hwndPage;
|
---|
1607 | PSHNOTIFY psn;
|
---|
1608 | LRESULT msgResult;
|
---|
1609 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg,
|
---|
1610 | PropSheetInfoStr);
|
---|
1611 |
|
---|
1612 | TRACE("active_page %d\n", psInfo->active_page);
|
---|
1613 | if (psInfo->active_page < 0)
|
---|
1614 | return FALSE;
|
---|
1615 |
|
---|
1616 | psn.hdr.hwndFrom = hwndDlg;
|
---|
1617 | psn.hdr.idFrom = 0;
|
---|
1618 | psn.lParam = 0;
|
---|
1619 |
|
---|
1620 |
|
---|
1621 | /*
|
---|
1622 | * Send PSN_KILLACTIVE to the current page.
|
---|
1623 | */
|
---|
1624 | psn.hdr.code = PSN_KILLACTIVE;
|
---|
1625 |
|
---|
1626 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
---|
1627 |
|
---|
1628 | if (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn) != FALSE)
|
---|
1629 | return FALSE;
|
---|
1630 |
|
---|
1631 | /*
|
---|
1632 | * Send PSN_APPLY to all pages.
|
---|
1633 | */
|
---|
1634 | psn.hdr.code = PSN_APPLY;
|
---|
1635 | psn.lParam = lParam;
|
---|
1636 |
|
---|
1637 | for (i = 0; i < psInfo->nPages; i++)
|
---|
1638 | {
|
---|
1639 | hwndPage = psInfo->proppage[i].hwndPage;
|
---|
1640 | if (hwndPage)
|
---|
1641 | {
|
---|
1642 | msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
---|
1643 | if (msgResult == PSNRET_INVALID_NOCHANGEPAGE)
|
---|
1644 | return FALSE;
|
---|
1645 | }
|
---|
1646 | }
|
---|
1647 |
|
---|
1648 | if(lParam)
|
---|
1649 | {
|
---|
1650 | psInfo->activeValid = FALSE;
|
---|
1651 | }
|
---|
1652 | else if(psInfo->active_page >= 0)
|
---|
1653 | {
|
---|
1654 | psn.hdr.code = PSN_SETACTIVE;
|
---|
1655 | psn.lParam = 0;
|
---|
1656 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
---|
1657 | SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
---|
1658 | }
|
---|
1659 |
|
---|
1660 | return TRUE;
|
---|
1661 | }
|
---|
1662 |
|
---|
1663 | /******************************************************************************
|
---|
1664 | * PROPSHEET_Cancel
|
---|
1665 | */
|
---|
1666 | static void PROPSHEET_Cancel(HWND hwndDlg, LPARAM lParam)
|
---|
1667 | {
|
---|
1668 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg,
|
---|
1669 | PropSheetInfoStr);
|
---|
1670 | HWND hwndPage;
|
---|
1671 | PSHNOTIFY psn;
|
---|
1672 | int i;
|
---|
1673 |
|
---|
1674 | TRACE("active_page %d\n", psInfo->active_page);
|
---|
1675 | if (psInfo->active_page < 0)
|
---|
1676 | return;
|
---|
1677 |
|
---|
1678 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
---|
1679 | psn.hdr.code = PSN_QUERYCANCEL;
|
---|
1680 | psn.hdr.hwndFrom = hwndDlg;
|
---|
1681 | psn.hdr.idFrom = 0;
|
---|
1682 | psn.lParam = 0;
|
---|
1683 |
|
---|
1684 | if (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn))
|
---|
1685 | return;
|
---|
1686 |
|
---|
1687 | psn.hdr.code = PSN_RESET;
|
---|
1688 | psn.lParam = lParam;
|
---|
1689 |
|
---|
1690 | for (i = 0; i < psInfo->nPages; i++)
|
---|
1691 | {
|
---|
1692 | hwndPage = psInfo->proppage[i].hwndPage;
|
---|
1693 |
|
---|
1694 | if (hwndPage)
|
---|
1695 | SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
---|
1696 | }
|
---|
1697 |
|
---|
1698 | if (psInfo->isModeless)
|
---|
1699 | {
|
---|
1700 | /* makes PSM_GETCURRENTPAGEHWND return NULL */
|
---|
1701 | psInfo->activeValid = FALSE;
|
---|
1702 | }
|
---|
1703 | else
|
---|
1704 | EndDialog(hwndDlg, FALSE);
|
---|
1705 | }
|
---|
1706 |
|
---|
1707 | /******************************************************************************
|
---|
1708 | * PROPSHEET_Help
|
---|
1709 | */
|
---|
1710 | static void PROPSHEET_Help(HWND hwndDlg)
|
---|
1711 | {
|
---|
1712 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg,
|
---|
1713 | PropSheetInfoStr);
|
---|
1714 | HWND hwndPage;
|
---|
1715 | PSHNOTIFY psn;
|
---|
1716 |
|
---|
1717 | TRACE("active_page %d\n", psInfo->active_page);
|
---|
1718 | if (psInfo->active_page < 0)
|
---|
1719 | return;
|
---|
1720 |
|
---|
1721 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
---|
1722 | psn.hdr.code = PSN_HELP;
|
---|
1723 | psn.hdr.hwndFrom = hwndDlg;
|
---|
1724 | psn.hdr.idFrom = 0;
|
---|
1725 | psn.lParam = 0;
|
---|
1726 |
|
---|
1727 | SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
---|
1728 | }
|
---|
1729 |
|
---|
1730 | /******************************************************************************
|
---|
1731 | * PROPSHEET_Changed
|
---|
1732 | */
|
---|
1733 | static void PROPSHEET_Changed(HWND hwndDlg, HWND hwndDirtyPage)
|
---|
1734 | {
|
---|
1735 | int i;
|
---|
1736 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg,
|
---|
1737 | PropSheetInfoStr);
|
---|
1738 |
|
---|
1739 | TRACE("\n");
|
---|
1740 | if (!psInfo) return;
|
---|
1741 | /*
|
---|
1742 | * Set the dirty flag of this page.
|
---|
1743 | */
|
---|
1744 | for (i = 0; i < psInfo->nPages; i++)
|
---|
1745 | {
|
---|
1746 | if (psInfo->proppage[i].hwndPage == hwndDirtyPage)
|
---|
1747 | psInfo->proppage[i].isDirty = TRUE;
|
---|
1748 | }
|
---|
1749 |
|
---|
1750 | /*
|
---|
1751 | * Enable the Apply button.
|
---|
1752 | */
|
---|
1753 | if (psInfo->hasApply)
|
---|
1754 | {
|
---|
1755 | HWND hwndApplyBtn = GetDlgItem(hwndDlg, IDC_APPLY_BUTTON);
|
---|
1756 |
|
---|
1757 | EnableWindow(hwndApplyBtn, TRUE);
|
---|
1758 | }
|
---|
1759 | }
|
---|
1760 |
|
---|
1761 | /******************************************************************************
|
---|
1762 | * PROPSHEET_UnChanged
|
---|
1763 | */
|
---|
1764 | static void PROPSHEET_UnChanged(HWND hwndDlg, HWND hwndCleanPage)
|
---|
1765 | {
|
---|
1766 | int i;
|
---|
1767 | BOOL noPageDirty = TRUE;
|
---|
1768 | HWND hwndApplyBtn = GetDlgItem(hwndDlg, IDC_APPLY_BUTTON);
|
---|
1769 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg,
|
---|
1770 | PropSheetInfoStr);
|
---|
1771 |
|
---|
1772 | TRACE("\n");
|
---|
1773 | if ( !psInfo ) return;
|
---|
1774 | for (i = 0; i < psInfo->nPages; i++)
|
---|
1775 | {
|
---|
1776 | /* set the specified page as clean */
|
---|
1777 | if (psInfo->proppage[i].hwndPage == hwndCleanPage)
|
---|
1778 | psInfo->proppage[i].isDirty = FALSE;
|
---|
1779 |
|
---|
1780 | /* look to see if there's any dirty pages */
|
---|
1781 | if (psInfo->proppage[i].isDirty)
|
---|
1782 | noPageDirty = FALSE;
|
---|
1783 | }
|
---|
1784 |
|
---|
1785 | /*
|
---|
1786 | * Disable Apply button.
|
---|
1787 | */
|
---|
1788 | if (noPageDirty)
|
---|
1789 | EnableWindow(hwndApplyBtn, FALSE);
|
---|
1790 | }
|
---|
1791 |
|
---|
1792 | /******************************************************************************
|
---|
1793 | * PROPSHEET_PressButton
|
---|
1794 | */
|
---|
1795 | static void PROPSHEET_PressButton(HWND hwndDlg, int buttonID)
|
---|
1796 | {
|
---|
1797 | TRACE("buttonID %d\n", buttonID);
|
---|
1798 | switch (buttonID)
|
---|
1799 | {
|
---|
1800 | case PSBTN_APPLYNOW:
|
---|
1801 | PROPSHEET_DoCommand(hwndDlg, IDC_APPLY_BUTTON);
|
---|
1802 | break;
|
---|
1803 | case PSBTN_BACK:
|
---|
1804 | PROPSHEET_Back(hwndDlg);
|
---|
1805 | break;
|
---|
1806 | case PSBTN_CANCEL:
|
---|
1807 | PROPSHEET_DoCommand(hwndDlg, IDCANCEL);
|
---|
1808 | break;
|
---|
1809 | case PSBTN_FINISH:
|
---|
1810 | PROPSHEET_Finish(hwndDlg);
|
---|
1811 | break;
|
---|
1812 | case PSBTN_HELP:
|
---|
1813 | PROPSHEET_DoCommand(hwndDlg, IDHELP);
|
---|
1814 | break;
|
---|
1815 | case PSBTN_NEXT:
|
---|
1816 | PROPSHEET_Next(hwndDlg);
|
---|
1817 | break;
|
---|
1818 | case PSBTN_OK:
|
---|
1819 | PROPSHEET_DoCommand(hwndDlg, IDOK);
|
---|
1820 | break;
|
---|
1821 | default:
|
---|
1822 | FIXME("Invalid button index %d\n", buttonID);
|
---|
1823 | }
|
---|
1824 | }
|
---|
1825 |
|
---|
1826 |
|
---|
1827 | /*************************************************************************
|
---|
1828 | * BOOL PROPSHEET_CanSetCurSel [Internal]
|
---|
1829 | *
|
---|
1830 | * Test whether the current page can be changed by sending a PSN_KILLACTIVE
|
---|
1831 | *
|
---|
1832 | * PARAMS
|
---|
1833 | * hwndDlg [I] handle to a Dialog hWnd
|
---|
1834 | *
|
---|
1835 | * RETURNS
|
---|
1836 | * TRUE if Current Selection can change
|
---|
1837 | *
|
---|
1838 | * NOTES
|
---|
1839 | */
|
---|
1840 | static BOOL PROPSHEET_CanSetCurSel(HWND hwndDlg)
|
---|
1841 | {
|
---|
1842 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg,
|
---|
1843 | PropSheetInfoStr);
|
---|
1844 | HWND hwndPage;
|
---|
1845 | PSHNOTIFY psn;
|
---|
1846 | BOOL res = FALSE;
|
---|
1847 |
|
---|
1848 | TRACE("active_page %d\n", psInfo->active_page);
|
---|
1849 | if (!psInfo)
|
---|
1850 | {
|
---|
1851 | res = FALSE;
|
---|
1852 | goto end;
|
---|
1853 | }
|
---|
1854 |
|
---|
1855 | if (psInfo->active_page < 0)
|
---|
1856 | {
|
---|
1857 | res = TRUE;
|
---|
1858 | goto end;
|
---|
1859 | }
|
---|
1860 |
|
---|
1861 | /*
|
---|
1862 | * Notify the current page.
|
---|
1863 | */
|
---|
1864 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
---|
1865 | psn.hdr.code = PSN_KILLACTIVE;
|
---|
1866 | psn.hdr.hwndFrom = hwndDlg;
|
---|
1867 | psn.hdr.idFrom = 0;
|
---|
1868 | psn.lParam = 0;
|
---|
1869 |
|
---|
1870 | res = !SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
---|
1871 |
|
---|
1872 | end:
|
---|
1873 | TRACE("<-- %d\n", res);
|
---|
1874 | return res;
|
---|
1875 | }
|
---|
1876 |
|
---|
1877 | /******************************************************************************
|
---|
1878 | * PROPSHEET_SetCurSel
|
---|
1879 | */
|
---|
1880 | static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
|
---|
1881 | int index,
|
---|
1882 | int skipdir,
|
---|
1883 | HPROPSHEETPAGE hpage
|
---|
1884 | )
|
---|
1885 | {
|
---|
1886 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg, PropSheetInfoStr);
|
---|
1887 | HWND hwndHelp = GetDlgItem(hwndDlg, IDHELP);
|
---|
1888 | HWND hwndTabControl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
---|
1889 |
|
---|
1890 | TRACE("index %d, skipdir %d, hpage %p\n", index, skipdir, hpage);
|
---|
1891 | /* hpage takes precedence over index */
|
---|
1892 | if (hpage != NULL)
|
---|
1893 | index = PROPSHEET_GetPageIndex(hpage, psInfo);
|
---|
1894 |
|
---|
1895 | if (index < 0 || index >= psInfo->nPages)
|
---|
1896 | {
|
---|
1897 | TRACE("Could not find page to select!\n");
|
---|
1898 | return FALSE;
|
---|
1899 | }
|
---|
1900 |
|
---|
1901 | while (1) {
|
---|
1902 | int result;
|
---|
1903 | PSHNOTIFY psn;
|
---|
1904 |
|
---|
1905 | if (hwndTabControl)
|
---|
1906 | SendMessageW(hwndTabControl, TCM_SETCURSEL, index, 0);
|
---|
1907 |
|
---|
1908 | psn.hdr.code = PSN_SETACTIVE;
|
---|
1909 | psn.hdr.hwndFrom = hwndDlg;
|
---|
1910 | psn.hdr.idFrom = 0;
|
---|
1911 | psn.lParam = 0;
|
---|
1912 |
|
---|
1913 | if (!psInfo->proppage[index].hwndPage) {
|
---|
1914 | LPCPROPSHEETPAGEW ppshpage = (LPCPROPSHEETPAGEW)psInfo->proppage[index].hpage;
|
---|
1915 | PROPSHEET_CreatePage(hwndDlg, index, psInfo, ppshpage);
|
---|
1916 | }
|
---|
1917 |
|
---|
1918 | result = SendMessageW(psInfo->proppage[index].hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
---|
1919 | if (!result)
|
---|
1920 | break;
|
---|
1921 | if (result == -1) {
|
---|
1922 | index+=skipdir;
|
---|
1923 | if (index < 0) {
|
---|
1924 | index = 0;
|
---|
1925 | FIXME("Tried to skip before first property sheet page!\n");
|
---|
1926 | break;
|
---|
1927 | }
|
---|
1928 | if (index >= psInfo->nPages) {
|
---|
1929 | FIXME("Tried to skip after last property sheet page!\n");
|
---|
1930 | index = psInfo->nPages-1;
|
---|
1931 | break;
|
---|
1932 | }
|
---|
1933 | }
|
---|
1934 | else if (result != 0)
|
---|
1935 | {
|
---|
1936 | index = PROPSHEET_FindPageByResId(psInfo, result);
|
---|
1937 | continue;
|
---|
1938 | }
|
---|
1939 | }
|
---|
1940 | /*
|
---|
1941 | * Display the new page.
|
---|
1942 | */
|
---|
1943 | PROPSHEET_ShowPage(hwndDlg, index, psInfo);
|
---|
1944 |
|
---|
1945 | if (psInfo->proppage[index].hasHelp)
|
---|
1946 | EnableWindow(hwndHelp, TRUE);
|
---|
1947 | else
|
---|
1948 | EnableWindow(hwndHelp, FALSE);
|
---|
1949 |
|
---|
1950 | return TRUE;
|
---|
1951 | }
|
---|
1952 |
|
---|
1953 | /******************************************************************************
|
---|
1954 | * PROPSHEET_SetCurSelId
|
---|
1955 | *
|
---|
1956 | * Selects the page, specified by resource id.
|
---|
1957 | */
|
---|
1958 | static void PROPSHEET_SetCurSelId(HWND hwndDlg, int id)
|
---|
1959 | {
|
---|
1960 | int idx;
|
---|
1961 | PropSheetInfo* psInfo =
|
---|
1962 | (PropSheetInfo*) GetPropW(hwndDlg, PropSheetInfoStr);
|
---|
1963 |
|
---|
1964 | idx = PROPSHEET_FindPageByResId(psInfo, id);
|
---|
1965 | if (idx < psInfo->nPages )
|
---|
1966 | {
|
---|
1967 | if (PROPSHEET_CanSetCurSel(hwndDlg) != FALSE)
|
---|
1968 | PROPSHEET_SetCurSel(hwndDlg, idx, 1, 0);
|
---|
1969 | }
|
---|
1970 | }
|
---|
1971 |
|
---|
1972 | /******************************************************************************
|
---|
1973 | * PROPSHEET_SetTitleA
|
---|
1974 | */
|
---|
1975 | static void PROPSHEET_SetTitleA(HWND hwndDlg, DWORD dwStyle, LPCSTR lpszText)
|
---|
1976 | {
|
---|
1977 | if(HIWORD(lpszText))
|
---|
1978 | {
|
---|
1979 | WCHAR szTitle[256];
|
---|
1980 | MultiByteToWideChar(CP_ACP, 0, lpszText, -1,
|
---|
1981 | szTitle, sizeof szTitle);
|
---|
1982 | PROPSHEET_SetTitleW(hwndDlg, dwStyle, szTitle);
|
---|
1983 | }
|
---|
1984 | else
|
---|
1985 | {
|
---|
1986 | PROPSHEET_SetTitleW(hwndDlg, dwStyle, (LPCWSTR)lpszText);
|
---|
1987 | }
|
---|
1988 | }
|
---|
1989 |
|
---|
1990 | /******************************************************************************
|
---|
1991 | * PROPSHEET_SetTitleW
|
---|
1992 | */
|
---|
1993 | static void PROPSHEET_SetTitleW(HWND hwndDlg, DWORD dwStyle, LPCWSTR lpszText)
|
---|
1994 | {
|
---|
1995 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg, PropSheetInfoStr);
|
---|
1996 | WCHAR szTitle[256];
|
---|
1997 |
|
---|
1998 | TRACE("'%s' (style %08lx)\n", debugstr_w(lpszText), dwStyle);
|
---|
1999 | if (HIWORD(lpszText) == 0) {
|
---|
2000 | if (!LoadStringW(psInfo->ppshheader.hInstance,
|
---|
2001 | LOWORD(lpszText), szTitle, sizeof(szTitle)-sizeof(WCHAR)))
|
---|
2002 | return;
|
---|
2003 | lpszText = szTitle;
|
---|
2004 | }
|
---|
2005 | if (dwStyle & PSH_PROPTITLE)
|
---|
2006 | {
|
---|
2007 | WCHAR* dest;
|
---|
2008 | int lentitle = strlenW(lpszText);
|
---|
2009 | int lenprop = strlenW(psInfo->strPropertiesFor);
|
---|
2010 |
|
---|
2011 | dest = COMCTL32_Alloc( (lentitle + lenprop + 1)*sizeof (WCHAR));
|
---|
2012 | strcpyW(dest, psInfo->strPropertiesFor);
|
---|
2013 | strcatW(dest, lpszText);
|
---|
2014 |
|
---|
2015 | SetWindowTextW(hwndDlg, dest);
|
---|
2016 | COMCTL32_Free(dest);
|
---|
2017 | }
|
---|
2018 | else
|
---|
2019 | SetWindowTextW(hwndDlg, lpszText);
|
---|
2020 | }
|
---|
2021 |
|
---|
2022 | /******************************************************************************
|
---|
2023 | * PROPSHEET_SetFinishTextA
|
---|
2024 | */
|
---|
2025 | static void PROPSHEET_SetFinishTextA(HWND hwndDlg, LPCSTR lpszText)
|
---|
2026 | {
|
---|
2027 | HWND hwndButton = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
|
---|
2028 |
|
---|
2029 | TRACE("'%s'\n", lpszText);
|
---|
2030 | /* Set text, show and enable the Finish button */
|
---|
2031 | SetWindowTextA(hwndButton, lpszText);
|
---|
2032 | ShowWindow(hwndButton, SW_SHOW);
|
---|
2033 | EnableWindow(hwndButton, TRUE);
|
---|
2034 |
|
---|
2035 | /* Make it default pushbutton */
|
---|
2036 | SendMessageA(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0);
|
---|
2037 |
|
---|
2038 | /* Hide Back button */
|
---|
2039 | hwndButton = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
|
---|
2040 | ShowWindow(hwndButton, SW_HIDE);
|
---|
2041 |
|
---|
2042 | /* Hide Next button */
|
---|
2043 | hwndButton = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
|
---|
2044 | ShowWindow(hwndButton, SW_HIDE);
|
---|
2045 | }
|
---|
2046 |
|
---|
2047 | /******************************************************************************
|
---|
2048 | * PROPSHEET_SetFinishTextW
|
---|
2049 | */
|
---|
2050 | static void PROPSHEET_SetFinishTextW(HWND hwndDlg, LPCWSTR lpszText)
|
---|
2051 | {
|
---|
2052 | HWND hwndButton = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
|
---|
2053 |
|
---|
2054 | TRACE("'%s'\n", debugstr_w(lpszText));
|
---|
2055 | /* Set text, show and enable the Finish button */
|
---|
2056 | SetWindowTextW(hwndButton, lpszText);
|
---|
2057 | ShowWindow(hwndButton, SW_SHOW);
|
---|
2058 | EnableWindow(hwndButton, TRUE);
|
---|
2059 |
|
---|
2060 | /* Make it default pushbutton */
|
---|
2061 | SendMessageW(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0);
|
---|
2062 |
|
---|
2063 | /* Hide Back button */
|
---|
2064 | hwndButton = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
|
---|
2065 | ShowWindow(hwndButton, SW_HIDE);
|
---|
2066 |
|
---|
2067 | /* Hide Next button */
|
---|
2068 | hwndButton = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
|
---|
2069 | ShowWindow(hwndButton, SW_HIDE);
|
---|
2070 | }
|
---|
2071 |
|
---|
2072 | /******************************************************************************
|
---|
2073 | * PROPSHEET_QuerySiblings
|
---|
2074 | */
|
---|
2075 | static LRESULT PROPSHEET_QuerySiblings(HWND hwndDlg,
|
---|
2076 | WPARAM wParam, LPARAM lParam)
|
---|
2077 | {
|
---|
2078 | int i = 0;
|
---|
2079 | HWND hwndPage;
|
---|
2080 | LRESULT msgResult = 0;
|
---|
2081 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg,
|
---|
2082 | PropSheetInfoStr);
|
---|
2083 |
|
---|
2084 | while ((i < psInfo->nPages) && (msgResult == 0))
|
---|
2085 | {
|
---|
2086 | hwndPage = psInfo->proppage[i].hwndPage;
|
---|
2087 | msgResult = SendMessageA(hwndPage, PSM_QUERYSIBLINGS, wParam, lParam);
|
---|
2088 | i++;
|
---|
2089 | }
|
---|
2090 |
|
---|
2091 | return msgResult;
|
---|
2092 | }
|
---|
2093 |
|
---|
2094 |
|
---|
2095 | /******************************************************************************
|
---|
2096 | * PROPSHEET_AddPage
|
---|
2097 | */
|
---|
2098 | static BOOL PROPSHEET_AddPage(HWND hwndDlg,
|
---|
2099 | HPROPSHEETPAGE hpage)
|
---|
2100 | {
|
---|
2101 | PropSheetInfo * psInfo = (PropSheetInfo*) GetPropW(hwndDlg,
|
---|
2102 | PropSheetInfoStr);
|
---|
2103 | HWND hwndTabControl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
---|
2104 | TCITEMW item;
|
---|
2105 | LPCPROPSHEETPAGEW ppsp = (LPCPROPSHEETPAGEW)hpage;
|
---|
2106 |
|
---|
2107 | TRACE("hpage %p\n", hpage);
|
---|
2108 | /*
|
---|
2109 | * Allocate and fill in a new PropPageInfo entry.
|
---|
2110 | */
|
---|
2111 | psInfo->proppage = (PropPageInfo*) COMCTL32_ReAlloc(psInfo->proppage,
|
---|
2112 | sizeof(PropPageInfo) *
|
---|
2113 | (psInfo->nPages + 1));
|
---|
2114 | if (!PROPSHEET_CollectPageInfo(ppsp, psInfo, psInfo->nPages))
|
---|
2115 | return FALSE;
|
---|
2116 |
|
---|
2117 | psInfo->proppage[psInfo->nPages].hpage = hpage;
|
---|
2118 |
|
---|
2119 | if (ppsp->dwFlags & PSP_PREMATURE)
|
---|
2120 | {
|
---|
2121 | /* Create the page but don't show it */
|
---|
2122 | PROPSHEET_CreatePage(hwndDlg, psInfo->nPages, psInfo, ppsp);
|
---|
2123 | }
|
---|
2124 |
|
---|
2125 | /*
|
---|
2126 | * Add a new tab to the tab control.
|
---|
2127 | */
|
---|
2128 | item.mask = TCIF_TEXT;
|
---|
2129 | item.pszText = (LPWSTR) psInfo->proppage[psInfo->nPages].pszText;
|
---|
2130 | item.cchTextMax = MAX_TABTEXT_LENGTH;
|
---|
2131 |
|
---|
2132 | if (psInfo->hImageList)
|
---|
2133 | {
|
---|
2134 | SendMessageW(hwndTabControl, TCM_SETIMAGELIST, 0, (LPARAM)psInfo->hImageList);
|
---|
2135 | }
|
---|
2136 |
|
---|
2137 | if ( psInfo->proppage[psInfo->nPages].hasIcon )
|
---|
2138 | {
|
---|
2139 | item.mask |= TCIF_IMAGE;
|
---|
2140 | item.iImage = psInfo->nPages;
|
---|
2141 | }
|
---|
2142 |
|
---|
2143 | SendMessageW(hwndTabControl, TCM_INSERTITEMW, psInfo->nPages + 1,
|
---|
2144 | (LPARAM)&item);
|
---|
2145 |
|
---|
2146 | psInfo->nPages++;
|
---|
2147 |
|
---|
2148 | /* If it is the only page - show it */
|
---|
2149 | if(psInfo->nPages == 1)
|
---|
2150 | PROPSHEET_SetCurSel(hwndDlg, 0, 1, 0);
|
---|
2151 | return TRUE;
|
---|
2152 | }
|
---|
2153 |
|
---|
2154 | /******************************************************************************
|
---|
2155 | * PROPSHEET_RemovePage
|
---|
2156 | */
|
---|
2157 | static BOOL PROPSHEET_RemovePage(HWND hwndDlg,
|
---|
2158 | int index,
|
---|
2159 | HPROPSHEETPAGE hpage)
|
---|
2160 | {
|
---|
2161 | PropSheetInfo * psInfo = (PropSheetInfo*) GetPropW(hwndDlg,
|
---|
2162 | PropSheetInfoStr);
|
---|
2163 | HWND hwndTabControl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
---|
2164 | PropPageInfo* oldPages;
|
---|
2165 |
|
---|
2166 | TRACE("index %d, hpage %p\n", index, hpage);
|
---|
2167 | if (!psInfo) {
|
---|
2168 | return FALSE;
|
---|
2169 | }
|
---|
2170 | oldPages = psInfo->proppage;
|
---|
2171 | /*
|
---|
2172 | * hpage takes precedence over index.
|
---|
2173 | */
|
---|
2174 | if (hpage != 0)
|
---|
2175 | {
|
---|
2176 | index = PROPSHEET_GetPageIndex(hpage, psInfo);
|
---|
2177 | }
|
---|
2178 |
|
---|
2179 | /* Make sure that index is within range */
|
---|
2180 | if (index < 0 || index >= psInfo->nPages)
|
---|
2181 | {
|
---|
2182 | TRACE("Could not find page to remove!\n");
|
---|
2183 | return FALSE;
|
---|
2184 | }
|
---|
2185 |
|
---|
2186 | TRACE("total pages %d removing page %d active page %d\n",
|
---|
2187 | psInfo->nPages, index, psInfo->active_page);
|
---|
2188 | /*
|
---|
2189 | * Check if we're removing the active page.
|
---|
2190 | */
|
---|
2191 | if (index == psInfo->active_page)
|
---|
2192 | {
|
---|
2193 | if (psInfo->nPages > 1)
|
---|
2194 | {
|
---|
2195 | if (index > 0)
|
---|
2196 | {
|
---|
2197 | /* activate previous page */
|
---|
2198 | PROPSHEET_SetCurSel(hwndDlg, index - 1, -1, 0);
|
---|
2199 | }
|
---|
2200 | else
|
---|
2201 | {
|
---|
2202 | /* activate the next page */
|
---|
2203 | PROPSHEET_SetCurSel(hwndDlg, index + 1, 1, 0);
|
---|
2204 | psInfo->active_page = index;
|
---|
2205 | }
|
---|
2206 | }
|
---|
2207 | else
|
---|
2208 | {
|
---|
2209 | psInfo->active_page = -1;
|
---|
2210 | if (!psInfo->isModeless)
|
---|
2211 | {
|
---|
2212 | EndDialog(hwndDlg, FALSE);
|
---|
2213 | return TRUE;
|
---|
2214 | }
|
---|
2215 | }
|
---|
2216 | }
|
---|
2217 | else if (index < psInfo->active_page)
|
---|
2218 | psInfo->active_page--;
|
---|
2219 |
|
---|
2220 | /* Destroy page dialog window */
|
---|
2221 | DestroyWindow(psInfo->proppage[index].hwndPage);
|
---|
2222 |
|
---|
2223 | /* Free page resources */
|
---|
2224 | if(psInfo->proppage[index].hpage)
|
---|
2225 | {
|
---|
2226 | PROPSHEETPAGEW* psp = (PROPSHEETPAGEW*)psInfo->proppage[index].hpage;
|
---|
2227 |
|
---|
2228 | if ((psp->dwFlags & PSP_USETITLE) && psInfo->proppage[index].pszText)
|
---|
2229 | HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->proppage[index].pszText);
|
---|
2230 |
|
---|
2231 | DestroyPropertySheetPage(psInfo->proppage[index].hpage);
|
---|
2232 | }
|
---|
2233 |
|
---|
2234 | /* Remove the tab */
|
---|
2235 | SendMessageW(hwndTabControl, TCM_DELETEITEM, index, 0);
|
---|
2236 |
|
---|
2237 | psInfo->nPages--;
|
---|
2238 | psInfo->proppage = COMCTL32_Alloc(sizeof(PropPageInfo) * psInfo->nPages);
|
---|
2239 |
|
---|
2240 | if (index > 0)
|
---|
2241 | memcpy(&psInfo->proppage[0], &oldPages[0], index * sizeof(PropPageInfo));
|
---|
2242 |
|
---|
2243 | if (index < psInfo->nPages)
|
---|
2244 | memcpy(&psInfo->proppage[index], &oldPages[index + 1],
|
---|
2245 | (psInfo->nPages - index) * sizeof(PropPageInfo));
|
---|
2246 |
|
---|
2247 | COMCTL32_Free(oldPages);
|
---|
2248 |
|
---|
2249 | return FALSE;
|
---|
2250 | }
|
---|
2251 |
|
---|
2252 | /******************************************************************************
|
---|
2253 | * PROPSHEET_SetWizButtons
|
---|
2254 | *
|
---|
2255 | * This code will work if (and assumes that) the Next button is on top of the
|
---|
2256 | * Finish button. ie. Finish comes after Next in the Z order.
|
---|
2257 | * This means make sure the dialog template reflects this.
|
---|
2258 | *
|
---|
2259 | */
|
---|
2260 | static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags)
|
---|
2261 | {
|
---|
2262 | HWND hwndBack = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
|
---|
2263 | HWND hwndNext = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
|
---|
2264 | HWND hwndFinish = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
|
---|
2265 |
|
---|
2266 | TRACE("%ld\n", dwFlags);
|
---|
2267 |
|
---|
2268 | EnableWindow(hwndBack, FALSE);
|
---|
2269 | EnableWindow(hwndNext, FALSE);
|
---|
2270 | EnableWindow(hwndFinish, FALSE);
|
---|
2271 |
|
---|
2272 | if (dwFlags & PSWIZB_BACK)
|
---|
2273 | EnableWindow(hwndBack, TRUE);
|
---|
2274 |
|
---|
2275 | if (dwFlags & PSWIZB_NEXT)
|
---|
2276 | {
|
---|
2277 | /* Hide the Finish button */
|
---|
2278 | ShowWindow(hwndFinish, SW_HIDE);
|
---|
2279 |
|
---|
2280 | /* Show and enable the Next button */
|
---|
2281 | ShowWindow(hwndNext, SW_SHOW);
|
---|
2282 | EnableWindow(hwndNext, TRUE);
|
---|
2283 |
|
---|
2284 | /* Set the Next button as the default pushbutton */
|
---|
2285 | SendMessageA(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0);
|
---|
2286 | }
|
---|
2287 |
|
---|
2288 | if ((dwFlags & PSWIZB_FINISH) || (dwFlags & PSWIZB_DISABLEDFINISH))
|
---|
2289 | {
|
---|
2290 | /* Hide the Next button */
|
---|
2291 | ShowWindow(hwndNext, SW_HIDE);
|
---|
2292 |
|
---|
2293 | /* Show the Finish button */
|
---|
2294 | ShowWindow(hwndFinish, SW_SHOW);
|
---|
2295 |
|
---|
2296 | if (dwFlags & PSWIZB_FINISH)
|
---|
2297 | EnableWindow(hwndFinish, TRUE);
|
---|
2298 |
|
---|
2299 | /* Set the Finish button as the default pushbutton */
|
---|
2300 | SendMessageA(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0);
|
---|
2301 | }
|
---|
2302 | }
|
---|
2303 |
|
---|
2304 | /******************************************************************************
|
---|
2305 | * PROPSHEET_GetPageIndex
|
---|
2306 | *
|
---|
2307 | * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
|
---|
2308 | * the array of PropPageInfo.
|
---|
2309 | */
|
---|
2310 | static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage, PropSheetInfo* psInfo)
|
---|
2311 | {
|
---|
2312 | BOOL found = FALSE;
|
---|
2313 | int index = 0;
|
---|
2314 |
|
---|
2315 | TRACE("hpage %p\n", hpage);
|
---|
2316 | while ((index < psInfo->nPages) && (found == FALSE))
|
---|
2317 | {
|
---|
2318 | if (psInfo->proppage[index].hpage == hpage)
|
---|
2319 | found = TRUE;
|
---|
2320 | else
|
---|
2321 | index++;
|
---|
2322 | }
|
---|
2323 |
|
---|
2324 | if (found == FALSE)
|
---|
2325 | index = -1;
|
---|
2326 |
|
---|
2327 | return index;
|
---|
2328 | }
|
---|
2329 |
|
---|
2330 | /******************************************************************************
|
---|
2331 | * PROPSHEET_CleanUp
|
---|
2332 | */
|
---|
2333 | static void PROPSHEET_CleanUp(HWND hwndDlg)
|
---|
2334 | {
|
---|
2335 | int i;
|
---|
2336 | PropSheetInfo* psInfo = (PropSheetInfo*) RemovePropW(hwndDlg,
|
---|
2337 | PropSheetInfoStr);
|
---|
2338 |
|
---|
2339 | TRACE("\n");
|
---|
2340 | if (!psInfo) return;
|
---|
2341 | if (HIWORD(psInfo->ppshheader.pszCaption))
|
---|
2342 | HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->ppshheader.pszCaption);
|
---|
2343 |
|
---|
2344 | for (i = 0; i < psInfo->nPages; i++)
|
---|
2345 | {
|
---|
2346 | PROPSHEETPAGEA* psp = (PROPSHEETPAGEA*)psInfo->proppage[i].hpage;
|
---|
2347 |
|
---|
2348 | if(psInfo->proppage[i].hwndPage)
|
---|
2349 | DestroyWindow(psInfo->proppage[i].hwndPage);
|
---|
2350 |
|
---|
2351 | if(psp)
|
---|
2352 | {
|
---|
2353 | if ((psp->dwFlags & PSP_USETITLE) && psInfo->proppage[i].pszText)
|
---|
2354 | HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->proppage[i].pszText);
|
---|
2355 |
|
---|
2356 | DestroyPropertySheetPage(psInfo->proppage[i].hpage);
|
---|
2357 | }
|
---|
2358 | }
|
---|
2359 |
|
---|
2360 | COMCTL32_Free(psInfo->proppage);
|
---|
2361 | COMCTL32_Free(psInfo->strPropertiesFor);
|
---|
2362 | ImageList_Destroy(psInfo->hImageList);
|
---|
2363 |
|
---|
2364 | GlobalFree((HGLOBAL)psInfo);
|
---|
2365 | }
|
---|
2366 |
|
---|
2367 | /******************************************************************************
|
---|
2368 | * PropertySheet (COMCTL32.@)
|
---|
2369 | * PropertySheetA (COMCTL32.@)
|
---|
2370 | */
|
---|
2371 | INT WINAPI PropertySheetA(LPCPROPSHEETHEADERA lppsh)
|
---|
2372 | {
|
---|
2373 | int bRet = 0;
|
---|
2374 | PropSheetInfo* psInfo = (PropSheetInfo*) GlobalAlloc(GPTR,
|
---|
2375 | sizeof(PropSheetInfo));
|
---|
2376 | int i, n;
|
---|
2377 | BYTE* pByte;
|
---|
2378 |
|
---|
2379 | TRACE("(%p)\n", lppsh);
|
---|
2380 |
|
---|
2381 | PROPSHEET_CollectSheetInfoA(lppsh, psInfo);
|
---|
2382 |
|
---|
2383 | psInfo->proppage = (PropPageInfo*) COMCTL32_Alloc(sizeof(PropPageInfo) *
|
---|
2384 | lppsh->nPages);
|
---|
2385 | pByte = (BYTE*) psInfo->ppshheader.u3.ppsp;
|
---|
2386 |
|
---|
2387 | for (n = i = 0; i < lppsh->nPages; i++, n++)
|
---|
2388 | {
|
---|
2389 | if (!(lppsh->dwFlags & PSH_PROPSHEETPAGE))
|
---|
2390 | psInfo->proppage[n].hpage = psInfo->ppshheader.u3.phpage[i];
|
---|
2391 | else
|
---|
2392 | {
|
---|
2393 | psInfo->proppage[n].hpage = CreatePropertySheetPageA((LPCPROPSHEETPAGEA)pByte);
|
---|
2394 | pByte += ((LPPROPSHEETPAGEA)pByte)->dwSize;
|
---|
2395 | }
|
---|
2396 |
|
---|
2397 | if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW)psInfo->proppage[n].hpage,
|
---|
2398 | psInfo, n))
|
---|
2399 | {
|
---|
2400 | if (lppsh->dwFlags & PSH_PROPSHEETPAGE)
|
---|
2401 | DestroyPropertySheetPage(psInfo->proppage[n].hpage);
|
---|
2402 | n--;
|
---|
2403 | psInfo->nPages--;
|
---|
2404 | }
|
---|
2405 | }
|
---|
2406 |
|
---|
2407 | bRet = PROPSHEET_CreateDialog(psInfo);
|
---|
2408 |
|
---|
2409 | return bRet;
|
---|
2410 | }
|
---|
2411 |
|
---|
2412 | /******************************************************************************
|
---|
2413 | * PropertySheetW (COMCTL32.@)
|
---|
2414 | */
|
---|
2415 | INT WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
|
---|
2416 | {
|
---|
2417 | int bRet = 0;
|
---|
2418 | PropSheetInfo* psInfo = (PropSheetInfo*) GlobalAlloc(GPTR,
|
---|
2419 | sizeof(PropSheetInfo));
|
---|
2420 | int i, n;
|
---|
2421 | BYTE* pByte;
|
---|
2422 |
|
---|
2423 | TRACE("(%p)\n", lppsh);
|
---|
2424 |
|
---|
2425 | PROPSHEET_CollectSheetInfoW(lppsh, psInfo);
|
---|
2426 |
|
---|
2427 | psInfo->proppage = (PropPageInfo*) COMCTL32_Alloc(sizeof(PropPageInfo) *
|
---|
2428 | lppsh->nPages);
|
---|
2429 | pByte = (BYTE*) psInfo->ppshheader.u3.ppsp;
|
---|
2430 |
|
---|
2431 | for (n = i = 0; i < lppsh->nPages; i++, n++)
|
---|
2432 | {
|
---|
2433 | if (!(lppsh->dwFlags & PSH_PROPSHEETPAGE))
|
---|
2434 | psInfo->proppage[n].hpage = psInfo->ppshheader.u3.phpage[i];
|
---|
2435 | else
|
---|
2436 | {
|
---|
2437 | psInfo->proppage[n].hpage = CreatePropertySheetPageW((LPCPROPSHEETPAGEW)pByte);
|
---|
2438 | pByte += ((LPPROPSHEETPAGEW)pByte)->dwSize;
|
---|
2439 | }
|
---|
2440 |
|
---|
2441 | if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW)psInfo->proppage[n].hpage,
|
---|
2442 | psInfo, n))
|
---|
2443 | {
|
---|
2444 | if (lppsh->dwFlags & PSH_PROPSHEETPAGE)
|
---|
2445 | DestroyPropertySheetPage(psInfo->proppage[n].hpage);
|
---|
2446 | n--;
|
---|
2447 | psInfo->nPages--;
|
---|
2448 | }
|
---|
2449 | }
|
---|
2450 |
|
---|
2451 | bRet = PROPSHEET_CreateDialog(psInfo);
|
---|
2452 |
|
---|
2453 | return bRet;
|
---|
2454 | }
|
---|
2455 |
|
---|
2456 | /******************************************************************************
|
---|
2457 | * CreatePropertySheetPage (COMCTL32.@)
|
---|
2458 | * CreatePropertySheetPageA (COMCTL32.@)
|
---|
2459 | */
|
---|
2460 | HPROPSHEETPAGE WINAPI CreatePropertySheetPageA(
|
---|
2461 | LPCPROPSHEETPAGEA lpPropSheetPage)
|
---|
2462 | {
|
---|
2463 | PROPSHEETPAGEW* ppsp = COMCTL32_Alloc(sizeof(PROPSHEETPAGEW));
|
---|
2464 |
|
---|
2465 | memcpy(ppsp,lpPropSheetPage,min(lpPropSheetPage->dwSize,sizeof(PROPSHEETPAGEA)));
|
---|
2466 |
|
---|
2467 | if ( !(ppsp->dwFlags & PSP_DLGINDIRECT) && HIWORD( ppsp->u.pszTemplate ) )
|
---|
2468 | {
|
---|
2469 | PROPSHEET_AtoW(&ppsp->u.pszTemplate, lpPropSheetPage->u.pszTemplate);
|
---|
2470 | }
|
---|
2471 | if ( (ppsp->dwFlags & PSP_USEICONID) && HIWORD( ppsp->u2.pszIcon ) )
|
---|
2472 | {
|
---|
2473 | PROPSHEET_AtoW(&ppsp->u2.pszIcon, lpPropSheetPage->u2.pszIcon);
|
---|
2474 | }
|
---|
2475 |
|
---|
2476 | if ((ppsp->dwFlags & PSP_USETITLE) && HIWORD( ppsp->pszTitle ))
|
---|
2477 | {
|
---|
2478 | PROPSHEET_AtoW(&ppsp->pszTitle, lpPropSheetPage->pszTitle);
|
---|
2479 | }
|
---|
2480 | else if ( !(ppsp->dwFlags & PSP_USETITLE) )
|
---|
2481 | ppsp->pszTitle = NULL;
|
---|
2482 |
|
---|
2483 | return (HPROPSHEETPAGE)ppsp;
|
---|
2484 | }
|
---|
2485 |
|
---|
2486 | /******************************************************************************
|
---|
2487 | * CreatePropertySheetPageW (COMCTL32.@)
|
---|
2488 | */
|
---|
2489 | HPROPSHEETPAGE WINAPI CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage)
|
---|
2490 | {
|
---|
2491 | PROPSHEETPAGEW* ppsp = COMCTL32_Alloc(sizeof(PROPSHEETPAGEW));
|
---|
2492 |
|
---|
2493 | memcpy(ppsp,lpPropSheetPage,min(lpPropSheetPage->dwSize,sizeof(PROPSHEETPAGEW)));
|
---|
2494 |
|
---|
2495 | if ( !(ppsp->dwFlags & PSP_DLGINDIRECT) && HIWORD( ppsp->u.pszTemplate ) )
|
---|
2496 | {
|
---|
2497 | int len = strlenW(lpPropSheetPage->u.pszTemplate);
|
---|
2498 |
|
---|
2499 | ppsp->u.pszTemplate = HeapAlloc( GetProcessHeap(),0,(len+1)*sizeof (WCHAR) );
|
---|
2500 | strcpyW( (WCHAR *)ppsp->u.pszTemplate, lpPropSheetPage->u.pszTemplate );
|
---|
2501 | }
|
---|
2502 | if ( (ppsp->dwFlags & PSP_USEICONID) && HIWORD( ppsp->u2.pszIcon ) )
|
---|
2503 | {
|
---|
2504 | int len = strlenW(lpPropSheetPage->u2.pszIcon);
|
---|
2505 | ppsp->u2.pszIcon = HeapAlloc( GetProcessHeap(), 0, (len+1)*sizeof (WCHAR) );
|
---|
2506 | strcpyW( (WCHAR *)ppsp->u2.pszIcon, lpPropSheetPage->u2.pszIcon );
|
---|
2507 | }
|
---|
2508 |
|
---|
2509 | if ((ppsp->dwFlags & PSP_USETITLE) && HIWORD( ppsp->pszTitle ))
|
---|
2510 | {
|
---|
2511 | int len = strlenW(lpPropSheetPage->pszTitle);
|
---|
2512 | ppsp->pszTitle = HeapAlloc( GetProcessHeap(), 0, (len+1)*sizeof (WCHAR) );
|
---|
2513 | strcpyW( (WCHAR *)ppsp->pszTitle, lpPropSheetPage->pszTitle );
|
---|
2514 | }
|
---|
2515 | else if ( !(ppsp->dwFlags & PSP_USETITLE) )
|
---|
2516 | ppsp->pszTitle = NULL;
|
---|
2517 |
|
---|
2518 | return (HPROPSHEETPAGE)ppsp;
|
---|
2519 | }
|
---|
2520 |
|
---|
2521 | /******************************************************************************
|
---|
2522 | * DestroyPropertySheetPage (COMCTL32.@)
|
---|
2523 | */
|
---|
2524 | BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
|
---|
2525 | {
|
---|
2526 | PROPSHEETPAGEW *psp = (PROPSHEETPAGEW *)hPropPage;
|
---|
2527 |
|
---|
2528 | if (!psp)
|
---|
2529 | return FALSE;
|
---|
2530 |
|
---|
2531 | if ( !(psp->dwFlags & PSP_DLGINDIRECT) && HIWORD( psp->u.pszTemplate ) )
|
---|
2532 | HeapFree(GetProcessHeap(), 0, (LPVOID)psp->u.pszTemplate);
|
---|
2533 |
|
---|
2534 | if ( (psp->dwFlags & PSP_USEICONID) && HIWORD( psp->u2.pszIcon ) )
|
---|
2535 | HeapFree(GetProcessHeap(), 0, (LPVOID)psp->u2.pszIcon);
|
---|
2536 |
|
---|
2537 | if ((psp->dwFlags & PSP_USETITLE) && HIWORD( psp->pszTitle ))
|
---|
2538 | HeapFree(GetProcessHeap(), 0, (LPVOID)psp->pszTitle);
|
---|
2539 |
|
---|
2540 | COMCTL32_Free(hPropPage);
|
---|
2541 |
|
---|
2542 | return TRUE;
|
---|
2543 | }
|
---|
2544 |
|
---|
2545 | /******************************************************************************
|
---|
2546 | * PROPSHEET_IsDialogMessage
|
---|
2547 | */
|
---|
2548 | static BOOL PROPSHEET_IsDialogMessage(HWND hwnd, LPMSG lpMsg)
|
---|
2549 | {
|
---|
2550 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwnd, PropSheetInfoStr);
|
---|
2551 |
|
---|
2552 | TRACE("\n");
|
---|
2553 | if (!psInfo || (hwnd != lpMsg->hwnd && !IsChild(hwnd, lpMsg->hwnd)))
|
---|
2554 | return FALSE;
|
---|
2555 |
|
---|
2556 | if (lpMsg->message == WM_KEYDOWN && (GetKeyState(VK_CONTROL) & 0x8000))
|
---|
2557 | {
|
---|
2558 | int new_page = 0;
|
---|
2559 | INT dlgCode = SendMessageA(lpMsg->hwnd, WM_GETDLGCODE, 0, (LPARAM)lpMsg);
|
---|
2560 |
|
---|
2561 | if (!(dlgCode & DLGC_WANTMESSAGE))
|
---|
2562 | {
|
---|
2563 | switch (lpMsg->wParam)
|
---|
2564 | {
|
---|
2565 | case VK_TAB:
|
---|
2566 | if (GetKeyState(VK_SHIFT) & 0x8000)
|
---|
2567 | new_page = -1;
|
---|
2568 | else
|
---|
2569 | new_page = 1;
|
---|
2570 | break;
|
---|
2571 |
|
---|
2572 | case VK_NEXT: new_page = 1; break;
|
---|
2573 | case VK_PRIOR: new_page = -1; break;
|
---|
2574 | }
|
---|
2575 | }
|
---|
2576 |
|
---|
2577 | if (new_page)
|
---|
2578 | {
|
---|
2579 | if (PROPSHEET_CanSetCurSel(hwnd) != FALSE)
|
---|
2580 | {
|
---|
2581 | new_page += psInfo->active_page;
|
---|
2582 |
|
---|
2583 | if (new_page < 0)
|
---|
2584 | new_page = psInfo->nPages - 1;
|
---|
2585 | else if (new_page >= psInfo->nPages)
|
---|
2586 | new_page = 0;
|
---|
2587 |
|
---|
2588 | PROPSHEET_SetCurSel(hwnd, new_page, 1, 0);
|
---|
2589 | }
|
---|
2590 |
|
---|
2591 | return TRUE;
|
---|
2592 | }
|
---|
2593 | }
|
---|
2594 |
|
---|
2595 | return IsDialogMessageA(hwnd, lpMsg);
|
---|
2596 | }
|
---|
2597 |
|
---|
2598 | /******************************************************************************
|
---|
2599 | * PROPSHEET_DoCommand
|
---|
2600 | */
|
---|
2601 | static BOOL PROPSHEET_DoCommand(HWND hwnd, WORD wID)
|
---|
2602 | {
|
---|
2603 |
|
---|
2604 | switch (wID) {
|
---|
2605 |
|
---|
2606 | case IDOK:
|
---|
2607 | case IDC_APPLY_BUTTON:
|
---|
2608 | {
|
---|
2609 | HWND hwndApplyBtn = GetDlgItem(hwnd, IDC_APPLY_BUTTON);
|
---|
2610 |
|
---|
2611 | if (PROPSHEET_Apply(hwnd, wID == IDOK ? 1: 0) == FALSE)
|
---|
2612 | break;
|
---|
2613 |
|
---|
2614 | if (wID == IDOK)
|
---|
2615 | {
|
---|
2616 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwnd,
|
---|
2617 | PropSheetInfoStr);
|
---|
2618 | int result = TRUE;
|
---|
2619 |
|
---|
2620 | if (psInfo->restartWindows)
|
---|
2621 | result = ID_PSRESTARTWINDOWS;
|
---|
2622 |
|
---|
2623 | /* reboot system takes precedence over restart windows */
|
---|
2624 | if (psInfo->rebootSystem)
|
---|
2625 | result = ID_PSREBOOTSYSTEM;
|
---|
2626 |
|
---|
2627 | if (psInfo->isModeless)
|
---|
2628 | psInfo->activeValid = FALSE;
|
---|
2629 | else
|
---|
2630 | EndDialog(hwnd, result);
|
---|
2631 | }
|
---|
2632 | else
|
---|
2633 | EnableWindow(hwndApplyBtn, FALSE);
|
---|
2634 |
|
---|
2635 | break;
|
---|
2636 | }
|
---|
2637 |
|
---|
2638 | case IDC_BACK_BUTTON:
|
---|
2639 | PROPSHEET_Back(hwnd);
|
---|
2640 | break;
|
---|
2641 |
|
---|
2642 | case IDC_NEXT_BUTTON:
|
---|
2643 | PROPSHEET_Next(hwnd);
|
---|
2644 | break;
|
---|
2645 |
|
---|
2646 | case IDC_FINISH_BUTTON:
|
---|
2647 | PROPSHEET_Finish(hwnd);
|
---|
2648 | break;
|
---|
2649 |
|
---|
2650 | case IDCANCEL:
|
---|
2651 | PROPSHEET_Cancel(hwnd, 0);
|
---|
2652 | break;
|
---|
2653 |
|
---|
2654 | case IDHELP:
|
---|
2655 | PROPSHEET_Help(hwnd);
|
---|
2656 | break;
|
---|
2657 | }
|
---|
2658 |
|
---|
2659 | return TRUE;
|
---|
2660 | }
|
---|
2661 |
|
---|
2662 | /******************************************************************************
|
---|
2663 | * PROPSHEET_DialogProc
|
---|
2664 | */
|
---|
2665 | BOOL WINAPI
|
---|
2666 | PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
---|
2667 | {
|
---|
2668 | TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
|
---|
2669 | hwnd, uMsg, wParam, lParam);
|
---|
2670 |
|
---|
2671 | switch (uMsg)
|
---|
2672 | {
|
---|
2673 | case WM_INITDIALOG:
|
---|
2674 | {
|
---|
2675 | PropSheetInfo* psInfo = (PropSheetInfo*) lParam;
|
---|
2676 | WCHAR* strCaption = (WCHAR*)COMCTL32_Alloc(MAX_CAPTION_LENGTH*sizeof(WCHAR));
|
---|
2677 | HWND hwndTabCtrl = GetDlgItem(hwnd, IDC_TABCONTROL);
|
---|
2678 | LPCPROPSHEETPAGEW ppshpage;
|
---|
2679 | int idx;
|
---|
2680 |
|
---|
2681 | SetPropW(hwnd, PropSheetInfoStr, (HANDLE)psInfo);
|
---|
2682 |
|
---|
2683 | /*
|
---|
2684 | * psInfo->hwnd is not being used by WINE code - it exists
|
---|
2685 | * for compatibility with "real" Windoze. The same about
|
---|
2686 | * SetWindowLong - WINE is only using the PropSheetInfoStr
|
---|
2687 | * property.
|
---|
2688 | */
|
---|
2689 | psInfo->hwnd = hwnd;
|
---|
2690 | SetWindowLongW(hwnd,DWL_USER,(LONG)psInfo);
|
---|
2691 |
|
---|
2692 | /*
|
---|
2693 | * Small icon in the title bar.
|
---|
2694 | */
|
---|
2695 | if ((psInfo->ppshheader.dwFlags & PSH_USEICONID) ||
|
---|
2696 | (psInfo->ppshheader.dwFlags & PSH_USEHICON))
|
---|
2697 | {
|
---|
2698 | HICON hIcon;
|
---|
2699 | int icon_cx = GetSystemMetrics(SM_CXSMICON);
|
---|
2700 | int icon_cy = GetSystemMetrics(SM_CYSMICON);
|
---|
2701 |
|
---|
2702 | if (psInfo->ppshheader.dwFlags & PSH_USEICONID)
|
---|
2703 | hIcon = LoadImageW(psInfo->ppshheader.hInstance,
|
---|
2704 | psInfo->ppshheader.u.pszIcon,
|
---|
2705 | IMAGE_ICON,
|
---|
2706 | icon_cx, icon_cy,
|
---|
2707 | LR_DEFAULTCOLOR);
|
---|
2708 | else
|
---|
2709 | hIcon = psInfo->ppshheader.u.hIcon;
|
---|
2710 |
|
---|
2711 | SendMessageW(hwnd, WM_SETICON, 0, (LPARAM)hIcon);
|
---|
2712 | }
|
---|
2713 |
|
---|
2714 | if (psInfo->ppshheader.dwFlags & PSH_USEHICON)
|
---|
2715 | SendMessageW(hwnd, WM_SETICON, 0, (LPARAM)psInfo->ppshheader.u.hIcon);
|
---|
2716 |
|
---|
2717 | psInfo->strPropertiesFor = strCaption;
|
---|
2718 |
|
---|
2719 | GetWindowTextW(hwnd, psInfo->strPropertiesFor, MAX_CAPTION_LENGTH);
|
---|
2720 |
|
---|
2721 | PROPSHEET_CreateTabControl(hwnd, psInfo);
|
---|
2722 |
|
---|
2723 | if (psInfo->ppshheader.dwFlags & INTRNL_ANY_WIZARD)
|
---|
2724 | {
|
---|
2725 | if (PROPSHEET_IsTooSmallWizard(hwnd, psInfo))
|
---|
2726 | {
|
---|
2727 | PROPSHEET_AdjustSizeWizard(hwnd, psInfo);
|
---|
2728 | PROPSHEET_AdjustButtonsWizard(hwnd, psInfo);
|
---|
2729 | }
|
---|
2730 | }
|
---|
2731 | else
|
---|
2732 | {
|
---|
2733 | if (PROPSHEET_SizeMismatch(hwnd, psInfo))
|
---|
2734 | {
|
---|
2735 | PROPSHEET_AdjustSize(hwnd, psInfo);
|
---|
2736 | PROPSHEET_AdjustButtons(hwnd, psInfo);
|
---|
2737 | }
|
---|
2738 | }
|
---|
2739 |
|
---|
2740 | if (psInfo->useCallback)
|
---|
2741 | (*(psInfo->ppshheader.pfnCallback))(hwnd,
|
---|
2742 | PSCB_INITIALIZED, (LPARAM)0);
|
---|
2743 |
|
---|
2744 | idx = psInfo->active_page;
|
---|
2745 | ppshpage = (LPCPROPSHEETPAGEW)psInfo->proppage[idx].hpage;
|
---|
2746 | psInfo->active_page = -1;
|
---|
2747 |
|
---|
2748 | PROPSHEET_SetCurSel(hwnd, idx, 1, psInfo->proppage[idx].hpage);
|
---|
2749 |
|
---|
2750 | /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
|
---|
2751 | * as some programs call TCM_GETCURSEL to get the current selection
|
---|
2752 | * from which to switch to the next page */
|
---|
2753 | SendMessageW(hwndTabCtrl, TCM_SETCURSEL, psInfo->active_page, 0);
|
---|
2754 |
|
---|
2755 | if (!HIWORD(psInfo->ppshheader.pszCaption) &&
|
---|
2756 | psInfo->ppshheader.hInstance)
|
---|
2757 | {
|
---|
2758 | WCHAR szText[256];
|
---|
2759 |
|
---|
2760 | if (LoadStringW(psInfo->ppshheader.hInstance,
|
---|
2761 | (UINT)psInfo->ppshheader.pszCaption, szText, 255))
|
---|
2762 | PROPSHEET_SetTitleW(hwnd, psInfo->ppshheader.dwFlags, szText);
|
---|
2763 | }
|
---|
2764 | else
|
---|
2765 | {
|
---|
2766 | PROPSHEET_SetTitleW(hwnd, psInfo->ppshheader.dwFlags,
|
---|
2767 | psInfo->ppshheader.pszCaption);
|
---|
2768 | }
|
---|
2769 |
|
---|
2770 | return TRUE;
|
---|
2771 | }
|
---|
2772 |
|
---|
2773 | case WM_DESTROY:
|
---|
2774 | PROPSHEET_CleanUp(hwnd);
|
---|
2775 | return TRUE;
|
---|
2776 |
|
---|
2777 | case WM_CLOSE:
|
---|
2778 | PROPSHEET_Cancel(hwnd, 1);
|
---|
2779 | return TRUE;
|
---|
2780 |
|
---|
2781 | case WM_COMMAND:
|
---|
2782 | return PROPSHEET_DoCommand(hwnd, LOWORD(wParam));
|
---|
2783 |
|
---|
2784 | case WM_NOTIFY:
|
---|
2785 | {
|
---|
2786 | NMHDR* pnmh = (LPNMHDR) lParam;
|
---|
2787 |
|
---|
2788 | if (pnmh->code == TCN_SELCHANGE)
|
---|
2789 | {
|
---|
2790 | int index = SendMessageW(pnmh->hwndFrom, TCM_GETCURSEL, 0, 0);
|
---|
2791 | PROPSHEET_SetCurSel(hwnd, index, 1, 0);
|
---|
2792 | }
|
---|
2793 |
|
---|
2794 | if(pnmh->code == TCN_SELCHANGING)
|
---|
2795 | {
|
---|
2796 | BOOL bRet = PROPSHEET_CanSetCurSel(hwnd);
|
---|
2797 | SetWindowLongW(hwnd, DWL_MSGRESULT, !bRet);
|
---|
2798 | return TRUE;
|
---|
2799 | }
|
---|
2800 |
|
---|
2801 | return FALSE;
|
---|
2802 | }
|
---|
2803 |
|
---|
2804 | case PSM_GETCURRENTPAGEHWND:
|
---|
2805 | {
|
---|
2806 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwnd,
|
---|
2807 | PropSheetInfoStr);
|
---|
2808 | HWND hwndPage = 0;
|
---|
2809 |
|
---|
2810 | if (psInfo->activeValid && psInfo->active_page != -1)
|
---|
2811 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
---|
2812 |
|
---|
2813 | SetWindowLongW(hwnd, DWL_MSGRESULT, (LONG)hwndPage);
|
---|
2814 |
|
---|
2815 | return TRUE;
|
---|
2816 | }
|
---|
2817 |
|
---|
2818 | case PSM_CHANGED:
|
---|
2819 | PROPSHEET_Changed(hwnd, (HWND)wParam);
|
---|
2820 | return TRUE;
|
---|
2821 |
|
---|
2822 | case PSM_UNCHANGED:
|
---|
2823 | PROPSHEET_UnChanged(hwnd, (HWND)wParam);
|
---|
2824 | return TRUE;
|
---|
2825 |
|
---|
2826 | case PSM_GETTABCONTROL:
|
---|
2827 | {
|
---|
2828 | HWND hwndTabCtrl = GetDlgItem(hwnd, IDC_TABCONTROL);
|
---|
2829 |
|
---|
2830 | SetWindowLongW(hwnd, DWL_MSGRESULT, (LONG)hwndTabCtrl);
|
---|
2831 |
|
---|
2832 | return TRUE;
|
---|
2833 | }
|
---|
2834 |
|
---|
2835 | case PSM_SETCURSEL:
|
---|
2836 | {
|
---|
2837 | BOOL msgResult;
|
---|
2838 |
|
---|
2839 | msgResult = PROPSHEET_CanSetCurSel(hwnd);
|
---|
2840 | if(msgResult != FALSE)
|
---|
2841 | {
|
---|
2842 | msgResult = PROPSHEET_SetCurSel(hwnd,
|
---|
2843 | (int)wParam,
|
---|
2844 | 1,
|
---|
2845 | (HPROPSHEETPAGE)lParam);
|
---|
2846 | }
|
---|
2847 |
|
---|
2848 | SetWindowLongW(hwnd, DWL_MSGRESULT, msgResult);
|
---|
2849 |
|
---|
2850 | return TRUE;
|
---|
2851 | }
|
---|
2852 |
|
---|
2853 | case PSM_CANCELTOCLOSE:
|
---|
2854 | {
|
---|
2855 | WCHAR buf[MAX_BUTTONTEXT_LENGTH];
|
---|
2856 | HWND hwndOK = GetDlgItem(hwnd, IDOK);
|
---|
2857 | HWND hwndCancel = GetDlgItem(hwnd, IDCANCEL);
|
---|
2858 |
|
---|
2859 | EnableWindow(hwndCancel, FALSE);
|
---|
2860 | if (LoadStringW(COMCTL32_hModule, IDS_CLOSE, buf, sizeof(buf)))
|
---|
2861 | SetWindowTextW(hwndOK, buf);
|
---|
2862 |
|
---|
2863 | return FALSE;
|
---|
2864 | }
|
---|
2865 |
|
---|
2866 | case PSM_RESTARTWINDOWS:
|
---|
2867 | {
|
---|
2868 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwnd,
|
---|
2869 | PropSheetInfoStr);
|
---|
2870 |
|
---|
2871 | psInfo->restartWindows = TRUE;
|
---|
2872 | return TRUE;
|
---|
2873 | }
|
---|
2874 |
|
---|
2875 | case PSM_REBOOTSYSTEM:
|
---|
2876 | {
|
---|
2877 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwnd,
|
---|
2878 | PropSheetInfoStr);
|
---|
2879 |
|
---|
2880 | psInfo->rebootSystem = TRUE;
|
---|
2881 | return TRUE;
|
---|
2882 | }
|
---|
2883 |
|
---|
2884 | case PSM_SETTITLEA:
|
---|
2885 | PROPSHEET_SetTitleA(hwnd, (DWORD) wParam, (LPCSTR) lParam);
|
---|
2886 | return TRUE;
|
---|
2887 |
|
---|
2888 | case PSM_SETTITLEW:
|
---|
2889 | PROPSHEET_SetTitleW(hwnd, (DWORD) wParam, (LPCWSTR) lParam);
|
---|
2890 | return TRUE;
|
---|
2891 |
|
---|
2892 | case PSM_APPLY:
|
---|
2893 | {
|
---|
2894 | BOOL msgResult = PROPSHEET_Apply(hwnd, 0);
|
---|
2895 |
|
---|
2896 | SetWindowLongW(hwnd, DWL_MSGRESULT, msgResult);
|
---|
2897 |
|
---|
2898 | return TRUE;
|
---|
2899 | }
|
---|
2900 |
|
---|
2901 | case PSM_QUERYSIBLINGS:
|
---|
2902 | {
|
---|
2903 | LRESULT msgResult = PROPSHEET_QuerySiblings(hwnd, wParam, lParam);
|
---|
2904 |
|
---|
2905 | SetWindowLongW(hwnd, DWL_MSGRESULT, msgResult);
|
---|
2906 |
|
---|
2907 | return TRUE;
|
---|
2908 | }
|
---|
2909 |
|
---|
2910 | case PSM_ADDPAGE:
|
---|
2911 | {
|
---|
2912 | /*
|
---|
2913 | * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
|
---|
2914 | * a return value. This is not true. PSM_ADDPAGE returns TRUE
|
---|
2915 | * on success or FALSE otherwise, as specified on MSDN Online.
|
---|
2916 | * Also see the MFC code for
|
---|
2917 | * CPropertySheet::AddPage(CPropertyPage* pPage).
|
---|
2918 | */
|
---|
2919 |
|
---|
2920 | BOOL msgResult = PROPSHEET_AddPage(hwnd, (HPROPSHEETPAGE)lParam);
|
---|
2921 |
|
---|
2922 | SetWindowLongW(hwnd, DWL_MSGRESULT, msgResult);
|
---|
2923 |
|
---|
2924 | return TRUE;
|
---|
2925 | }
|
---|
2926 |
|
---|
2927 | case PSM_REMOVEPAGE:
|
---|
2928 | PROPSHEET_RemovePage(hwnd, (int)wParam, (HPROPSHEETPAGE)lParam);
|
---|
2929 | return TRUE;
|
---|
2930 |
|
---|
2931 | case PSM_ISDIALOGMESSAGE:
|
---|
2932 | {
|
---|
2933 | BOOL msgResult = PROPSHEET_IsDialogMessage(hwnd, (LPMSG)lParam);
|
---|
2934 | SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
|
---|
2935 | return TRUE;
|
---|
2936 | }
|
---|
2937 |
|
---|
2938 | case PSM_PRESSBUTTON:
|
---|
2939 | PROPSHEET_PressButton(hwnd, (int)wParam);
|
---|
2940 | return TRUE;
|
---|
2941 |
|
---|
2942 | case PSM_SETFINISHTEXTA:
|
---|
2943 | PROPSHEET_SetFinishTextA(hwnd, (LPCSTR) lParam);
|
---|
2944 | return TRUE;
|
---|
2945 |
|
---|
2946 | case PSM_SETWIZBUTTONS:
|
---|
2947 | PROPSHEET_SetWizButtons(hwnd, (DWORD)lParam);
|
---|
2948 | return TRUE;
|
---|
2949 |
|
---|
2950 | case PSM_SETCURSELID:
|
---|
2951 | PROPSHEET_SetCurSelId(hwnd, (int)lParam);
|
---|
2952 | return TRUE;
|
---|
2953 |
|
---|
2954 | case PSM_SETFINISHTEXTW:
|
---|
2955 | PROPSHEET_SetFinishTextW(hwnd, (LPCWSTR) lParam);
|
---|
2956 | return FALSE;
|
---|
2957 |
|
---|
2958 | default:
|
---|
2959 | return FALSE;
|
---|
2960 | }
|
---|
2961 |
|
---|
2962 | return FALSE;
|
---|
2963 | }
|
---|