4 * Copyright 1998 Francis Beaudet
5 * Copyright 1999 Thuy Nguyen
6 * Copyright 2004 Maxime Bellenge
7 * Copyright 2004 Filip Navara
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * This code was audited for completeness against the documented features
24 * of Comctl32.dll version 6.0 on Sep. 12, 2004, by Filip Navara.
26 * Unless otherwise noted, we believe this code to be complete, as per
27 * the specification mentioned above.
28 * If you discover missing features, or bugs, please note them below.
32 * - Wizard 97 header resizing
33 * - Enforcing of minimal wizard size
37 * o PSM_RECALCPAGESIZES
38 * o PSM_SETHEADERSUBTITLE
39 * o PSM_SETHEADERTITLE
44 * o PSN_QUERYINITIALFOCUS
45 * o PSN_TRANSLATEACCELERATOR
48 * o PSH_STRETCHWATERMARK
52 * o PSP_USEFUSIONCONTEXT
59 #define NONAMELESSUNION
60 #define NONAMELESSSTRUCT
71 #include "wine/debug.h"
72 #include "wine/unicode.h"
74 /******************************************************************************
98 } MyDLGITEMTEMPLATEEX
;
101 typedef struct tagPropPageInfo
103 HPROPSHEETPAGE hpage
; /* to keep track of pages not passed to PropertySheet */
112 typedef struct tagPropSheetInfo
115 PROPSHEETHEADERW ppshheader
;
117 LPWSTR strPropertiesFor
;
128 PropPageInfo
* proppage
;
133 HIMAGELIST hImageList
;
144 /******************************************************************************
145 * Defines and global variables
148 const WCHAR PropSheetInfoStr
[] =
149 {'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0 };
151 #define PSP_INTERNAL_UNICODE 0x80000000
153 #define MAX_CAPTION_LENGTH 255
154 #define MAX_TABTEXT_LENGTH 255
155 #define MAX_BUTTONTEXT_LENGTH 64
157 #define INTRNL_ANY_WIZARD (PSH_WIZARD | PSH_WIZARD97_OLD | PSH_WIZARD97_NEW | PSH_WIZARD_LITE)
159 /* Wizard metrics specified in DLUs */
160 #define WIZARD_PADDING 7
161 #define WIZARD_HEADER_HEIGHT 36
163 /******************************************************************************
166 static INT_PTR
PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
);
167 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, PropSheetInfo
* psInfo
);
168 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
);
169 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, PropSheetInfo
* psInfo
);
170 static BOOL
PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh
,
171 PropSheetInfo
* psInfo
);
172 static BOOL
PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
173 PropSheetInfo
* psInfo
);
174 static BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
175 PropSheetInfo
* psInfo
,
177 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
178 PropSheetInfo
* psInfo
);
179 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
, int index
,
180 const PropSheetInfo
* psInfo
,
181 LPCPROPSHEETPAGEW ppshpage
);
182 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
);
183 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
);
184 static BOOL
PROPSHEET_Back(HWND hwndDlg
);
185 static BOOL
PROPSHEET_Next(HWND hwndDlg
);
186 static BOOL
PROPSHEET_Finish(HWND hwndDlg
);
187 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
);
188 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
);
189 static void PROPSHEET_Help(HWND hwndDlg
);
190 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
);
191 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
);
192 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
);
193 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
);
194 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
);
195 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
);
196 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
);
197 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
);
198 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
201 HPROPSHEETPAGE hpage
);
202 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
);
203 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
204 WPARAM wParam
, LPARAM lParam
);
205 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
206 HPROPSHEETPAGE hpage
);
208 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
210 HPROPSHEETPAGE hpage
);
211 static void PROPSHEET_CleanUp(HWND hwndDlg
);
212 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, PropSheetInfo
* psInfo
);
213 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
);
214 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
);
215 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
);
216 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
);
219 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
221 WINE_DEFAULT_DEBUG_CHANNEL(propsheet
);
223 #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");}
224 /******************************************************************************
225 * PROPSHEET_UnImplementedFlags
227 * Document use of flags we don't implement yet.
229 static VOID
PROPSHEET_UnImplementedFlags(DWORD dwFlags
)
236 * unhandled header flags:
237 * PSH_RTLREADING 0x00000800
238 * PSH_STRETCHWATERMARK 0x00040000
239 * PSH_USEPAGELANG 0x00200000
242 add_flag(PSH_RTLREADING
);
243 add_flag(PSH_STRETCHWATERMARK
);
244 add_flag(PSH_USEPAGELANG
);
245 if (string
[0] != '\0')
246 FIXME("%s\n", string
);
250 /******************************************************************************
251 * PROPSHEET_GetPageRect
253 * Retrieve rect from tab control and map into the dialog for SetWindowPos
255 static void PROPSHEET_GetPageRect(const PropSheetInfo
* psInfo
, HWND hwndDlg
,
256 RECT
*rc
, LPCPROPSHEETPAGEW ppshpage
)
258 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) {
262 if (((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
263 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
264 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) ||
265 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
))
267 rc
->left
= rc
->top
= WIZARD_PADDING
;
271 rc
->left
= rc
->top
= 0;
273 rc
->right
= psInfo
->width
- rc
->left
;
274 rc
->bottom
= psInfo
->height
- rc
->top
;
275 MapDialogRect(hwndDlg
, rc
);
277 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
278 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
279 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
))
281 hwndChild
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
282 GetClientRect(hwndChild
, &r
);
283 MapWindowPoints(hwndChild
, hwndDlg
, (LPPOINT
) &r
, 2);
284 rc
->top
+= r
.bottom
+ 1;
287 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
288 GetClientRect(hwndTabCtrl
, rc
);
289 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)rc
);
290 MapWindowPoints(hwndTabCtrl
, hwndDlg
, (LPPOINT
)rc
, 2);
294 /******************************************************************************
295 * PROPSHEET_FindPageByResId
297 * Find page index corresponding to page resource id.
299 static INT
PROPSHEET_FindPageByResId(PropSheetInfo
* psInfo
, LRESULT resId
)
303 for (i
= 0; i
< psInfo
->nPages
; i
++)
305 LPCPROPSHEETPAGEA lppsp
= (LPCPROPSHEETPAGEA
)psInfo
->proppage
[i
].hpage
;
307 /* Fixme: if resource ID is a string shall we use strcmp ??? */
308 if (lppsp
->u
.pszTemplate
== (LPVOID
)resId
)
315 /******************************************************************************
318 * Convert ASCII to Unicode since all data is saved as Unicode.
320 static void PROPSHEET_AtoW(LPCWSTR
*tostr
, LPCSTR frstr
)
324 TRACE("<%s>\n", frstr
);
325 len
= MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, 0, 0);
326 *tostr
= Alloc(len
* sizeof(WCHAR
));
327 MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, (LPWSTR
)*tostr
, len
);
330 /******************************************************************************
331 * PROPSHEET_CollectSheetInfoA
333 * Collect relevant data.
335 static BOOL
PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh
,
336 PropSheetInfo
* psInfo
)
338 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERA
));
339 DWORD dwFlags
= lppsh
->dwFlags
;
341 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
342 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
343 psInfo
->hasFinish
= dwFlags
& PSH_WIZARDHASFINISH
;
344 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
)&& (lppsh
->pfnCallback
);
345 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
347 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
348 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",
349 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
,
350 debugstr_a(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
352 PROPSHEET_UnImplementedFlags(lppsh
->dwFlags
);
354 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
355 psInfo
->ppshheader
.pszCaption
= NULL
;
358 if (HIWORD(lppsh
->pszCaption
))
360 int len
= MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, NULL
, 0);
361 psInfo
->ppshheader
.pszCaption
= Alloc( len
*sizeof (WCHAR
) );
362 MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, (LPWSTR
) psInfo
->ppshheader
.pszCaption
, len
);
365 psInfo
->nPages
= lppsh
->nPages
;
367 if (dwFlags
& PSH_USEPSTARTPAGE
)
369 TRACE("PSH_USEPSTARTPAGE is on\n");
370 psInfo
->active_page
= 0;
373 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
375 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
376 psInfo
->active_page
= 0;
378 psInfo
->restartWindows
= FALSE
;
379 psInfo
->rebootSystem
= FALSE
;
380 psInfo
->hImageList
= 0;
381 psInfo
->activeValid
= FALSE
;
386 /******************************************************************************
387 * PROPSHEET_CollectSheetInfoW
389 * Collect relevant data.
391 static BOOL
PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
392 PropSheetInfo
* psInfo
)
394 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERW
));
395 DWORD dwFlags
= lppsh
->dwFlags
;
397 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
398 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
399 psInfo
->hasFinish
= dwFlags
& PSH_WIZARDHASFINISH
;
400 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
) && (lppsh
->pfnCallback
);
401 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
403 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
404 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",
405 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
, debugstr_w(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
407 PROPSHEET_UnImplementedFlags(lppsh
->dwFlags
);
409 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
410 psInfo
->ppshheader
.pszCaption
= NULL
;
413 if (HIWORD(lppsh
->pszCaption
))
415 int len
= strlenW(lppsh
->pszCaption
);
416 psInfo
->ppshheader
.pszCaption
= Alloc( (len
+1)*sizeof(WCHAR
) );
417 strcpyW( (WCHAR
*)psInfo
->ppshheader
.pszCaption
, lppsh
->pszCaption
);
420 psInfo
->nPages
= lppsh
->nPages
;
422 if (dwFlags
& PSH_USEPSTARTPAGE
)
424 TRACE("PSH_USEPSTARTPAGE is on\n");
425 psInfo
->active_page
= 0;
428 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
430 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
431 psInfo
->active_page
= 0;
433 psInfo
->restartWindows
= FALSE
;
434 psInfo
->rebootSystem
= FALSE
;
435 psInfo
->hImageList
= 0;
436 psInfo
->activeValid
= FALSE
;
441 /******************************************************************************
442 * PROPSHEET_CollectPageInfo
444 * Collect property sheet data.
445 * With code taken from DIALOG_ParseTemplate32.
447 BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
448 PropSheetInfo
* psInfo
,
451 DLGTEMPLATE
* pTemplate
;
460 psInfo
->proppage
[index
].hpage
= (HPROPSHEETPAGE
)lppsp
;
461 psInfo
->proppage
[index
].hwndPage
= 0;
462 psInfo
->proppage
[index
].isDirty
= FALSE
;
465 * Process property page flags.
467 dwFlags
= lppsp
->dwFlags
;
468 psInfo
->proppage
[index
].useCallback
= (dwFlags
& PSP_USECALLBACK
) && (lppsp
->pfnCallback
);
469 psInfo
->proppage
[index
].hasHelp
= dwFlags
& PSP_HASHELP
;
470 psInfo
->proppage
[index
].hasIcon
= dwFlags
& (PSP_USEHICON
| PSP_USEICONID
);
472 /* as soon as we have a page with the help flag, set the sheet flag on */
473 if (psInfo
->proppage
[index
].hasHelp
)
474 psInfo
->hasHelp
= TRUE
;
477 * Process page template.
479 if (dwFlags
& PSP_DLGINDIRECT
)
480 pTemplate
= (DLGTEMPLATE
*)lppsp
->u
.pResource
;
481 else if(dwFlags
& PSP_INTERNAL_UNICODE
)
483 HRSRC hResource
= FindResourceW(lppsp
->hInstance
,
484 lppsp
->u
.pszTemplate
,
486 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
488 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
492 HRSRC hResource
= FindResourceA(lppsp
->hInstance
,
493 (LPSTR
)lppsp
->u
.pszTemplate
,
495 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
497 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
501 * Extract the size of the page and the caption.
506 p
= (const WORD
*)pTemplate
;
508 if (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
510 /* DLGTEMPLATEEX (not defined in any std. header file) */
514 p
+= 2; /* help ID */
515 p
+= 2; /* ext style */
523 p
+= 2; /* ext style */
529 width
= (WORD
)*p
; p
++;
530 height
= (WORD
)*p
; p
++;
532 /* Special calculation for interior wizard pages so the largest page is
533 * calculated correctly. We need to add all the padding and space occupied
534 * by the header so the width and height sums up to the whole wizard client
536 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
537 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
538 !(dwFlags
& PSP_HIDEHEADER
))
540 height
+= 2 * WIZARD_PADDING
+ WIZARD_HEADER_HEIGHT
;
541 width
+= 2 * WIZARD_PADDING
;
543 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
)
545 height
+= 2 * WIZARD_PADDING
;
546 width
+= 2 * WIZARD_PADDING
;
549 /* remember the largest width and height */
550 if (width
> psInfo
->width
)
551 psInfo
->width
= width
;
553 if (height
> psInfo
->height
)
554 psInfo
->height
= height
;
566 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
580 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
584 /* Extract the caption */
585 psInfo
->proppage
[index
].pszText
= (LPCWSTR
)p
;
586 TRACE("Tab %d %s\n",index
,debugstr_w((LPCWSTR
)p
));
587 p
+= lstrlenW((LPCWSTR
)p
) + 1;
589 if (dwFlags
& PSP_USETITLE
)
593 static const WCHAR pszNull
[] = { '(','n','u','l','l',')',0 };
596 if ( !HIWORD( lppsp
->pszTitle
) )
598 if (!LoadStringW( lppsp
->hInstance
, (DWORD_PTR
)lppsp
->pszTitle
,szTitle
,sizeof(szTitle
) ))
601 FIXME("Could not load resource #%04x?\n",LOWORD(lppsp
->pszTitle
));
607 pTitle
= lppsp
->pszTitle
;
609 len
= strlenW(pTitle
);
610 psInfo
->proppage
[index
].pszText
= Alloc( (len
+1)*sizeof (WCHAR
) );
611 strcpyW( (LPWSTR
)psInfo
->proppage
[index
].pszText
,pTitle
);
615 * Build the image list for icons
617 if ((dwFlags
& PSP_USEHICON
) || (dwFlags
& PSP_USEICONID
))
620 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
621 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
623 if (dwFlags
& PSP_USEICONID
)
624 hIcon
= LoadImageW(lppsp
->hInstance
, lppsp
->u2
.pszIcon
, IMAGE_ICON
,
625 icon_cx
, icon_cy
, LR_DEFAULTCOLOR
);
627 hIcon
= lppsp
->u2
.hIcon
;
631 if (psInfo
->hImageList
== 0 )
632 psInfo
->hImageList
= ImageList_Create(icon_cx
, icon_cy
, ILC_COLOR
, 1, 1);
634 ImageList_AddIcon(psInfo
->hImageList
, hIcon
);
642 /******************************************************************************
643 * PROPSHEET_CreateDialog
645 * Creates the actual property sheet.
647 INT_PTR
PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
)
654 WORD resID
= IDD_PROPSHEET
;
657 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
660 if( psInfo
->unicode
)
662 if(!(hRes
= FindResourceW(COMCTL32_hModule
,
663 MAKEINTRESOURCEW(resID
),
669 if(!(hRes
= FindResourceA(COMCTL32_hModule
,
670 MAKEINTRESOURCEA(resID
),
675 if(!(template = (LPVOID
)LoadResource(COMCTL32_hModule
, hRes
)))
679 * Make a copy of the dialog template.
681 resSize
= SizeofResource(COMCTL32_hModule
, hRes
);
683 temp
= Alloc(resSize
);
688 memcpy(temp
, template, resSize
);
690 if (psInfo
->ppshheader
.dwFlags
& PSH_NOCONTEXTHELP
)
692 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
693 ((MyDLGTEMPLATEEX
*)temp
)->style
&= ~DS_CONTEXTHELP
;
695 ((DLGTEMPLATE
*)temp
)->style
&= ~DS_CONTEXTHELP
;
697 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
698 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARDCONTEXTHELP
))
700 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
701 ((MyDLGTEMPLATEEX
*)temp
)->style
|= DS_CONTEXTHELP
;
703 ((DLGTEMPLATE
*)temp
)->style
|= DS_CONTEXTHELP
;
706 if (psInfo
->useCallback
)
707 (*(psInfo
->ppshheader
.pfnCallback
))(0, PSCB_PRECREATE
, (LPARAM
)temp
);
709 /* NOTE: MSDN states "Returns a positive value if successful, or -1
710 * otherwise for modal property sheets.", but this is wrong. The
711 * actual return value is either TRUE (success), FALSE (cancel) or
713 if( psInfo
->unicode
)
715 ret
= (INT_PTR
)CreateDialogIndirectParamW(psInfo
->ppshheader
.hInstance
,
716 (LPDLGTEMPLATEW
) temp
,
717 psInfo
->ppshheader
.hwndParent
,
718 PROPSHEET_DialogProc
,
720 if ( !ret
) ret
= -1;
724 ret
= (INT_PTR
)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
725 (LPDLGTEMPLATEA
) temp
,
726 psInfo
->ppshheader
.hwndParent
,
727 PROPSHEET_DialogProc
,
729 if ( !ret
) ret
= -1;
737 /******************************************************************************
738 * PROPSHEET_SizeMismatch
740 * Verify that the tab control and the "largest" property sheet page dlg. template
743 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, PropSheetInfo
* psInfo
)
745 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
746 RECT rcOrigTab
, rcPage
;
751 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
752 TRACE("orig tab %ld %ld %ld %ld\n", rcOrigTab
.left
, rcOrigTab
.top
,
753 rcOrigTab
.right
, rcOrigTab
.bottom
);
760 rcPage
.right
= psInfo
->width
;
761 rcPage
.bottom
= psInfo
->height
;
763 MapDialogRect(hwndDlg
, &rcPage
);
764 TRACE("biggest page %ld %ld %ld %ld\n", rcPage
.left
, rcPage
.top
,
765 rcPage
.right
, rcPage
.bottom
);
767 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
769 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
775 /******************************************************************************
776 * PROPSHEET_AdjustSize
778 * Resizes the property sheet and the tab control to fit the largest page.
780 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
782 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
783 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
785 int tabOffsetX
, tabOffsetY
, buttonHeight
;
786 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
789 /* Get the height of buttons */
790 GetClientRect(hwndButton
, &rc
);
791 buttonHeight
= rc
.bottom
;
798 rc
.right
= psInfo
->width
;
799 rc
.bottom
= psInfo
->height
;
801 MapDialogRect(hwndDlg
, &rc
);
803 /* retrieve the dialog units */
804 units
.left
= units
.right
= 4;
805 units
.top
= units
.bottom
= 8;
806 MapDialogRect(hwndDlg
, &units
);
809 * Resize the tab control.
811 GetClientRect(hwndTabCtrl
,&tabRect
);
813 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
815 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
817 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
818 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
821 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
823 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
824 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
827 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
829 tabOffsetX
= -(rc
.left
);
830 tabOffsetY
= -(rc
.top
);
834 TRACE("setting tab %p, rc (0,0)-(%ld,%ld)\n",
835 hwndTabCtrl
, rc
.right
, rc
.bottom
);
836 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
837 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
839 GetClientRect(hwndTabCtrl
, &rc
);
841 TRACE("tab client rc %ld %ld %ld %ld\n",
842 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
844 rc
.right
+= ((padding
.x
* 2) + tabOffsetX
);
845 rc
.bottom
+= (buttonHeight
+ (3 * padding
.y
) + tabOffsetY
);
848 * Resize the property sheet.
850 TRACE("setting dialog %p, rc (0,0)-(%ld,%ld)\n",
851 hwndDlg
, rc
.right
, rc
.bottom
);
852 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
853 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
857 /******************************************************************************
858 * PROPSHEET_AdjustSizeWizard
860 * Resizes the property sheet to fit the largest page.
862 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, PropSheetInfo
* psInfo
)
864 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
865 RECT rc
, lineRect
, dialogRect
;
867 /* Biggest page size */
870 rc
.right
= psInfo
->width
;
871 rc
.bottom
= psInfo
->height
;
872 MapDialogRect(hwndDlg
, &rc
);
874 TRACE("Biggest page %ld %ld %ld %ld\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
876 /* Add space for the buttons row */
877 GetWindowRect(hwndLine
, &lineRect
);
878 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
879 GetClientRect(hwndDlg
, &dialogRect
);
880 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
882 /* Convert the client coordinates to window coordinates */
883 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
885 /* Resize the property sheet */
886 TRACE("setting dialog %p, rc (0,0)-(%ld,%ld)\n",
887 hwndDlg
, rc
.right
, rc
.bottom
);
888 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
889 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
894 /******************************************************************************
895 * PROPSHEET_AdjustButtons
897 * Adjusts the buttons' positions.
899 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, PropSheetInfo
* psInfo
)
901 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
905 int buttonWidth
, buttonHeight
;
906 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
908 if (psInfo
->hasApply
)
915 * Obtain the size of the buttons.
917 GetClientRect(hwndButton
, &rcSheet
);
918 buttonWidth
= rcSheet
.right
;
919 buttonHeight
= rcSheet
.bottom
;
922 * Get the size of the property sheet.
924 GetClientRect(hwndParent
, &rcSheet
);
927 * All buttons will be at this y coordinate.
929 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
932 * Position OK button and make it default.
934 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
936 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
938 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
939 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
941 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
945 * Position Cancel button.
947 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
949 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1));
951 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
952 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
955 * Position Apply button.
957 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
959 if (psInfo
->hasApply
)
962 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * 2);
964 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
966 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
967 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
969 EnableWindow(hwndButton
, FALSE
);
972 ShowWindow(hwndButton
, SW_HIDE
);
975 * Position Help button.
977 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
981 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
983 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
984 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
987 ShowWindow(hwndButton
, SW_HIDE
);
992 /******************************************************************************
993 * PROPSHEET_AdjustButtonsWizard
995 * Adjusts the buttons' positions.
997 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
998 PropSheetInfo
* psInfo
)
1000 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1001 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
1002 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
1005 int num_buttons
= 3;
1006 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
1007 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
1009 if (psInfo
->hasHelp
)
1011 if (psInfo
->hasFinish
)
1015 * Obtain the size of the buttons.
1017 GetClientRect(hwndButton
, &rcSheet
);
1018 buttonWidth
= rcSheet
.right
;
1019 buttonHeight
= rcSheet
.bottom
;
1021 GetClientRect(hwndLine
, &rcSheet
);
1022 lineHeight
= rcSheet
.bottom
;
1025 * Get the size of the property sheet.
1027 GetClientRect(hwndParent
, &rcSheet
);
1030 * All buttons will be at this y coordinate.
1032 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
1035 * Position the Back button.
1037 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
1039 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1)) - buttonWidth
;
1041 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1042 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1045 * Position the Next button.
1047 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
1051 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1052 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1055 * Position the Finish button.
1057 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
1059 if (psInfo
->hasFinish
)
1060 x
+= padding
.x
+ buttonWidth
;
1062 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1063 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1065 if (!psInfo
->hasFinish
)
1066 ShowWindow(hwndButton
, SW_HIDE
);
1069 * Position the Cancel button.
1071 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1073 x
+= padding
.x
+ buttonWidth
;
1075 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1076 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1079 * Position Help button.
1081 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1083 if (psInfo
->hasHelp
)
1085 x
+= padding
.x
+ buttonWidth
;
1087 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1088 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1091 ShowWindow(hwndButton
, SW_HIDE
);
1093 if (psInfo
->ppshheader
.dwFlags
&
1094 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1098 * Position and resize the sunken line.
1101 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1103 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1104 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1105 SWP_NOZORDER
| SWP_NOACTIVATE
);
1108 * Position and resize the header sunken line.
1111 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1112 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1113 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1114 ShowWindow(hwndLineHeader
, SW_HIDE
);
1119 /******************************************************************************
1120 * PROPSHEET_GetPaddingInfo
1122 * Returns the layout information.
1124 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1126 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1129 PADDING_INFO padding
;
1131 GetWindowRect(hwndTab
, &rcTab
);
1136 ScreenToClient(hwndDlg
, &tl
);
1144 /******************************************************************************
1145 * PROPSHEET_GetPaddingInfoWizard
1147 * Returns the layout information.
1148 * Vertical spacing is the distance between the line and the buttons.
1149 * Do NOT use the Help button to gather padding information when it isn't mapped
1150 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1151 * for it in this case !
1152 * FIXME: I'm not sure about any other coordinate problems with these evil
1153 * buttons. Fix it in case additional problems appear or maybe calculate
1154 * a padding in a completely different way, as this is somewhat messy.
1156 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1159 PADDING_INFO padding
;
1163 POINT ptButton
, ptLine
;
1166 if (psInfo
->hasHelp
)
1172 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1174 idButton
= IDC_NEXT_BUTTON
;
1178 /* hopefully this is ok */
1179 idButton
= IDCANCEL
;
1183 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1184 GetWindowRect(hwndControl
, &rc
);
1186 ptButton
.x
= rc
.left
;
1187 ptButton
.y
= rc
.top
;
1189 ScreenToClient(hwndDlg
, &ptButton
);
1192 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1193 GetWindowRect(hwndControl
, &rc
);
1196 ptLine
.y
= rc
.bottom
;
1198 ScreenToClient(hwndDlg
, &ptLine
);
1200 padding
.y
= ptButton
.y
- ptLine
.y
;
1203 ERR("padding negative ! Please report this !\n");
1205 /* this is most probably not correct, but the best we have now */
1206 padding
.x
= padding
.y
;
1210 /******************************************************************************
1211 * PROPSHEET_CreateTabControl
1213 * Insert the tabs in the tab control.
1215 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1216 PropSheetInfo
* psInfo
)
1218 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1224 item
.mask
= TCIF_TEXT
;
1225 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1227 nTabs
= psInfo
->nPages
;
1230 * Set the image list for icons.
1232 if (psInfo
->hImageList
)
1234 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1237 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 0, 0);
1238 for (i
= 0; i
< nTabs
; i
++)
1240 if ( psInfo
->proppage
[i
].hasIcon
)
1242 item
.mask
|= TCIF_IMAGE
;
1243 item
.iImage
= iImage
++;
1247 item
.mask
&= ~TCIF_IMAGE
;
1250 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1251 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, (WPARAM
)i
, (LPARAM
)&item
);
1253 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 1, 0);
1258 /******************************************************************************
1259 * PROPSHEET_WizardSubclassProc
1261 * Subclassing window procedure for wizard extrior pages to prevent drawing
1262 * background and so drawing above the watermark.
1264 static LRESULT CALLBACK
1265 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1272 case WM_CTLCOLORSTATIC
:
1273 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1274 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1277 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1281 * Get the size of an in-memory Template
1283 *( Based on the code of PROPSHEET_CollectPageInfo)
1284 * See also dialog.c/DIALOG_ParseTemplate32().
1287 static UINT
GetTemplateSize(DLGTEMPLATE
* pTemplate
)
1290 const WORD
* p
= (const WORD
*)pTemplate
;
1291 BOOL istemplateex
= (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1296 /* DLGTEMPLATEEX (not defined in any std. header file) */
1298 TRACE("is DLGTEMPLATEEX\n");
1300 p
++; /* signature */
1301 p
+= 2; /* help ID */
1302 p
+= 2; /* ext style */
1309 TRACE("is DLGTEMPLATE\n");
1311 p
+= 2; /* ext style */
1314 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1330 TRACE("menu %s\n",debugstr_w((LPCWSTR
)p
));
1331 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1342 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1345 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1346 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1351 TRACE("title %s\n",debugstr_w((LPCWSTR
)p
));
1352 p
+= lstrlenW((LPCWSTR
)p
) + 1;
1354 /* font, if DS_SETFONT set */
1355 if ((DS_SETFONT
& ((istemplateex
)? ((MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1358 p
+=(istemplateex
)?3:1;
1359 TRACE("font %s\n",debugstr_w((LPCWSTR
)p
));
1360 p
+= lstrlenW( (LPCWSTR
)p
) + 1; /* the font name */
1363 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1364 * that are following the DLGTEMPLATE(EX) data */
1365 TRACE("%d items\n",nrofitems
);
1366 while (nrofitems
> 0)
1368 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1371 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1380 TRACE("class ordinal 0x%08lx\n",*(DWORD
*)p
);
1384 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1385 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1389 /* check title text */
1396 TRACE("text ordinal 0x%08lx\n",*(DWORD
*)p
);
1400 TRACE("text %s\n",debugstr_w((LPCWSTR
)p
));
1401 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1404 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1408 TRACE("%p %p size 0x%08x\n",p
, (WORD
*)pTemplate
,sizeof(WORD
)*(p
- (WORD
*)pTemplate
));
1409 return (p
- (WORD
*)pTemplate
)*sizeof(WORD
);
1413 /******************************************************************************
1414 * PROPSHEET_CreatePage
1418 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1420 const PropSheetInfo
* psInfo
,
1421 LPCPROPSHEETPAGEW ppshpage
)
1423 DLGTEMPLATE
* pTemplate
;
1428 TRACE("index %d\n", index
);
1430 if (ppshpage
== NULL
)
1435 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1437 pTemplate
= (DLGTEMPLATE
*)ppshpage
->u
.pResource
;
1438 resSize
= GetTemplateSize(pTemplate
);
1440 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1445 hResource
= FindResourceW(ppshpage
->hInstance
,
1446 ppshpage
->u
.pszTemplate
,
1451 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1453 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1457 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
1459 * Make a copy of the dialog template to make it writable
1467 hResource
= FindResourceA(ppshpage
->hInstance
,
1468 (LPSTR
)ppshpage
->u
.pszTemplate
,
1473 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1475 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1479 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
1481 * Make a copy of the dialog template to make it writable
1484 temp
= Alloc(resSize
);
1488 TRACE("copying pTemplate %p into temp %p (%ld)\n", pTemplate
, temp
, resSize
);
1489 memcpy(temp
, pTemplate
, resSize
);
1492 if (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
1494 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1495 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~DS_MODALFRAME
;
1496 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_CAPTION
;
1497 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_SYSMENU
;
1498 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_POPUP
;
1499 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_DISABLED
;
1500 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_VISIBLE
;
1501 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_THICKFRAME
;
1503 ((MyDLGTEMPLATEEX
*)pTemplate
)->exStyle
|= WS_EX_CONTROLPARENT
;
1507 pTemplate
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1508 pTemplate
->style
&= ~DS_MODALFRAME
;
1509 pTemplate
->style
&= ~WS_CAPTION
;
1510 pTemplate
->style
&= ~WS_SYSMENU
;
1511 pTemplate
->style
&= ~WS_POPUP
;
1512 pTemplate
->style
&= ~WS_DISABLED
;
1513 pTemplate
->style
&= ~WS_VISIBLE
;
1514 pTemplate
->style
&= ~WS_THICKFRAME
;
1516 pTemplate
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1519 if (psInfo
->proppage
[index
].useCallback
)
1520 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1521 (LPPROPSHEETPAGEW
)ppshpage
);
1523 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1524 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1527 ppshpage
->pfnDlgProc
,
1530 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1533 ppshpage
->pfnDlgProc
,
1535 /* Free a no more needed copy */
1539 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1541 /* Subclass exterior wizard pages */
1542 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1543 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1544 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1546 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1547 (DWORD_PTR
)ppshpage
);
1549 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1550 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1555 /******************************************************************************
1556 * PROPSHEET_LoadWizardBitmaps
1558 * Loads the watermark and header bitmaps for a wizard.
1560 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1562 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1564 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1565 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1566 considers hbmWatermark as valid. */
1567 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1568 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1570 ((PropSheetInfo
*)psInfo
)->ppshheader
.u4
.hbmWatermark
=
1571 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1574 /* Same behavior as for watermarks */
1575 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1576 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1578 ((PropSheetInfo
*)psInfo
)->ppshheader
.u5
.hbmHeader
=
1579 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1585 /******************************************************************************
1586 * PROPSHEET_ShowPage
1588 * Displays or creates the specified page.
1590 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1593 HWND hwndLineHeader
;
1594 LPCPROPSHEETPAGEW ppshpage
;
1596 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1597 if (index
== psInfo
->active_page
)
1599 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1600 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1604 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1605 if (psInfo
->proppage
[index
].hwndPage
== 0)
1607 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1610 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
1611 (ppshpage
->dwFlags
& PSP_USETITLE
))
1613 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1614 psInfo
->proppage
[index
].pszText
);
1617 if (psInfo
->active_page
!= -1)
1618 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1620 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1622 /* Synchronize current selection with tab control
1623 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1624 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1625 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1627 psInfo
->active_page
= index
;
1628 psInfo
->activeValid
= TRUE
;
1630 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1632 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1633 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1635 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1636 ShowWindow(hwndLineHeader
, SW_HIDE
);
1638 ShowWindow(hwndLineHeader
, SW_SHOW
);
1644 /******************************************************************************
1647 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1651 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1656 TRACE("active_page %d\n", psInfo
->active_page
);
1657 if (psInfo
->active_page
< 0)
1660 psn
.hdr
.code
= PSN_WIZBACK
;
1661 psn
.hdr
.hwndFrom
= hwndDlg
;
1665 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1667 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1670 else if (result
== 0)
1671 idx
= psInfo
->active_page
- 1;
1673 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1675 if (idx
>= 0 && idx
< psInfo
->nPages
)
1677 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1678 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1683 /******************************************************************************
1686 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1690 LRESULT msgResult
= 0;
1691 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1695 TRACE("active_page %d\n", psInfo
->active_page
);
1696 if (psInfo
->active_page
< 0)
1699 psn
.hdr
.code
= PSN_WIZNEXT
;
1700 psn
.hdr
.hwndFrom
= hwndDlg
;
1704 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1706 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1707 if (msgResult
== -1)
1709 else if (msgResult
== 0)
1710 idx
= psInfo
->active_page
+ 1;
1712 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1714 if (idx
< psInfo
->nPages
)
1716 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1717 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1723 /******************************************************************************
1726 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1730 LRESULT msgResult
= 0;
1731 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1734 TRACE("active_page %d\n", psInfo
->active_page
);
1735 if (psInfo
->active_page
< 0)
1738 psn
.hdr
.code
= PSN_WIZFINISH
;
1739 psn
.hdr
.hwndFrom
= hwndDlg
;
1743 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1745 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1747 TRACE("msg result %ld\n", msgResult
);
1752 if (psInfo
->isModeless
)
1753 psInfo
->activeValid
= FALSE
;
1756 psInfo
->ended
= TRUE
;
1757 psInfo
->returned
= 1;
1763 /******************************************************************************
1766 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1771 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1774 TRACE("active_page %d\n", psInfo
->active_page
);
1775 if (psInfo
->active_page
< 0)
1778 psn
.hdr
.hwndFrom
= hwndDlg
;
1784 * Send PSN_KILLACTIVE to the current page.
1786 psn
.hdr
.code
= PSN_KILLACTIVE
;
1788 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1790 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1794 * Send PSN_APPLY to all pages.
1796 psn
.hdr
.code
= PSN_APPLY
;
1797 psn
.lParam
= lParam
;
1799 for (i
= 0; i
< psInfo
->nPages
; i
++)
1801 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1804 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1806 case PSNRET_INVALID
:
1807 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1809 case PSNRET_INVALID_NOCHANGEPAGE
:
1817 psInfo
->activeValid
= FALSE
;
1819 else if(psInfo
->active_page
>= 0)
1821 psn
.hdr
.code
= PSN_SETACTIVE
;
1823 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1824 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1830 /******************************************************************************
1833 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1835 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1841 TRACE("active_page %d\n", psInfo
->active_page
);
1842 if (psInfo
->active_page
< 0)
1845 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1846 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1847 psn
.hdr
.hwndFrom
= hwndDlg
;
1851 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1854 psn
.hdr
.code
= PSN_RESET
;
1855 psn
.lParam
= lParam
;
1857 for (i
= 0; i
< psInfo
->nPages
; i
++)
1859 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1862 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1865 if (psInfo
->isModeless
)
1867 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1868 psInfo
->activeValid
= FALSE
;
1872 psInfo
->ended
= TRUE
;
1873 psInfo
->returned
= 0;
1877 /******************************************************************************
1880 static void PROPSHEET_Help(HWND hwndDlg
)
1882 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1887 TRACE("active_page %d\n", psInfo
->active_page
);
1888 if (psInfo
->active_page
< 0)
1891 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1892 psn
.hdr
.code
= PSN_HELP
;
1893 psn
.hdr
.hwndFrom
= hwndDlg
;
1897 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1900 /******************************************************************************
1903 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1906 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1910 if (!psInfo
) return;
1912 * Set the dirty flag of this page.
1914 for (i
= 0; i
< psInfo
->nPages
; i
++)
1916 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1917 psInfo
->proppage
[i
].isDirty
= TRUE
;
1921 * Enable the Apply button.
1923 if (psInfo
->hasApply
)
1925 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1927 EnableWindow(hwndApplyBtn
, TRUE
);
1931 /******************************************************************************
1932 * PROPSHEET_UnChanged
1934 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1937 BOOL noPageDirty
= TRUE
;
1938 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1939 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1943 if ( !psInfo
) return;
1944 for (i
= 0; i
< psInfo
->nPages
; i
++)
1946 /* set the specified page as clean */
1947 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1948 psInfo
->proppage
[i
].isDirty
= FALSE
;
1950 /* look to see if there's any dirty pages */
1951 if (psInfo
->proppage
[i
].isDirty
)
1952 noPageDirty
= FALSE
;
1956 * Disable Apply button.
1959 EnableWindow(hwndApplyBtn
, FALSE
);
1962 /******************************************************************************
1963 * PROPSHEET_PressButton
1965 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1967 TRACE("buttonID %d\n", buttonID
);
1970 case PSBTN_APPLYNOW
:
1971 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1974 PROPSHEET_Back(hwndDlg
);
1977 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1980 PROPSHEET_Finish(hwndDlg
);
1983 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1986 PROPSHEET_Next(hwndDlg
);
1989 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1992 FIXME("Invalid button index %d\n", buttonID
);
1997 /*************************************************************************
1998 * BOOL PROPSHEET_CanSetCurSel [Internal]
2000 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
2003 * hwndDlg [I] handle to a Dialog hWnd
2006 * TRUE if Current Selection can change
2010 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
2012 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2018 TRACE("active_page %d\n", psInfo
->active_page
);
2025 if (psInfo
->active_page
< 0)
2032 * Notify the current page.
2034 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
2035 psn
.hdr
.code
= PSN_KILLACTIVE
;
2036 psn
.hdr
.hwndFrom
= hwndDlg
;
2040 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2043 TRACE("<-- %d\n", res
);
2047 /******************************************************************************
2048 * PROPSHEET_SetCurSel
2050 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
2053 HPROPSHEETPAGE hpage
2056 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2057 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
2058 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2060 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
2061 /* hpage takes precedence over index */
2063 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2065 if (index
< 0 || index
>= psInfo
->nPages
)
2067 TRACE("Could not find page to select!\n");
2075 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2078 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
2080 psn
.hdr
.code
= PSN_SETACTIVE
;
2081 psn
.hdr
.hwndFrom
= hwndDlg
;
2085 if (!psInfo
->proppage
[index
].hwndPage
) {
2086 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
2089 /* Resize the property sheet page to the fit in the Tab control
2090 * (for regular property sheets) or to fit in the client area (for
2092 * NOTE: The resizing happens every time the page is selected and
2093 * not only when it's created (some applications depend on it). */
2094 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2095 TRACE("setting page %p, rc (%ld,%ld)-(%ld,%ld) w=%ld, h=%ld\n",
2096 psInfo
->proppage
[index
].hwndPage
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
2097 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2098 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2100 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2102 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2109 WARN("Tried to skip before first property sheet page!\n");
2112 if (index
>= psInfo
->nPages
) {
2113 WARN("Tried to skip after last property sheet page!\n");
2114 index
= psInfo
->nPages
-1;
2118 else if (result
!= 0)
2120 int old_index
= index
;
2121 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2122 if(index
>= psInfo
->nPages
) {
2124 WARN("Tried to skip to nonexistant page by res id\n");
2131 * Display the new page.
2133 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2135 if (psInfo
->proppage
[index
].hasHelp
)
2136 EnableWindow(hwndHelp
, TRUE
);
2138 EnableWindow(hwndHelp
, FALSE
);
2143 /******************************************************************************
2144 * PROPSHEET_SetCurSelId
2146 * Selects the page, specified by resource id.
2148 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2151 PropSheetInfo
* psInfo
=
2152 (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2154 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2155 if (idx
< psInfo
->nPages
)
2157 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2158 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2162 /******************************************************************************
2163 * PROPSHEET_SetTitleA
2165 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2167 if(HIWORD(lpszText
))
2170 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2171 szTitle
, sizeof(szTitle
)/sizeof(WCHAR
));
2172 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2176 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2180 /******************************************************************************
2181 * PROPSHEET_SetTitleW
2183 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2185 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2188 TRACE("'%s' (style %08lx)\n", debugstr_w(lpszText
), dwStyle
);
2189 if (HIWORD(lpszText
) == 0) {
2190 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2191 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)-sizeof(WCHAR
)))
2195 if (dwStyle
& PSH_PROPTITLE
)
2198 int lentitle
= strlenW(lpszText
);
2199 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2201 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2202 strcpyW(dest
, psInfo
->strPropertiesFor
);
2203 strcatW(dest
, lpszText
);
2205 SetWindowTextW(hwndDlg
, dest
);
2209 SetWindowTextW(hwndDlg
, lpszText
);
2212 /******************************************************************************
2213 * PROPSHEET_SetFinishTextA
2215 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2217 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2218 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2220 TRACE("'%s'\n", lpszText
);
2221 /* Set text, show and enable the Finish button */
2222 SetWindowTextA(hwndButton
, lpszText
);
2223 ShowWindow(hwndButton
, SW_SHOW
);
2224 EnableWindow(hwndButton
, TRUE
);
2226 /* Make it default pushbutton */
2227 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2229 /* Hide Back button */
2230 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2231 ShowWindow(hwndButton
, SW_HIDE
);
2233 if (!psInfo
->hasFinish
)
2235 /* Hide Next button */
2236 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2237 ShowWindow(hwndButton
, SW_HIDE
);
2241 /******************************************************************************
2242 * PROPSHEET_SetFinishTextW
2244 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2246 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2247 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2249 TRACE("'%s'\n", debugstr_w(lpszText
));
2250 /* Set text, show and enable the Finish button */
2251 SetWindowTextW(hwndButton
, lpszText
);
2252 ShowWindow(hwndButton
, SW_SHOW
);
2253 EnableWindow(hwndButton
, TRUE
);
2255 /* Make it default pushbutton */
2256 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2258 /* Hide Back button */
2259 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2260 ShowWindow(hwndButton
, SW_HIDE
);
2262 if (!psInfo
->hasFinish
)
2264 /* Hide Next button */
2265 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2266 ShowWindow(hwndButton
, SW_HIDE
);
2270 /******************************************************************************
2271 * PROPSHEET_QuerySiblings
2273 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2274 WPARAM wParam
, LPARAM lParam
)
2278 LRESULT msgResult
= 0;
2279 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2281 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2283 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2284 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2292 /******************************************************************************
2295 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
2296 HPROPSHEETPAGE hpage
)
2299 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2301 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2303 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2305 TRACE("hpage %p\n", hpage
);
2307 * Allocate and fill in a new PropPageInfo entry.
2309 ppi
= (PropPageInfo
*) ReAlloc(psInfo
->proppage
,
2310 sizeof(PropPageInfo
) *
2311 (psInfo
->nPages
+ 1));
2315 psInfo
->proppage
= ppi
;
2316 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, psInfo
->nPages
))
2319 psInfo
->proppage
[psInfo
->nPages
].hpage
= hpage
;
2321 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2323 /* Create the page but don't show it */
2324 PROPSHEET_CreatePage(hwndDlg
, psInfo
->nPages
, psInfo
, ppsp
);
2328 * Add a new tab to the tab control.
2330 item
.mask
= TCIF_TEXT
;
2331 item
.pszText
= (LPWSTR
) psInfo
->proppage
[psInfo
->nPages
].pszText
;
2332 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2334 if (psInfo
->hImageList
)
2336 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2339 if ( psInfo
->proppage
[psInfo
->nPages
].hasIcon
)
2341 item
.mask
|= TCIF_IMAGE
;
2342 item
.iImage
= psInfo
->nPages
;
2345 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, psInfo
->nPages
+ 1,
2350 /* If it is the only page - show it */
2351 if(psInfo
->nPages
== 1)
2352 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2356 /******************************************************************************
2357 * PROPSHEET_RemovePage
2359 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2361 HPROPSHEETPAGE hpage
)
2363 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2365 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2366 PropPageInfo
* oldPages
;
2368 TRACE("index %d, hpage %p\n", index
, hpage
);
2373 * hpage takes precedence over index.
2377 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2380 /* Make sure that index is within range */
2381 if (index
< 0 || index
>= psInfo
->nPages
)
2383 TRACE("Could not find page to remove!\n");
2387 TRACE("total pages %d removing page %d active page %d\n",
2388 psInfo
->nPages
, index
, psInfo
->active_page
);
2390 * Check if we're removing the active page.
2392 if (index
== psInfo
->active_page
)
2394 if (psInfo
->nPages
> 1)
2398 /* activate previous page */
2399 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2403 /* activate the next page */
2404 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2405 psInfo
->active_page
= index
;
2410 psInfo
->active_page
= -1;
2411 if (!psInfo
->isModeless
)
2413 psInfo
->ended
= TRUE
;
2414 psInfo
->returned
= 0;
2419 else if (index
< psInfo
->active_page
)
2420 psInfo
->active_page
--;
2422 /* Unsubclass the page dialog window */
2423 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2424 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2425 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2427 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2428 PROPSHEET_WizardSubclassProc
, 1);
2431 /* Destroy page dialog window */
2432 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2434 /* Free page resources */
2435 if(psInfo
->proppage
[index
].hpage
)
2437 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2439 if ((psp
->dwFlags
& PSP_USETITLE
) && psInfo
->proppage
[index
].pszText
)
2440 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2442 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2445 /* Remove the tab */
2446 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2448 oldPages
= psInfo
->proppage
;
2450 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2453 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2455 if (index
< psInfo
->nPages
)
2456 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2457 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2464 /******************************************************************************
2465 * PROPSHEET_SetWizButtons
2467 * This code will work if (and assumes that) the Next button is on top of the
2468 * Finish button. ie. Finish comes after Next in the Z order.
2469 * This means make sure the dialog template reflects this.
2472 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2474 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2476 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2477 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2478 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2480 TRACE("%ld\n", dwFlags
);
2482 EnableWindow(hwndBack
, FALSE
);
2483 EnableWindow(hwndNext
, FALSE
);
2484 EnableWindow(hwndFinish
, FALSE
);
2486 if (dwFlags
& PSWIZB_BACK
)
2487 EnableWindow(hwndBack
, TRUE
);
2489 if (dwFlags
& PSWIZB_NEXT
)
2491 if (!psInfo
->hasFinish
)
2493 /* Hide the Finish button */
2494 ShowWindow(hwndFinish
, SW_HIDE
);
2497 /* Show and enable the Next button */
2498 ShowWindow(hwndNext
, SW_SHOW
);
2499 EnableWindow(hwndNext
, TRUE
);
2501 /* Set the Next button as the default pushbutton */
2502 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2505 if (!psInfo
->hasFinish
)
2507 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2509 /* Hide the Next button */
2510 ShowWindow(hwndNext
, SW_HIDE
);
2512 /* Show the Finish button */
2513 ShowWindow(hwndFinish
, SW_SHOW
);
2515 if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2517 EnableWindow(hwndFinish
, TRUE
);
2519 /* Set the Finish button as the default pushbutton */
2520 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2524 else if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2525 EnableWindow(hwndFinish
, TRUE
);
2528 /******************************************************************************
2529 * PROPSHEET_InsertPage
2531 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2533 if (!HIWORD(hpageInsertAfter
))
2534 FIXME("(%p, %d, %p): stub\n", hwndDlg
, LOWORD(hpageInsertAfter
), hpage
);
2536 FIXME("(%p, %p, %p): stub\n", hwndDlg
, hpageInsertAfter
, hpage
);
2540 /******************************************************************************
2541 * PROPSHEET_SetHeaderTitleW
2543 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderTitle
)
2545 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderTitle
));
2548 /******************************************************************************
2549 * PROPSHEET_SetHeaderTitleA
2551 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderTitle
)
2553 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderTitle
));
2556 /******************************************************************************
2557 * PROPSHEET_SetHeaderSubTitleW
2559 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderSubTitle
)
2561 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderSubTitle
));
2564 /******************************************************************************
2565 * PROPSHEET_SetHeaderSubTitleA
2567 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderSubTitle
)
2569 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderSubTitle
));
2572 /******************************************************************************
2573 * PROPSHEET_HwndToIndex
2575 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2578 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2581 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2583 for (index
= 0; index
< psInfo
->nPages
; index
++)
2584 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2586 WARN("%p not found\n", hPageDlg
);
2590 /******************************************************************************
2591 * PROPSHEET_IndexToHwnd
2593 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2595 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2597 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2598 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2599 WARN("%d out of range.\n", iPageIndex
);
2602 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2605 /******************************************************************************
2606 * PROPSHEET_PageToIndex
2608 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2611 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2614 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2616 for (index
= 0; index
< psInfo
->nPages
; index
++)
2617 if (psInfo
->proppage
[index
].hpage
== hPage
)
2619 WARN("%p not found\n", hPage
);
2623 /******************************************************************************
2624 * PROPSHEET_IndexToPage
2626 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2628 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2630 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2631 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2632 WARN("%d out of range.\n", iPageIndex
);
2635 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2638 /******************************************************************************
2639 * PROPSHEET_IdToIndex
2641 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2644 LPCPROPSHEETPAGEW psp
;
2645 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2647 TRACE("(%p, %d)\n", hwndDlg
, iPageId
);
2648 for (index
= 0; index
< psInfo
->nPages
; index
++) {
2649 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2650 if (psp
->u
.pszTemplate
== MAKEINTRESOURCEW(iPageId
))
2657 /******************************************************************************
2658 * PROPSHEET_IndexToId
2660 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2662 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2664 LPCPROPSHEETPAGEW psp
;
2665 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2666 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2667 WARN("%d out of range.\n", iPageIndex
);
2670 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2671 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| HIWORD(psp
->u
.pszTemplate
)) {
2674 return (LRESULT
)psp
->u
.pszTemplate
;
2677 /******************************************************************************
2678 * PROPSHEET_GetResult
2680 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2682 FIXME("(%p): stub\n", hwndDlg
);
2686 /******************************************************************************
2687 * PROPSHEET_RecalcPageSizes
2689 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2691 FIXME("(%p): stub\n", hwndDlg
);
2695 /******************************************************************************
2696 * PROPSHEET_GetPageIndex
2698 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2699 * the array of PropPageInfo.
2701 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, PropSheetInfo
* psInfo
)
2706 TRACE("hpage %p\n", hpage
);
2707 while ((index
< psInfo
->nPages
) && (found
== FALSE
))
2709 if (psInfo
->proppage
[index
].hpage
== hpage
)
2721 /******************************************************************************
2724 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2727 PropSheetInfo
* psInfo
= (PropSheetInfo
*) RemovePropW(hwndDlg
,
2731 if (!psInfo
) return;
2732 if (HIWORD(psInfo
->ppshheader
.pszCaption
))
2733 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2735 for (i
= 0; i
< psInfo
->nPages
; i
++)
2737 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2739 /* Unsubclass the page dialog window */
2740 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2741 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2742 (psp
->dwFlags
& PSP_HIDEHEADER
))
2744 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2745 PROPSHEET_WizardSubclassProc
, 1);
2748 if(psInfo
->proppage
[i
].hwndPage
)
2749 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2753 if ((psp
->dwFlags
& PSP_USETITLE
) && psInfo
->proppage
[i
].pszText
)
2754 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2756 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2760 DeleteObject(psInfo
->hFont
);
2761 DeleteObject(psInfo
->hFontBold
);
2762 /* If we created the bitmaps, destroy them */
2763 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2764 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2765 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2766 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2767 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2768 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2770 Free(psInfo
->proppage
);
2771 Free(psInfo
->strPropertiesFor
);
2772 ImageList_Destroy(psInfo
->hImageList
);
2774 GlobalFree((HGLOBAL
)psInfo
);
2777 static INT
do_loop(PropSheetInfo
*psInfo
)
2781 HWND hwnd
= psInfo
->hwnd
;
2783 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2788 if(!IsDialogMessageW(hwnd
, &msg
))
2790 TranslateMessage(&msg
);
2791 DispatchMessageW(&msg
);
2798 PostQuitMessage(msg
.wParam
);
2802 if (psInfo
->ended
&& ret
> 0)
2803 ret
= psInfo
->returned
;
2805 DestroyWindow(hwnd
);
2809 /******************************************************************************
2810 * PropertySheet (COMCTL32.@)
2811 * PropertySheetA (COMCTL32.@)
2813 * Creates a property sheet in the specified property sheet header.
2816 * Modal property sheets: Positive if successful or -1 otherwise.
2817 * Modeless property sheets: Property sheet handle.
2819 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2820 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2822 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2825 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2826 sizeof(PropSheetInfo
));
2830 TRACE("(%p)\n", lppsh
);
2832 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2834 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2836 pByte
= (BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2838 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2840 if (!(lppsh
->dwFlags
& PSH_PROPSHEETPAGE
))
2841 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2844 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2845 pByte
+= ((LPPROPSHEETPAGEA
)pByte
)->dwSize
;
2848 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2851 if (lppsh
->dwFlags
& PSH_PROPSHEETPAGE
)
2852 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2858 psInfo
->unicode
= FALSE
;
2859 psInfo
->ended
= FALSE
;
2861 bRet
= PROPSHEET_CreateDialog(psInfo
);
2862 if(!psInfo
->isModeless
)
2863 bRet
= do_loop(psInfo
);
2868 /******************************************************************************
2869 * PropertySheetW (COMCTL32.@)
2871 * See PropertySheetA.
2873 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2876 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2877 sizeof(PropSheetInfo
));
2881 TRACE("(%p)\n", lppsh
);
2883 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2885 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2887 pByte
= (BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2889 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2891 if (!(lppsh
->dwFlags
& PSH_PROPSHEETPAGE
))
2892 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2895 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2896 pByte
+= ((LPPROPSHEETPAGEW
)pByte
)->dwSize
;
2899 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2902 if (lppsh
->dwFlags
& PSH_PROPSHEETPAGE
)
2903 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2909 psInfo
->unicode
= TRUE
;
2910 psInfo
->ended
= FALSE
;
2912 bRet
= PROPSHEET_CreateDialog(psInfo
);
2913 if(!psInfo
->isModeless
)
2914 bRet
= do_loop(psInfo
);
2919 /******************************************************************************
2920 * CreatePropertySheetPage (COMCTL32.@)
2921 * CreatePropertySheetPageA (COMCTL32.@)
2923 * Creates a new property sheet page.
2926 * Success: Handle to new property sheet page.
2930 * An application must use the PSM_ADDPAGE message to add the new page to
2931 * an existing property sheet.
2933 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2934 LPCPROPSHEETPAGEA lpPropSheetPage
)
2936 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2938 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEA
)));
2940 ppsp
->dwFlags
&= ~ PSP_INTERNAL_UNICODE
;
2941 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( ppsp
->u
.pszTemplate
) )
2943 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
);
2945 ppsp
->u
.pszTemplate
= Alloc( len
+1 );
2946 strcpy( (LPSTR
)ppsp
->u
.pszTemplate
, lpPropSheetPage
->u
.pszTemplate
);
2948 if ( (ppsp
->dwFlags
& PSP_USEICONID
) && HIWORD( ppsp
->u2
.pszIcon
) )
2950 PROPSHEET_AtoW(&ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2953 if ((ppsp
->dwFlags
& PSP_USETITLE
) && HIWORD( ppsp
->pszTitle
))
2955 PROPSHEET_AtoW(&ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2957 else if ( !(ppsp
->dwFlags
& PSP_USETITLE
) )
2958 ppsp
->pszTitle
= NULL
;
2960 return (HPROPSHEETPAGE
)ppsp
;
2963 /******************************************************************************
2964 * CreatePropertySheetPageW (COMCTL32.@)
2966 * See CreatePropertySheetA.
2968 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
2970 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2972 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEW
)));
2974 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
2976 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( ppsp
->u
.pszTemplate
) )
2978 int len
= strlenW(lpPropSheetPage
->u
.pszTemplate
);
2980 ppsp
->u
.pszTemplate
= Alloc( (len
+1)*sizeof (WCHAR
) );
2981 strcpyW( (WCHAR
*)ppsp
->u
.pszTemplate
, lpPropSheetPage
->u
.pszTemplate
);
2983 if ( (ppsp
->dwFlags
& PSP_USEICONID
) && HIWORD( ppsp
->u2
.pszIcon
) )
2985 int len
= strlenW(lpPropSheetPage
->u2
.pszIcon
);
2986 ppsp
->u2
.pszIcon
= Alloc( (len
+1)*sizeof (WCHAR
) );
2987 strcpyW( (WCHAR
*)ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2990 if ((ppsp
->dwFlags
& PSP_USETITLE
) && HIWORD( ppsp
->pszTitle
))
2992 int len
= strlenW(lpPropSheetPage
->pszTitle
);
2993 ppsp
->pszTitle
= Alloc( (len
+1)*sizeof (WCHAR
) );
2994 strcpyW( (WCHAR
*)ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2996 else if ( !(ppsp
->dwFlags
& PSP_USETITLE
) )
2997 ppsp
->pszTitle
= NULL
;
2999 return (HPROPSHEETPAGE
)ppsp
;
3002 /******************************************************************************
3003 * DestroyPropertySheetPage (COMCTL32.@)
3005 * Destroys a property sheet page previously created with
3006 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
3013 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
3015 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3020 if ( !(psp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( psp
->u
.pszTemplate
) )
3021 Free ((LPVOID
)psp
->u
.pszTemplate
);
3023 if ( (psp
->dwFlags
& PSP_USEICONID
) && HIWORD( psp
->u2
.pszIcon
) )
3024 Free ((LPVOID
)psp
->u2
.pszIcon
);
3026 if ((psp
->dwFlags
& PSP_USETITLE
) && HIWORD( psp
->pszTitle
))
3027 Free ((LPVOID
)psp
->pszTitle
);
3034 /******************************************************************************
3035 * PROPSHEET_IsDialogMessage
3037 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3039 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3042 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3045 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3048 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3050 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3052 switch (lpMsg
->wParam
)
3055 if (GetKeyState(VK_SHIFT
) & 0x8000)
3061 case VK_NEXT
: new_page
= 1; break;
3062 case VK_PRIOR
: new_page
= -1; break;
3068 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3070 new_page
+= psInfo
->active_page
;
3073 new_page
= psInfo
->nPages
- 1;
3074 else if (new_page
>= psInfo
->nPages
)
3077 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3084 return IsDialogMessageW(hwnd
, lpMsg
);
3087 /******************************************************************************
3088 * PROPSHEET_DoCommand
3090 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3096 case IDC_APPLY_BUTTON
:
3098 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3100 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3105 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3109 if (psInfo
->restartWindows
)
3110 result
= ID_PSRESTARTWINDOWS
;
3112 /* reboot system takes precedence over restart windows */
3113 if (psInfo
->rebootSystem
)
3114 result
= ID_PSREBOOTSYSTEM
;
3116 if (psInfo
->isModeless
)
3117 psInfo
->activeValid
= FALSE
;
3120 psInfo
->ended
= TRUE
;
3121 psInfo
->returned
= 1;
3125 EnableWindow(hwndApplyBtn
, FALSE
);
3130 case IDC_BACK_BUTTON
:
3131 PROPSHEET_Back(hwnd
);
3134 case IDC_NEXT_BUTTON
:
3135 PROPSHEET_Next(hwnd
);
3138 case IDC_FINISH_BUTTON
:
3139 PROPSHEET_Finish(hwnd
);
3143 PROPSHEET_Cancel(hwnd
, 0);
3147 PROPSHEET_Help(hwnd
);
3157 /******************************************************************************
3160 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3162 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3167 HPALETTE hOldPal
= 0;
3171 LPCPROPSHEETPAGEW ppshpage
;
3172 WCHAR szBuffer
[256];
3175 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3178 hdcSrc
= CreateCompatibleDC(0);
3179 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3181 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3182 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3184 if ( (!(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3185 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3186 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3188 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3190 COLORREF clrOld
= 0;
3193 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3194 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3196 GetClientRect(hwndLineHeader
, &r
);
3197 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3198 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3200 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), (LPVOID
)&bm
);
3202 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3204 /* Fill the unoccupied part of the header with color of the
3205 * left-top pixel, but do it only when needed.
3207 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3209 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3210 CopyRect(&r
, &rzone
);
3211 if (bm
.bmWidth
< r
.right
)
3213 r
.left
= bm
.bmWidth
;
3214 FillRect(hdc
, &r
, hbr
);
3216 if (bm
.bmHeight
< r
.bottom
)
3219 r
.top
= bm
.bmHeight
;
3220 FillRect(hdc
, &r
, hbr
);
3225 /* Draw the header itself. */
3227 bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3228 hdcSrc
, 0, 0, SRCCOPY
);
3232 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3233 FillRect(hdc
, &rzone
, hbr
);
3235 /* Draw the header bitmap. It's always centered like a
3236 * common 49 x 49 bitmap. */
3237 BitBlt(hdc
, rzone
.right
- 49 - ((rzone
.bottom
- 49) / 2),
3238 (rzone
.bottom
- 49) / 2,
3239 bm
.bmWidth
, bm
.bmHeight
,
3240 hdcSrc
, 0, 0, SRCCOPY
);
3242 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3243 * if its height is smaller than 49 pixels. Because the reason
3244 * for this bug is unknown the current code doesn't try to
3248 clrOld
= SetTextColor (hdc
, 0x00000000);
3249 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3251 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3252 SetRect(&r
, 20, 10, 0, 0);
3253 if (HIWORD(ppshpage
->pszHeaderTitle
))
3255 if (psInfo
->unicode
)
3256 DrawTextW(hdc
, (LPWSTR
)ppshpage
->pszHeaderTitle
,
3257 -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3259 DrawTextA(hdc
, (LPCSTR
)ppshpage
->pszHeaderTitle
,
3260 -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3264 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderTitle
,
3268 DrawTextW(hdc
, szBuffer
, nLength
,
3269 &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3274 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3275 SelectObject(hdc
, psInfo
->hFont
);
3276 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3277 if (HIWORD(ppshpage
->pszHeaderTitle
))
3279 if (psInfo
->unicode
)
3280 DrawTextW(hdc
, (LPWSTR
)ppshpage
->pszHeaderSubTitle
,
3281 -1, &r
, DT_LEFT
| DT_SINGLELINE
);
3283 DrawTextA(hdc
, (LPCSTR
)ppshpage
->pszHeaderSubTitle
,
3284 -1, &r
, DT_LEFT
| DT_SINGLELINE
);
3288 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderSubTitle
,
3292 DrawTextW(hdc
, szBuffer
, nLength
,
3293 &r
, DT_LEFT
| DT_SINGLELINE
);
3298 offsety
= rzone
.bottom
+ 2;
3300 SetTextColor(hdc
, clrOld
);
3301 SetBkMode(hdc
, oldBkMode
);
3302 SelectObject(hdc
, hOldFont
);
3303 SelectObject(hdcSrc
, hbmp
);
3306 if ( (ppshpage
->dwFlags
& PSP_HIDEHEADER
) &&
3307 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3308 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3310 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3312 GetClientRect(hwndLine
, &r
);
3313 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3317 rzone
.right
= r
.right
;
3318 rzone
.bottom
= r
.top
- 1;
3320 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3321 FillRect(hdc
, &rzone
, hbr
);
3323 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), (LPVOID
)&bm
);
3324 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3326 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3327 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3329 /* If the bitmap is not big enough, fill the remaining area
3330 with the color of pixel (0,0) of bitmap - see MSDN */
3331 if (r
.top
> bm
.bmHeight
) {
3332 r
.bottom
= r
.top
- 1;
3333 r
.top
= bm
.bmHeight
;
3335 r
.right
= bm
.bmWidth
;
3336 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3337 FillRect(hdc
, &r
, hbr
);
3341 SelectObject(hdcSrc
, hbmp
);
3344 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3345 SelectPalette(hdc
, hOldPal
, FALSE
);
3349 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3354 /******************************************************************************
3355 * PROPSHEET_DialogProc
3358 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3360 TRACE("hwnd=%p msg=0x%04x wparam=%x lparam=%lx\n",
3361 hwnd
, uMsg
, wParam
, lParam
);
3367 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3368 WCHAR
* strCaption
= (WCHAR
*)Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3369 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3370 LPCPROPSHEETPAGEW ppshpage
;
3374 /* Using PropSheetInfoStr to store extra data doesn't match the native
3375 * common control: native uses TCM_[GS]ETITEM
3377 SetPropW(hwnd
, PropSheetInfoStr
, (HANDLE
)psInfo
);
3380 * psInfo->hwnd is not being used by WINE code - it exists
3381 * for compatibility with "real" Windoze. The same about
3382 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3385 psInfo
->hwnd
= hwnd
;
3386 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3388 /* set up the Next and Back buttons by default */
3389 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3392 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3393 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3394 logFont
.lfWeight
= FW_BOLD
;
3395 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3398 * Small icon in the title bar.
3400 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3401 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3404 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3405 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3407 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3408 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3409 psInfo
->ppshheader
.u
.pszIcon
,
3414 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3416 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3419 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3420 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3422 psInfo
->strPropertiesFor
= strCaption
;
3424 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3426 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3428 PROPSHEET_LoadWizardBitmaps(psInfo
);
3430 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3432 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3433 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3434 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3438 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3440 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3441 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3445 if (psInfo
->useCallback
)
3446 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
,
3447 PSCB_INITIALIZED
, (LPARAM
)0);
3449 idx
= psInfo
->active_page
;
3450 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[idx
].hpage
;
3451 psInfo
->active_page
= -1;
3453 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3455 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3456 * as some programs call TCM_GETCURSEL to get the current selection
3457 * from which to switch to the next page */
3458 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3460 if (!HIWORD(psInfo
->ppshheader
.pszCaption
) &&
3461 psInfo
->ppshheader
.hInstance
)
3465 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3466 (UINT_PTR
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3467 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3471 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3472 psInfo
->ppshheader
.pszCaption
);
3478 case WM_PRINTCLIENT
:
3480 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3484 PROPSHEET_CleanUp(hwnd
);
3488 PROPSHEET_Cancel(hwnd
, 1);
3492 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3494 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3499 /* No default handler, forward notification to active page */
3500 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3502 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3503 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3509 switch(wParam
& 0xfff0)
3512 PROPSHEET_Cancel(hwnd
, 1);
3521 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3523 if (pnmh
->code
== TCN_SELCHANGE
)
3525 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3526 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3529 if(pnmh
->code
== TCN_SELCHANGING
)
3531 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3532 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3539 case WM_SYSCOLORCHANGE
:
3540 COMCTL32_RefreshSysColors();
3543 case PSM_GETCURRENTPAGEHWND
:
3545 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3552 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3553 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3555 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3561 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3565 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3568 case PSM_GETTABCONTROL
:
3570 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3572 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3581 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3582 if(msgResult
!= FALSE
)
3584 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3587 (HPROPSHEETPAGE
)lParam
);
3590 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3595 case PSM_CANCELTOCLOSE
:
3597 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3598 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3599 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3601 EnableWindow(hwndCancel
, FALSE
);
3602 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, sizeof(buf
)))
3603 SetWindowTextW(hwndOK
, buf
);
3608 case PSM_RESTARTWINDOWS
:
3610 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3616 psInfo
->restartWindows
= TRUE
;
3620 case PSM_REBOOTSYSTEM
:
3622 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3628 psInfo
->rebootSystem
= TRUE
;
3633 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3637 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3642 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3644 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3649 case PSM_QUERYSIBLINGS
:
3651 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3653 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3661 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3662 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3663 * on success or FALSE otherwise, as specified on MSDN Online.
3664 * Also see the MFC code for
3665 * CPropertySheet::AddPage(CPropertyPage* pPage).
3668 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3670 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3675 case PSM_REMOVEPAGE
:
3676 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3679 case PSM_ISDIALOGMESSAGE
:
3681 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3682 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3686 case PSM_PRESSBUTTON
:
3687 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3690 case PSM_SETFINISHTEXTA
:
3691 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3694 case PSM_SETWIZBUTTONS
:
3695 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3698 case PSM_SETCURSELID
:
3699 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3702 case PSM_SETFINISHTEXTW
:
3703 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3706 case PSM_INSERTPAGE
:
3708 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3709 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3713 case PSM_SETHEADERTITLEW
:
3714 PROPSHEET_SetHeaderTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3717 case PSM_SETHEADERTITLEA
:
3718 PROPSHEET_SetHeaderTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3721 case PSM_SETHEADERSUBTITLEW
:
3722 PROPSHEET_SetHeaderSubTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3725 case PSM_SETHEADERSUBTITLEA
:
3726 PROPSHEET_SetHeaderSubTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3729 case PSM_HWNDTOINDEX
:
3731 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3732 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3736 case PSM_INDEXTOHWND
:
3738 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3739 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3743 case PSM_PAGETOINDEX
:
3745 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3746 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3750 case PSM_INDEXTOPAGE
:
3752 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3753 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3759 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3760 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3766 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3767 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3773 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3774 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3778 case PSM_RECALCPAGESIZES
:
3780 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3781 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);