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
;
143 /******************************************************************************
144 * Defines and global variables
147 const WCHAR PropSheetInfoStr
[] =
148 {'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0 };
150 #define PSP_INTERNAL_UNICODE 0x80000000
152 #define MAX_CAPTION_LENGTH 255
153 #define MAX_TABTEXT_LENGTH 255
154 #define MAX_BUTTONTEXT_LENGTH 64
156 #define INTRNL_ANY_WIZARD (PSH_WIZARD | PSH_WIZARD97_OLD | PSH_WIZARD97_NEW | PSH_WIZARD_LITE)
158 /* Wizard metrics specified in DLUs */
159 #define WIZARD_PADDING 7
160 #define WIZARD_HEADER_HEIGHT 36
162 /******************************************************************************
165 static INT_PTR
PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
);
166 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, PropSheetInfo
* psInfo
);
167 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
);
168 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, PropSheetInfo
* psInfo
);
169 static BOOL
PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh
,
170 PropSheetInfo
* psInfo
);
171 static BOOL
PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
172 PropSheetInfo
* psInfo
);
173 static BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
174 PropSheetInfo
* psInfo
,
176 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
177 PropSheetInfo
* psInfo
);
178 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
, int index
,
179 const PropSheetInfo
* psInfo
,
180 LPCPROPSHEETPAGEW ppshpage
);
181 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
);
182 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
);
183 static BOOL
PROPSHEET_Back(HWND hwndDlg
);
184 static BOOL
PROPSHEET_Next(HWND hwndDlg
);
185 static BOOL
PROPSHEET_Finish(HWND hwndDlg
);
186 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
);
187 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
);
188 static void PROPSHEET_Help(HWND hwndDlg
);
189 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
);
190 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
);
191 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
);
192 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
);
193 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
);
194 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
);
195 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
);
196 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
);
197 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
200 HPROPSHEETPAGE hpage
);
201 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
);
202 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
203 WPARAM wParam
, LPARAM lParam
);
204 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
205 HPROPSHEETPAGE hpage
);
207 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
209 HPROPSHEETPAGE hpage
);
210 static void PROPSHEET_CleanUp(HWND hwndDlg
);
211 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, PropSheetInfo
* psInfo
);
212 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
);
213 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
);
214 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
);
215 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
);
218 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
220 WINE_DEFAULT_DEBUG_CHANNEL(propsheet
);
222 #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");}
223 /******************************************************************************
224 * PROPSHEET_UnImplementedFlags
226 * Document use of flags we don't implement yet.
228 static VOID
PROPSHEET_UnImplementedFlags(DWORD dwFlags
)
235 * unhandled header flags:
236 * PSH_RTLREADING 0x00000800
237 * PSH_STRETCHWATERMARK 0x00040000
238 * PSH_USEPAGELANG 0x00200000
241 add_flag(PSH_RTLREADING
);
242 add_flag(PSH_STRETCHWATERMARK
);
243 add_flag(PSH_USEPAGELANG
);
244 if (string
[0] != '\0')
245 FIXME("%s\n", string
);
249 /******************************************************************************
250 * PROPSHEET_GetPageRect
252 * Retrieve rect from tab control and map into the dialog for SetWindowPos
254 static void PROPSHEET_GetPageRect(const PropSheetInfo
* psInfo
, HWND hwndDlg
,
255 RECT
*rc
, LPCPROPSHEETPAGEW ppshpage
)
257 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) {
261 if (((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
262 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
263 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) ||
264 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
))
266 rc
->left
= rc
->top
= WIZARD_PADDING
;
270 rc
->left
= rc
->top
= 0;
272 rc
->right
= psInfo
->width
- rc
->left
;
273 rc
->bottom
= psInfo
->height
- rc
->top
;
274 MapDialogRect(hwndDlg
, rc
);
276 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
277 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
278 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
))
280 hwndChild
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
281 GetClientRect(hwndChild
, &r
);
282 MapWindowPoints(hwndChild
, hwndDlg
, (LPPOINT
) &r
, 2);
283 rc
->top
+= r
.bottom
+ 1;
286 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
287 GetClientRect(hwndTabCtrl
, rc
);
288 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)rc
);
289 MapWindowPoints(hwndTabCtrl
, hwndDlg
, (LPPOINT
)rc
, 2);
293 /******************************************************************************
294 * PROPSHEET_FindPageByResId
296 * Find page index corresponding to page resource id.
298 static INT
PROPSHEET_FindPageByResId(PropSheetInfo
* psInfo
, LRESULT resId
)
302 for (i
= 0; i
< psInfo
->nPages
; i
++)
304 LPCPROPSHEETPAGEA lppsp
= (LPCPROPSHEETPAGEA
)psInfo
->proppage
[i
].hpage
;
306 /* Fixme: if resource ID is a string shall we use strcmp ??? */
307 if (lppsp
->u
.pszTemplate
== (LPVOID
)resId
)
314 /******************************************************************************
317 * Convert ASCII to Unicode since all data is saved as Unicode.
319 static void PROPSHEET_AtoW(LPCWSTR
*tostr
, LPCSTR frstr
)
323 TRACE("<%s>\n", frstr
);
324 len
= MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, 0, 0);
325 *tostr
= Alloc(len
* sizeof(WCHAR
));
326 MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, (LPWSTR
)*tostr
, len
);
329 /******************************************************************************
330 * PROPSHEET_CollectSheetInfoA
332 * Collect relevant data.
334 static BOOL
PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh
,
335 PropSheetInfo
* psInfo
)
337 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERA
));
338 DWORD dwFlags
= lppsh
->dwFlags
;
340 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
341 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
342 psInfo
->hasFinish
= dwFlags
& PSH_WIZARDHASFINISH
;
343 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
)&& (lppsh
->pfnCallback
);
344 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
346 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
347 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",
348 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
,
349 debugstr_a(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
351 PROPSHEET_UnImplementedFlags(lppsh
->dwFlags
);
353 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
354 psInfo
->ppshheader
.pszCaption
= NULL
;
357 if (HIWORD(lppsh
->pszCaption
))
359 int len
= MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, NULL
, 0);
360 psInfo
->ppshheader
.pszCaption
= Alloc( len
*sizeof (WCHAR
) );
361 MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, (LPWSTR
) psInfo
->ppshheader
.pszCaption
, len
);
364 psInfo
->nPages
= lppsh
->nPages
;
366 if (dwFlags
& PSH_USEPSTARTPAGE
)
368 TRACE("PSH_USEPSTARTPAGE is on\n");
369 psInfo
->active_page
= 0;
372 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
374 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
375 psInfo
->active_page
= 0;
377 psInfo
->restartWindows
= FALSE
;
378 psInfo
->rebootSystem
= FALSE
;
379 psInfo
->hImageList
= 0;
380 psInfo
->activeValid
= FALSE
;
385 /******************************************************************************
386 * PROPSHEET_CollectSheetInfoW
388 * Collect relevant data.
390 static BOOL
PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
391 PropSheetInfo
* psInfo
)
393 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERW
));
394 DWORD dwFlags
= lppsh
->dwFlags
;
396 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
397 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
398 psInfo
->hasFinish
= dwFlags
& PSH_WIZARDHASFINISH
;
399 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
) && (lppsh
->pfnCallback
);
400 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
402 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
403 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",
404 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
, debugstr_w(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
406 PROPSHEET_UnImplementedFlags(lppsh
->dwFlags
);
408 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
409 psInfo
->ppshheader
.pszCaption
= NULL
;
412 if (HIWORD(lppsh
->pszCaption
))
414 int len
= strlenW(lppsh
->pszCaption
);
415 psInfo
->ppshheader
.pszCaption
= Alloc( (len
+1)*sizeof(WCHAR
) );
416 strcpyW( (WCHAR
*)psInfo
->ppshheader
.pszCaption
, lppsh
->pszCaption
);
419 psInfo
->nPages
= lppsh
->nPages
;
421 if (dwFlags
& PSH_USEPSTARTPAGE
)
423 TRACE("PSH_USEPSTARTPAGE is on\n");
424 psInfo
->active_page
= 0;
427 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
429 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
430 psInfo
->active_page
= 0;
432 psInfo
->restartWindows
= FALSE
;
433 psInfo
->rebootSystem
= FALSE
;
434 psInfo
->hImageList
= 0;
435 psInfo
->activeValid
= FALSE
;
440 /******************************************************************************
441 * PROPSHEET_CollectPageInfo
443 * Collect property sheet data.
444 * With code taken from DIALOG_ParseTemplate32.
446 BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
447 PropSheetInfo
* psInfo
,
450 DLGTEMPLATE
* pTemplate
;
459 psInfo
->proppage
[index
].hpage
= (HPROPSHEETPAGE
)lppsp
;
460 psInfo
->proppage
[index
].hwndPage
= 0;
461 psInfo
->proppage
[index
].isDirty
= FALSE
;
464 * Process property page flags.
466 dwFlags
= lppsp
->dwFlags
;
467 psInfo
->proppage
[index
].useCallback
= (dwFlags
& PSP_USECALLBACK
) && (lppsp
->pfnCallback
);
468 psInfo
->proppage
[index
].hasHelp
= dwFlags
& PSP_HASHELP
;
469 psInfo
->proppage
[index
].hasIcon
= dwFlags
& (PSP_USEHICON
| PSP_USEICONID
);
471 /* as soon as we have a page with the help flag, set the sheet flag on */
472 if (psInfo
->proppage
[index
].hasHelp
)
473 psInfo
->hasHelp
= TRUE
;
476 * Process page template.
478 if (dwFlags
& PSP_DLGINDIRECT
)
479 pTemplate
= (DLGTEMPLATE
*)lppsp
->u
.pResource
;
480 else if(dwFlags
& PSP_INTERNAL_UNICODE
)
482 HRSRC hResource
= FindResourceW(lppsp
->hInstance
,
483 lppsp
->u
.pszTemplate
,
485 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
487 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
491 HRSRC hResource
= FindResourceA(lppsp
->hInstance
,
492 (LPSTR
)lppsp
->u
.pszTemplate
,
494 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
496 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
500 * Extract the size of the page and the caption.
505 p
= (const WORD
*)pTemplate
;
507 if (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
509 /* DLGTEMPLATEEX (not defined in any std. header file) */
513 p
+= 2; /* help ID */
514 p
+= 2; /* ext style */
522 p
+= 2; /* ext style */
528 width
= (WORD
)*p
; p
++;
529 height
= (WORD
)*p
; p
++;
531 /* Special calculation for interior wizard pages so the largest page is
532 * calculated correctly. We need to add all the padding and space occupied
533 * by the header so the width and height sums up to the whole wizard client
535 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
536 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
537 !(dwFlags
& PSP_HIDEHEADER
))
539 height
+= 2 * WIZARD_PADDING
+ WIZARD_HEADER_HEIGHT
;
540 width
+= 2 * WIZARD_PADDING
;
542 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
)
544 height
+= 2 * WIZARD_PADDING
;
545 width
+= 2 * WIZARD_PADDING
;
548 /* remember the largest width and height */
549 if (width
> psInfo
->width
)
550 psInfo
->width
= width
;
552 if (height
> psInfo
->height
)
553 psInfo
->height
= height
;
565 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
579 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
583 /* Extract the caption */
584 psInfo
->proppage
[index
].pszText
= (LPCWSTR
)p
;
585 TRACE("Tab %d %s\n",index
,debugstr_w((LPCWSTR
)p
));
586 p
+= lstrlenW((LPCWSTR
)p
) + 1;
588 if (dwFlags
& PSP_USETITLE
)
592 static const WCHAR pszNull
[] = { '(','n','u','l','l',')',0 };
595 if ( !HIWORD( lppsp
->pszTitle
) )
597 if (!LoadStringW( lppsp
->hInstance
, (DWORD_PTR
)lppsp
->pszTitle
,szTitle
,sizeof(szTitle
) ))
600 FIXME("Could not load resource #%04x?\n",LOWORD(lppsp
->pszTitle
));
606 pTitle
= lppsp
->pszTitle
;
608 len
= strlenW(pTitle
);
609 psInfo
->proppage
[index
].pszText
= Alloc( (len
+1)*sizeof (WCHAR
) );
610 strcpyW( (LPWSTR
)psInfo
->proppage
[index
].pszText
,pTitle
);
614 * Build the image list for icons
616 if ((dwFlags
& PSP_USEHICON
) || (dwFlags
& PSP_USEICONID
))
619 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
620 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
622 if (dwFlags
& PSP_USEICONID
)
623 hIcon
= LoadImageW(lppsp
->hInstance
, lppsp
->u2
.pszIcon
, IMAGE_ICON
,
624 icon_cx
, icon_cy
, LR_DEFAULTCOLOR
);
626 hIcon
= lppsp
->u2
.hIcon
;
630 if (psInfo
->hImageList
== 0 )
631 psInfo
->hImageList
= ImageList_Create(icon_cx
, icon_cy
, ILC_COLOR
, 1, 1);
633 ImageList_AddIcon(psInfo
->hImageList
, hIcon
);
641 /******************************************************************************
642 * PROPSHEET_CreateDialog
644 * Creates the actual property sheet.
646 INT_PTR
PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
)
653 WORD resID
= IDD_PROPSHEET
;
656 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
659 if( psInfo
->unicode
)
661 if(!(hRes
= FindResourceW(COMCTL32_hModule
,
662 MAKEINTRESOURCEW(resID
),
668 if(!(hRes
= FindResourceA(COMCTL32_hModule
,
669 MAKEINTRESOURCEA(resID
),
674 if(!(template = (LPVOID
)LoadResource(COMCTL32_hModule
, hRes
)))
678 * Make a copy of the dialog template.
680 resSize
= SizeofResource(COMCTL32_hModule
, hRes
);
682 temp
= Alloc(resSize
);
687 memcpy(temp
, template, resSize
);
689 if (psInfo
->ppshheader
.dwFlags
& PSH_NOCONTEXTHELP
)
691 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
692 ((MyDLGTEMPLATEEX
*)temp
)->style
&= ~DS_CONTEXTHELP
;
694 ((DLGTEMPLATE
*)temp
)->style
&= ~DS_CONTEXTHELP
;
696 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
697 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARDCONTEXTHELP
))
699 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
700 ((MyDLGTEMPLATEEX
*)temp
)->style
|= DS_CONTEXTHELP
;
702 ((DLGTEMPLATE
*)temp
)->style
|= DS_CONTEXTHELP
;
705 if (psInfo
->useCallback
)
706 (*(psInfo
->ppshheader
.pfnCallback
))(0, PSCB_PRECREATE
, (LPARAM
)temp
);
708 /* NOTE: MSDN states "Returns a positive value if successful, or -1
709 * otherwise for modal property sheets.", but this is wrong. The
710 * actual return value is either TRUE (success), FALSE (cancel) or
712 if( psInfo
->unicode
)
714 ret
= (INT_PTR
)CreateDialogIndirectParamW(psInfo
->ppshheader
.hInstance
,
715 (LPDLGTEMPLATEW
) temp
,
716 psInfo
->ppshheader
.hwndParent
,
717 PROPSHEET_DialogProc
,
719 if ( !ret
) ret
= -1;
723 ret
= (INT_PTR
)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
724 (LPDLGTEMPLATEA
) temp
,
725 psInfo
->ppshheader
.hwndParent
,
726 PROPSHEET_DialogProc
,
728 if ( !ret
) ret
= -1;
736 /******************************************************************************
737 * PROPSHEET_SizeMismatch
739 * Verify that the tab control and the "largest" property sheet page dlg. template
742 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, PropSheetInfo
* psInfo
)
744 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
745 RECT rcOrigTab
, rcPage
;
750 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
751 TRACE("orig tab %ld %ld %ld %ld\n", rcOrigTab
.left
, rcOrigTab
.top
,
752 rcOrigTab
.right
, rcOrigTab
.bottom
);
759 rcPage
.right
= psInfo
->width
;
760 rcPage
.bottom
= psInfo
->height
;
762 MapDialogRect(hwndDlg
, &rcPage
);
763 TRACE("biggest page %ld %ld %ld %ld\n", rcPage
.left
, rcPage
.top
,
764 rcPage
.right
, rcPage
.bottom
);
766 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
768 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
774 /******************************************************************************
775 * PROPSHEET_AdjustSize
777 * Resizes the property sheet and the tab control to fit the largest page.
779 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
781 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
782 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
784 int tabOffsetX
, tabOffsetY
, buttonHeight
;
785 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
788 /* Get the height of buttons */
789 GetClientRect(hwndButton
, &rc
);
790 buttonHeight
= rc
.bottom
;
797 rc
.right
= psInfo
->width
;
798 rc
.bottom
= psInfo
->height
;
800 MapDialogRect(hwndDlg
, &rc
);
802 /* retrieve the dialog units */
803 units
.left
= units
.right
= 4;
804 units
.top
= units
.bottom
= 8;
805 MapDialogRect(hwndDlg
, &units
);
808 * Resize the tab control.
810 GetClientRect(hwndTabCtrl
,&tabRect
);
812 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
814 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
816 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
817 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
820 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
822 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
823 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
826 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
828 tabOffsetX
= -(rc
.left
);
829 tabOffsetY
= -(rc
.top
);
833 TRACE("setting tab %p, rc (0,0)-(%ld,%ld)\n",
834 hwndTabCtrl
, rc
.right
, rc
.bottom
);
835 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
836 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
838 GetClientRect(hwndTabCtrl
, &rc
);
840 TRACE("tab client rc %ld %ld %ld %ld\n",
841 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
843 rc
.right
+= ((padding
.x
* 2) + tabOffsetX
);
844 rc
.bottom
+= (buttonHeight
+ (3 * padding
.y
) + tabOffsetY
);
847 * Resize the property sheet.
849 TRACE("setting dialog %p, rc (0,0)-(%ld,%ld)\n",
850 hwndDlg
, rc
.right
, rc
.bottom
);
851 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
852 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
856 /******************************************************************************
857 * PROPSHEET_AdjustSizeWizard
859 * Resizes the property sheet to fit the largest page.
861 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, PropSheetInfo
* psInfo
)
863 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
864 RECT rc
, lineRect
, dialogRect
;
866 /* Biggest page size */
869 rc
.right
= psInfo
->width
;
870 rc
.bottom
= psInfo
->height
;
871 MapDialogRect(hwndDlg
, &rc
);
873 TRACE("Biggest page %ld %ld %ld %ld\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
875 /* Add space for the buttons row */
876 GetWindowRect(hwndLine
, &lineRect
);
877 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
878 GetClientRect(hwndDlg
, &dialogRect
);
879 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
881 /* Convert the client coordinates to window coordinates */
882 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
884 /* Resize the property sheet */
885 TRACE("setting dialog %p, rc (0,0)-(%ld,%ld)\n",
886 hwndDlg
, rc
.right
, rc
.bottom
);
887 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
888 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
893 /******************************************************************************
894 * PROPSHEET_AdjustButtons
896 * Adjusts the buttons' positions.
898 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, PropSheetInfo
* psInfo
)
900 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
904 int buttonWidth
, buttonHeight
;
905 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
907 if (psInfo
->hasApply
)
914 * Obtain the size of the buttons.
916 GetClientRect(hwndButton
, &rcSheet
);
917 buttonWidth
= rcSheet
.right
;
918 buttonHeight
= rcSheet
.bottom
;
921 * Get the size of the property sheet.
923 GetClientRect(hwndParent
, &rcSheet
);
926 * All buttons will be at this y coordinate.
928 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
931 * Position OK button and make it default.
933 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
935 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
937 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
938 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
940 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
944 * Position Cancel button.
946 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
948 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1));
950 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
951 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
954 * Position Apply button.
956 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
958 if (psInfo
->hasApply
)
961 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * 2);
963 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
965 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
966 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
968 EnableWindow(hwndButton
, FALSE
);
971 ShowWindow(hwndButton
, SW_HIDE
);
974 * Position Help button.
976 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
980 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
982 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
983 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
986 ShowWindow(hwndButton
, SW_HIDE
);
991 /******************************************************************************
992 * PROPSHEET_AdjustButtonsWizard
994 * Adjusts the buttons' positions.
996 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
997 PropSheetInfo
* psInfo
)
999 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1000 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
1001 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
1004 int num_buttons
= 3;
1005 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
1006 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
1008 if (psInfo
->hasHelp
)
1010 if (psInfo
->hasFinish
)
1014 * Obtain the size of the buttons.
1016 GetClientRect(hwndButton
, &rcSheet
);
1017 buttonWidth
= rcSheet
.right
;
1018 buttonHeight
= rcSheet
.bottom
;
1020 GetClientRect(hwndLine
, &rcSheet
);
1021 lineHeight
= rcSheet
.bottom
;
1024 * Get the size of the property sheet.
1026 GetClientRect(hwndParent
, &rcSheet
);
1029 * All buttons will be at this y coordinate.
1031 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
1034 * Position the Back button.
1036 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
1038 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1)) - buttonWidth
;
1040 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1041 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1044 * Position the Next button.
1046 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
1050 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1051 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1054 * Position the Finish button.
1056 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
1058 if (psInfo
->hasFinish
)
1059 x
+= padding
.x
+ buttonWidth
;
1061 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1062 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1064 if (!psInfo
->hasFinish
)
1065 ShowWindow(hwndButton
, SW_HIDE
);
1068 * Position the Cancel button.
1070 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1072 x
+= padding
.x
+ buttonWidth
;
1074 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1075 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1078 * Position Help button.
1080 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1082 if (psInfo
->hasHelp
)
1084 x
+= padding
.x
+ buttonWidth
;
1086 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1087 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1090 ShowWindow(hwndButton
, SW_HIDE
);
1092 if (psInfo
->ppshheader
.dwFlags
&
1093 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1097 * Position and resize the sunken line.
1100 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1102 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1103 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1104 SWP_NOZORDER
| SWP_NOACTIVATE
);
1107 * Position and resize the header sunken line.
1110 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1111 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1112 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1113 ShowWindow(hwndLineHeader
, SW_HIDE
);
1118 /******************************************************************************
1119 * PROPSHEET_GetPaddingInfo
1121 * Returns the layout information.
1123 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1125 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1128 PADDING_INFO padding
;
1130 GetWindowRect(hwndTab
, &rcTab
);
1135 ScreenToClient(hwndDlg
, &tl
);
1143 /******************************************************************************
1144 * PROPSHEET_GetPaddingInfoWizard
1146 * Returns the layout information.
1147 * Vertical spacing is the distance between the line and the buttons.
1148 * Do NOT use the Help button to gather padding information when it isn't mapped
1149 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1150 * for it in this case !
1151 * FIXME: I'm not sure about any other coordinate problems with these evil
1152 * buttons. Fix it in case additional problems appear or maybe calculate
1153 * a padding in a completely different way, as this is somewhat messy.
1155 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1158 PADDING_INFO padding
;
1162 POINT ptButton
, ptLine
;
1165 if (psInfo
->hasHelp
)
1171 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1173 idButton
= IDC_NEXT_BUTTON
;
1177 /* hopefully this is ok */
1178 idButton
= IDCANCEL
;
1182 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1183 GetWindowRect(hwndControl
, &rc
);
1185 ptButton
.x
= rc
.left
;
1186 ptButton
.y
= rc
.top
;
1188 ScreenToClient(hwndDlg
, &ptButton
);
1191 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1192 GetWindowRect(hwndControl
, &rc
);
1195 ptLine
.y
= rc
.bottom
;
1197 ScreenToClient(hwndDlg
, &ptLine
);
1199 padding
.y
= ptButton
.y
- ptLine
.y
;
1202 ERR("padding negative ! Please report this !\n");
1204 /* this is most probably not correct, but the best we have now */
1205 padding
.x
= padding
.y
;
1209 /******************************************************************************
1210 * PROPSHEET_CreateTabControl
1212 * Insert the tabs in the tab control.
1214 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1215 PropSheetInfo
* psInfo
)
1217 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1223 item
.mask
= TCIF_TEXT
;
1224 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1226 nTabs
= psInfo
->nPages
;
1229 * Set the image list for icons.
1231 if (psInfo
->hImageList
)
1233 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1236 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 0, 0);
1237 for (i
= 0; i
< nTabs
; i
++)
1239 if ( psInfo
->proppage
[i
].hasIcon
)
1241 item
.mask
|= TCIF_IMAGE
;
1242 item
.iImage
= iImage
++;
1246 item
.mask
&= ~TCIF_IMAGE
;
1249 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1250 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, (WPARAM
)i
, (LPARAM
)&item
);
1252 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 1, 0);
1257 /******************************************************************************
1258 * PROPSHEET_WizardSubclassProc
1260 * Subclassing window procedure for wizard extrior pages to prevent drawing
1261 * background and so drawing above the watermark.
1263 static LRESULT CALLBACK
1264 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1271 case WM_CTLCOLORSTATIC
:
1272 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1273 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1276 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1280 * Get the size of an in-memory Template
1282 *( Based on the code of PROPSHEET_CollectPageInfo)
1283 * See also dialog.c/DIALOG_ParseTemplate32().
1286 static UINT
GetTemplateSize(DLGTEMPLATE
* pTemplate
)
1289 const WORD
* p
= (const WORD
*)pTemplate
;
1290 BOOL istemplateex
= (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1295 /* DLGTEMPLATEEX (not defined in any std. header file) */
1297 TRACE("is DLGTEMPLATEEX\n");
1299 p
++; /* signature */
1300 p
+= 2; /* help ID */
1301 p
+= 2; /* ext style */
1308 TRACE("is DLGTEMPLATE\n");
1310 p
+= 2; /* ext style */
1313 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1329 TRACE("menu %s\n",debugstr_w((LPCWSTR
)p
));
1330 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1341 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1344 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1345 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1350 TRACE("title %s\n",debugstr_w((LPCWSTR
)p
));
1351 p
+= lstrlenW((LPCWSTR
)p
) + 1;
1353 /* font, if DS_SETFONT set */
1354 if ((DS_SETFONT
& ((istemplateex
)? ((MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1357 p
+=(istemplateex
)?3:1;
1358 TRACE("font %s\n",debugstr_w((LPCWSTR
)p
));
1359 p
+= lstrlenW( (LPCWSTR
)p
) + 1; /* the font name */
1362 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1363 * that are following the DLGTEMPLATE(EX) data */
1364 TRACE("%d items\n",nrofitems
);
1365 while (nrofitems
> 0)
1367 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1370 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1379 TRACE("class ordinal 0x%08lx\n",*(DWORD
*)p
);
1383 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1384 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1388 /* check title text */
1395 TRACE("text ordinal 0x%08lx\n",*(DWORD
*)p
);
1399 TRACE("text %s\n",debugstr_w((LPCWSTR
)p
));
1400 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1403 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1407 TRACE("%p %p size 0x%08x\n",p
, (WORD
*)pTemplate
,sizeof(WORD
)*(p
- (WORD
*)pTemplate
));
1408 return (p
- (WORD
*)pTemplate
)*sizeof(WORD
);
1412 /******************************************************************************
1413 * PROPSHEET_CreatePage
1417 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1419 const PropSheetInfo
* psInfo
,
1420 LPCPROPSHEETPAGEW ppshpage
)
1422 DLGTEMPLATE
* pTemplate
;
1427 TRACE("index %d\n", index
);
1429 if (ppshpage
== NULL
)
1434 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1436 pTemplate
= (DLGTEMPLATE
*)ppshpage
->u
.pResource
;
1437 resSize
= GetTemplateSize(pTemplate
);
1439 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1444 hResource
= FindResourceW(ppshpage
->hInstance
,
1445 ppshpage
->u
.pszTemplate
,
1450 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1452 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1456 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
1458 * Make a copy of the dialog template to make it writable
1466 hResource
= FindResourceA(ppshpage
->hInstance
,
1467 (LPSTR
)ppshpage
->u
.pszTemplate
,
1472 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1474 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1478 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
1480 * Make a copy of the dialog template to make it writable
1483 temp
= Alloc(resSize
);
1487 TRACE("copying pTemplate %p into temp %p (%ld)\n", pTemplate
, temp
, resSize
);
1488 memcpy(temp
, pTemplate
, resSize
);
1491 if (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
1493 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1494 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~DS_MODALFRAME
;
1495 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_CAPTION
;
1496 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_SYSMENU
;
1497 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_POPUP
;
1498 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_DISABLED
;
1499 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_VISIBLE
;
1500 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_THICKFRAME
;
1502 ((MyDLGTEMPLATEEX
*)pTemplate
)->exStyle
|= WS_EX_CONTROLPARENT
;
1506 pTemplate
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1507 pTemplate
->style
&= ~DS_MODALFRAME
;
1508 pTemplate
->style
&= ~WS_CAPTION
;
1509 pTemplate
->style
&= ~WS_SYSMENU
;
1510 pTemplate
->style
&= ~WS_POPUP
;
1511 pTemplate
->style
&= ~WS_DISABLED
;
1512 pTemplate
->style
&= ~WS_VISIBLE
;
1513 pTemplate
->style
&= ~WS_THICKFRAME
;
1515 pTemplate
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1518 if (psInfo
->proppage
[index
].useCallback
)
1519 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1520 (LPPROPSHEETPAGEW
)ppshpage
);
1522 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1523 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1526 ppshpage
->pfnDlgProc
,
1529 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1532 ppshpage
->pfnDlgProc
,
1534 /* Free a no more needed copy */
1538 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1540 /* Subclass exterior wizard pages */
1541 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1542 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1543 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1545 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1546 (DWORD_PTR
)ppshpage
);
1548 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1549 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1554 /******************************************************************************
1555 * PROPSHEET_LoadWizardBitmaps
1557 * Loads the watermark and header bitmaps for a wizard.
1559 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1561 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1563 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1564 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1565 considers hbmWatermark as valid. */
1566 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1567 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1569 ((PropSheetInfo
*)psInfo
)->ppshheader
.u4
.hbmWatermark
=
1570 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1573 /* Same behavior as for watermarks */
1574 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1575 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1577 ((PropSheetInfo
*)psInfo
)->ppshheader
.u5
.hbmHeader
=
1578 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1584 /******************************************************************************
1585 * PROPSHEET_ShowPage
1587 * Displays or creates the specified page.
1589 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1592 HWND hwndLineHeader
;
1593 LPCPROPSHEETPAGEW ppshpage
;
1595 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1596 if (index
== psInfo
->active_page
)
1598 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1599 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1603 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1604 if (psInfo
->proppage
[index
].hwndPage
== 0)
1606 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1609 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
1610 (ppshpage
->dwFlags
& PSP_USETITLE
))
1612 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1613 psInfo
->proppage
[index
].pszText
);
1616 if (psInfo
->active_page
!= -1)
1617 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1619 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1621 /* Synchronize current selection with tab control
1622 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1623 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1624 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1626 psInfo
->active_page
= index
;
1627 psInfo
->activeValid
= TRUE
;
1629 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1631 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1632 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1634 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1635 ShowWindow(hwndLineHeader
, SW_HIDE
);
1637 ShowWindow(hwndLineHeader
, SW_SHOW
);
1643 /******************************************************************************
1646 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1650 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1655 TRACE("active_page %d\n", psInfo
->active_page
);
1656 if (psInfo
->active_page
< 0)
1659 psn
.hdr
.code
= PSN_WIZBACK
;
1660 psn
.hdr
.hwndFrom
= hwndDlg
;
1664 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1666 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1669 else if (result
== 0)
1670 idx
= psInfo
->active_page
- 1;
1672 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1674 if (idx
>= 0 && idx
< psInfo
->nPages
)
1676 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1677 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1682 /******************************************************************************
1685 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1689 LRESULT msgResult
= 0;
1690 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1694 TRACE("active_page %d\n", psInfo
->active_page
);
1695 if (psInfo
->active_page
< 0)
1698 psn
.hdr
.code
= PSN_WIZNEXT
;
1699 psn
.hdr
.hwndFrom
= hwndDlg
;
1703 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1705 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1706 if (msgResult
== -1)
1708 else if (msgResult
== 0)
1709 idx
= psInfo
->active_page
+ 1;
1711 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1713 if (idx
< psInfo
->nPages
)
1715 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1716 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1722 /******************************************************************************
1725 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1729 LRESULT msgResult
= 0;
1730 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1733 TRACE("active_page %d\n", psInfo
->active_page
);
1734 if (psInfo
->active_page
< 0)
1737 psn
.hdr
.code
= PSN_WIZFINISH
;
1738 psn
.hdr
.hwndFrom
= hwndDlg
;
1742 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1744 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1746 TRACE("msg result %ld\n", msgResult
);
1751 if (psInfo
->isModeless
)
1752 psInfo
->activeValid
= FALSE
;
1754 psInfo
->ended
= TRUE
;
1759 /******************************************************************************
1762 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1767 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1770 TRACE("active_page %d\n", psInfo
->active_page
);
1771 if (psInfo
->active_page
< 0)
1774 psn
.hdr
.hwndFrom
= hwndDlg
;
1780 * Send PSN_KILLACTIVE to the current page.
1782 psn
.hdr
.code
= PSN_KILLACTIVE
;
1784 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1786 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1790 * Send PSN_APPLY to all pages.
1792 psn
.hdr
.code
= PSN_APPLY
;
1793 psn
.lParam
= lParam
;
1795 for (i
= 0; i
< psInfo
->nPages
; i
++)
1797 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1800 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1802 case PSNRET_INVALID
:
1803 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1805 case PSNRET_INVALID_NOCHANGEPAGE
:
1813 psInfo
->activeValid
= FALSE
;
1815 else if(psInfo
->active_page
>= 0)
1817 psn
.hdr
.code
= PSN_SETACTIVE
;
1819 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1820 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1826 /******************************************************************************
1829 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1831 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1837 TRACE("active_page %d\n", psInfo
->active_page
);
1838 if (psInfo
->active_page
< 0)
1841 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1842 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1843 psn
.hdr
.hwndFrom
= hwndDlg
;
1847 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1850 psn
.hdr
.code
= PSN_RESET
;
1851 psn
.lParam
= lParam
;
1853 for (i
= 0; i
< psInfo
->nPages
; i
++)
1855 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1858 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1861 if (psInfo
->isModeless
)
1863 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1864 psInfo
->activeValid
= FALSE
;
1867 psInfo
->ended
= TRUE
;
1870 /******************************************************************************
1873 static void PROPSHEET_Help(HWND hwndDlg
)
1875 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1880 TRACE("active_page %d\n", psInfo
->active_page
);
1881 if (psInfo
->active_page
< 0)
1884 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1885 psn
.hdr
.code
= PSN_HELP
;
1886 psn
.hdr
.hwndFrom
= hwndDlg
;
1890 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1893 /******************************************************************************
1896 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1899 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1903 if (!psInfo
) return;
1905 * Set the dirty flag of this page.
1907 for (i
= 0; i
< psInfo
->nPages
; i
++)
1909 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1910 psInfo
->proppage
[i
].isDirty
= TRUE
;
1914 * Enable the Apply button.
1916 if (psInfo
->hasApply
)
1918 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1920 EnableWindow(hwndApplyBtn
, TRUE
);
1924 /******************************************************************************
1925 * PROPSHEET_UnChanged
1927 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1930 BOOL noPageDirty
= TRUE
;
1931 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1932 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1936 if ( !psInfo
) return;
1937 for (i
= 0; i
< psInfo
->nPages
; i
++)
1939 /* set the specified page as clean */
1940 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1941 psInfo
->proppage
[i
].isDirty
= FALSE
;
1943 /* look to see if there's any dirty pages */
1944 if (psInfo
->proppage
[i
].isDirty
)
1945 noPageDirty
= FALSE
;
1949 * Disable Apply button.
1952 EnableWindow(hwndApplyBtn
, FALSE
);
1955 /******************************************************************************
1956 * PROPSHEET_PressButton
1958 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1960 TRACE("buttonID %d\n", buttonID
);
1963 case PSBTN_APPLYNOW
:
1964 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1967 PROPSHEET_Back(hwndDlg
);
1970 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1973 PROPSHEET_Finish(hwndDlg
);
1976 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1979 PROPSHEET_Next(hwndDlg
);
1982 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1985 FIXME("Invalid button index %d\n", buttonID
);
1990 /*************************************************************************
1991 * BOOL PROPSHEET_CanSetCurSel [Internal]
1993 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1996 * hwndDlg [I] handle to a Dialog hWnd
1999 * TRUE if Current Selection can change
2003 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
2005 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2011 TRACE("active_page %d\n", psInfo
->active_page
);
2018 if (psInfo
->active_page
< 0)
2025 * Notify the current page.
2027 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
2028 psn
.hdr
.code
= PSN_KILLACTIVE
;
2029 psn
.hdr
.hwndFrom
= hwndDlg
;
2033 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2036 TRACE("<-- %d\n", res
);
2040 /******************************************************************************
2041 * PROPSHEET_SetCurSel
2043 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
2046 HPROPSHEETPAGE hpage
2049 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2050 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
2051 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2053 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
2054 /* hpage takes precedence over index */
2056 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2058 if (index
< 0 || index
>= psInfo
->nPages
)
2060 TRACE("Could not find page to select!\n");
2068 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2071 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
2073 psn
.hdr
.code
= PSN_SETACTIVE
;
2074 psn
.hdr
.hwndFrom
= hwndDlg
;
2078 if (!psInfo
->proppage
[index
].hwndPage
) {
2079 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
2082 /* Resize the property sheet page to the fit in the Tab control
2083 * (for regular property sheets) or to fit in the client area (for
2085 * NOTE: The resizing happens every time the page is selected and
2086 * not only when it's created (some applications depend on it). */
2087 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2088 TRACE("setting page %p, rc (%ld,%ld)-(%ld,%ld) w=%ld, h=%ld\n",
2089 psInfo
->proppage
[index
].hwndPage
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
2090 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2091 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2093 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2095 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2102 WARN("Tried to skip before first property sheet page!\n");
2105 if (index
>= psInfo
->nPages
) {
2106 WARN("Tried to skip after last property sheet page!\n");
2107 index
= psInfo
->nPages
-1;
2111 else if (result
!= 0)
2113 int old_index
= index
;
2114 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2115 if(index
>= psInfo
->nPages
) {
2117 WARN("Tried to skip to nonexistant page by res id\n");
2124 * Display the new page.
2126 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2128 if (psInfo
->proppage
[index
].hasHelp
)
2129 EnableWindow(hwndHelp
, TRUE
);
2131 EnableWindow(hwndHelp
, FALSE
);
2136 /******************************************************************************
2137 * PROPSHEET_SetCurSelId
2139 * Selects the page, specified by resource id.
2141 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2144 PropSheetInfo
* psInfo
=
2145 (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2147 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2148 if (idx
< psInfo
->nPages
)
2150 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2151 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2155 /******************************************************************************
2156 * PROPSHEET_SetTitleA
2158 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2160 if(HIWORD(lpszText
))
2163 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2164 szTitle
, sizeof(szTitle
));
2165 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2169 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2173 /******************************************************************************
2174 * PROPSHEET_SetTitleW
2176 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2178 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2181 TRACE("'%s' (style %08lx)\n", debugstr_w(lpszText
), dwStyle
);
2182 if (HIWORD(lpszText
) == 0) {
2183 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2184 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)-sizeof(WCHAR
)))
2188 if (dwStyle
& PSH_PROPTITLE
)
2191 int lentitle
= strlenW(lpszText
);
2192 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2194 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2195 strcpyW(dest
, psInfo
->strPropertiesFor
);
2196 strcatW(dest
, lpszText
);
2198 SetWindowTextW(hwndDlg
, dest
);
2202 SetWindowTextW(hwndDlg
, lpszText
);
2205 /******************************************************************************
2206 * PROPSHEET_SetFinishTextA
2208 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2210 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2211 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2213 TRACE("'%s'\n", lpszText
);
2214 /* Set text, show and enable the Finish button */
2215 SetWindowTextA(hwndButton
, lpszText
);
2216 ShowWindow(hwndButton
, SW_SHOW
);
2217 EnableWindow(hwndButton
, TRUE
);
2219 /* Make it default pushbutton */
2220 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2222 /* Hide Back button */
2223 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2224 ShowWindow(hwndButton
, SW_HIDE
);
2226 if (!psInfo
->hasFinish
)
2228 /* Hide Next button */
2229 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2230 ShowWindow(hwndButton
, SW_HIDE
);
2234 /******************************************************************************
2235 * PROPSHEET_SetFinishTextW
2237 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2239 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2240 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2242 TRACE("'%s'\n", debugstr_w(lpszText
));
2243 /* Set text, show and enable the Finish button */
2244 SetWindowTextW(hwndButton
, lpszText
);
2245 ShowWindow(hwndButton
, SW_SHOW
);
2246 EnableWindow(hwndButton
, TRUE
);
2248 /* Make it default pushbutton */
2249 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2251 /* Hide Back button */
2252 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2253 ShowWindow(hwndButton
, SW_HIDE
);
2255 if (!psInfo
->hasFinish
)
2257 /* Hide Next button */
2258 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2259 ShowWindow(hwndButton
, SW_HIDE
);
2263 /******************************************************************************
2264 * PROPSHEET_QuerySiblings
2266 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2267 WPARAM wParam
, LPARAM lParam
)
2271 LRESULT msgResult
= 0;
2272 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2274 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2276 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2277 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2285 /******************************************************************************
2288 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
2289 HPROPSHEETPAGE hpage
)
2291 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2293 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2295 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2297 TRACE("hpage %p\n", hpage
);
2299 * Allocate and fill in a new PropPageInfo entry.
2301 psInfo
->proppage
= (PropPageInfo
*) ReAlloc(psInfo
->proppage
,
2302 sizeof(PropPageInfo
) *
2303 (psInfo
->nPages
+ 1));
2304 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, psInfo
->nPages
))
2307 psInfo
->proppage
[psInfo
->nPages
].hpage
= hpage
;
2309 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2311 /* Create the page but don't show it */
2312 PROPSHEET_CreatePage(hwndDlg
, psInfo
->nPages
, psInfo
, ppsp
);
2316 * Add a new tab to the tab control.
2318 item
.mask
= TCIF_TEXT
;
2319 item
.pszText
= (LPWSTR
) psInfo
->proppage
[psInfo
->nPages
].pszText
;
2320 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2322 if (psInfo
->hImageList
)
2324 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2327 if ( psInfo
->proppage
[psInfo
->nPages
].hasIcon
)
2329 item
.mask
|= TCIF_IMAGE
;
2330 item
.iImage
= psInfo
->nPages
;
2333 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, psInfo
->nPages
+ 1,
2338 /* If it is the only page - show it */
2339 if(psInfo
->nPages
== 1)
2340 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2344 /******************************************************************************
2345 * PROPSHEET_RemovePage
2347 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2349 HPROPSHEETPAGE hpage
)
2351 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2353 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2354 PropPageInfo
* oldPages
;
2356 TRACE("index %d, hpage %p\n", index
, hpage
);
2361 * hpage takes precedence over index.
2365 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2368 /* Make sure that index is within range */
2369 if (index
< 0 || index
>= psInfo
->nPages
)
2371 TRACE("Could not find page to remove!\n");
2375 TRACE("total pages %d removing page %d active page %d\n",
2376 psInfo
->nPages
, index
, psInfo
->active_page
);
2378 * Check if we're removing the active page.
2380 if (index
== psInfo
->active_page
)
2382 if (psInfo
->nPages
> 1)
2386 /* activate previous page */
2387 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2391 /* activate the next page */
2392 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2393 psInfo
->active_page
= index
;
2398 psInfo
->active_page
= -1;
2399 if (!psInfo
->isModeless
)
2401 psInfo
->ended
= TRUE
;
2406 else if (index
< psInfo
->active_page
)
2407 psInfo
->active_page
--;
2409 /* Unsubclass the page dialog window */
2410 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2411 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2412 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2414 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2415 PROPSHEET_WizardSubclassProc
, 1);
2418 /* Destroy page dialog window */
2419 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2421 /* Free page resources */
2422 if(psInfo
->proppage
[index
].hpage
)
2424 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2426 if ((psp
->dwFlags
& PSP_USETITLE
) && psInfo
->proppage
[index
].pszText
)
2427 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2429 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2432 /* Remove the tab */
2433 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2435 oldPages
= psInfo
->proppage
;
2437 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2440 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2442 if (index
< psInfo
->nPages
)
2443 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2444 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2451 /******************************************************************************
2452 * PROPSHEET_SetWizButtons
2454 * This code will work if (and assumes that) the Next button is on top of the
2455 * Finish button. ie. Finish comes after Next in the Z order.
2456 * This means make sure the dialog template reflects this.
2459 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2461 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2463 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2464 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2465 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2467 TRACE("%ld\n", dwFlags
);
2469 EnableWindow(hwndBack
, FALSE
);
2470 EnableWindow(hwndNext
, FALSE
);
2471 EnableWindow(hwndFinish
, FALSE
);
2473 if (dwFlags
& PSWIZB_BACK
)
2474 EnableWindow(hwndBack
, TRUE
);
2476 if (dwFlags
& PSWIZB_NEXT
)
2478 if (!psInfo
->hasFinish
)
2480 /* Hide the Finish button */
2481 ShowWindow(hwndFinish
, SW_HIDE
);
2484 /* Show and enable the Next button */
2485 ShowWindow(hwndNext
, SW_SHOW
);
2486 EnableWindow(hwndNext
, TRUE
);
2488 /* Set the Next button as the default pushbutton */
2489 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2492 if (!psInfo
->hasFinish
)
2494 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2496 /* Hide the Next button */
2497 ShowWindow(hwndNext
, SW_HIDE
);
2499 /* Show the Finish button */
2500 ShowWindow(hwndFinish
, SW_SHOW
);
2502 if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2504 EnableWindow(hwndFinish
, TRUE
);
2506 /* Set the Finish button as the default pushbutton */
2507 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2511 else if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2512 EnableWindow(hwndFinish
, TRUE
);
2515 /******************************************************************************
2516 * PROPSHEET_InsertPage
2518 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2520 if (!HIWORD(hpageInsertAfter
))
2521 FIXME("(%p, %d, %p): stub\n", hwndDlg
, LOWORD(hpageInsertAfter
), hpage
);
2523 FIXME("(%p, %p, %p): stub\n", hwndDlg
, hpageInsertAfter
, hpage
);
2527 /******************************************************************************
2528 * PROPSHEET_SetHeaderTitleW
2530 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderTitle
)
2532 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderTitle
));
2535 /******************************************************************************
2536 * PROPSHEET_SetHeaderTitleA
2538 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderTitle
)
2540 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderTitle
));
2543 /******************************************************************************
2544 * PROPSHEET_SetHeaderSubTitleW
2546 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderSubTitle
)
2548 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderSubTitle
));
2551 /******************************************************************************
2552 * PROPSHEET_SetHeaderSubTitleA
2554 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderSubTitle
)
2556 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderSubTitle
));
2559 /******************************************************************************
2560 * PROPSHEET_HwndToIndex
2562 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2565 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2568 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2570 for (index
= 0; index
< psInfo
->nPages
; index
++)
2571 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2573 WARN("%p not found\n", hPageDlg
);
2577 /******************************************************************************
2578 * PROPSHEET_IndexToHwnd
2580 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2582 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2584 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2585 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2586 WARN("%d out of range.\n", iPageIndex
);
2589 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2592 /******************************************************************************
2593 * PROPSHEET_PageToIndex
2595 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2598 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2601 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2603 for (index
= 0; index
< psInfo
->nPages
; index
++)
2604 if (psInfo
->proppage
[index
].hpage
== hPage
)
2606 WARN("%p not found\n", hPage
);
2610 /******************************************************************************
2611 * PROPSHEET_IndexToPage
2613 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2615 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2617 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2618 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2619 WARN("%d out of range.\n", iPageIndex
);
2622 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2625 /******************************************************************************
2626 * PROPSHEET_IdToIndex
2628 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2631 LPCPROPSHEETPAGEW psp
;
2632 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2634 TRACE("(%p, %d)\n", hwndDlg
, iPageId
);
2635 for (index
= 0; index
< psInfo
->nPages
; index
++) {
2636 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2637 if (psp
->u
.pszTemplate
== MAKEINTRESOURCEW(iPageId
))
2644 /******************************************************************************
2645 * PROPSHEET_IndexToId
2647 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2649 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2651 LPCPROPSHEETPAGEW psp
;
2652 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2653 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2654 WARN("%d out of range.\n", iPageIndex
);
2657 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2658 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| HIWORD(psp
->u
.pszTemplate
)) {
2661 return (LRESULT
)psp
->u
.pszTemplate
;
2664 /******************************************************************************
2665 * PROPSHEET_GetResult
2667 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2669 FIXME("(%p): stub\n", hwndDlg
);
2673 /******************************************************************************
2674 * PROPSHEET_RecalcPageSizes
2676 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2678 FIXME("(%p): stub\n", hwndDlg
);
2682 /******************************************************************************
2683 * PROPSHEET_GetPageIndex
2685 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2686 * the array of PropPageInfo.
2688 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, PropSheetInfo
* psInfo
)
2693 TRACE("hpage %p\n", hpage
);
2694 while ((index
< psInfo
->nPages
) && (found
== FALSE
))
2696 if (psInfo
->proppage
[index
].hpage
== hpage
)
2708 /******************************************************************************
2711 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2714 PropSheetInfo
* psInfo
= (PropSheetInfo
*) RemovePropW(hwndDlg
,
2718 if (!psInfo
) return;
2719 if (HIWORD(psInfo
->ppshheader
.pszCaption
))
2720 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2722 for (i
= 0; i
< psInfo
->nPages
; i
++)
2724 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2726 /* Unsubclass the page dialog window */
2727 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2728 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2729 (psp
->dwFlags
& PSP_HIDEHEADER
))
2731 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2732 PROPSHEET_WizardSubclassProc
, 1);
2735 if(psInfo
->proppage
[i
].hwndPage
)
2736 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2740 if ((psp
->dwFlags
& PSP_USETITLE
) && psInfo
->proppage
[i
].pszText
)
2741 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2743 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2747 DeleteObject(psInfo
->hFont
);
2748 DeleteObject(psInfo
->hFontBold
);
2749 /* If we created the bitmaps, destroy them */
2750 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2751 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2752 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2753 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2754 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2755 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2757 Free(psInfo
->proppage
);
2758 Free(psInfo
->strPropertiesFor
);
2759 ImageList_Destroy(psInfo
->hImageList
);
2761 GlobalFree((HGLOBAL
)psInfo
);
2764 static INT
do_loop(PropSheetInfo
*psInfo
)
2768 HWND hwnd
= psInfo
->hwnd
;
2770 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2775 if(!IsDialogMessageW(hwnd
, &msg
))
2777 TranslateMessage(&msg
);
2778 DispatchMessageW(&msg
);
2784 PostQuitMessage(msg
.wParam
);
2788 DestroyWindow(hwnd
);
2792 /******************************************************************************
2793 * PropertySheet (COMCTL32.@)
2794 * PropertySheetA (COMCTL32.@)
2796 * Creates a property sheet in the specified property sheet header.
2799 * Modal property sheets: Positive if successful or -1 otherwise.
2800 * Modeless property sheets: Property sheet handle.
2802 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2803 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2805 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2808 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2809 sizeof(PropSheetInfo
));
2813 TRACE("(%p)\n", lppsh
);
2815 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2817 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2819 pByte
= (BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2821 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2823 if (!(lppsh
->dwFlags
& PSH_PROPSHEETPAGE
))
2824 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2827 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2828 pByte
+= ((LPPROPSHEETPAGEA
)pByte
)->dwSize
;
2831 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2834 if (lppsh
->dwFlags
& PSH_PROPSHEETPAGE
)
2835 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2841 psInfo
->unicode
= FALSE
;
2842 psInfo
->ended
= FALSE
;
2844 bRet
= PROPSHEET_CreateDialog(psInfo
);
2845 if(!psInfo
->isModeless
)
2846 bRet
= do_loop(psInfo
);
2851 /******************************************************************************
2852 * PropertySheetW (COMCTL32.@)
2854 * See PropertySheetA.
2856 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2859 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2860 sizeof(PropSheetInfo
));
2864 TRACE("(%p)\n", lppsh
);
2866 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2868 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2870 pByte
= (BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2872 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2874 if (!(lppsh
->dwFlags
& PSH_PROPSHEETPAGE
))
2875 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2878 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2879 pByte
+= ((LPPROPSHEETPAGEW
)pByte
)->dwSize
;
2882 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2885 if (lppsh
->dwFlags
& PSH_PROPSHEETPAGE
)
2886 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2892 psInfo
->unicode
= TRUE
;
2893 psInfo
->ended
= FALSE
;
2895 bRet
= PROPSHEET_CreateDialog(psInfo
);
2896 if(!psInfo
->isModeless
)
2897 bRet
= do_loop(psInfo
);
2902 /******************************************************************************
2903 * CreatePropertySheetPage (COMCTL32.@)
2904 * CreatePropertySheetPageA (COMCTL32.@)
2906 * Creates a new property sheet page.
2909 * Success: Handle to new property sheet page.
2913 * An application must use the PSM_ADDPAGE message to add the new page to
2914 * an existing property sheet.
2916 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2917 LPCPROPSHEETPAGEA lpPropSheetPage
)
2919 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2921 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEA
)));
2923 ppsp
->dwFlags
&= ~ PSP_INTERNAL_UNICODE
;
2924 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( ppsp
->u
.pszTemplate
) )
2926 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
);
2928 ppsp
->u
.pszTemplate
= Alloc( len
+1 );
2929 strcpy( (LPSTR
)ppsp
->u
.pszTemplate
, lpPropSheetPage
->u
.pszTemplate
);
2931 if ( (ppsp
->dwFlags
& PSP_USEICONID
) && HIWORD( ppsp
->u2
.pszIcon
) )
2933 PROPSHEET_AtoW(&ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2936 if ((ppsp
->dwFlags
& PSP_USETITLE
) && HIWORD( ppsp
->pszTitle
))
2938 PROPSHEET_AtoW(&ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2940 else if ( !(ppsp
->dwFlags
& PSP_USETITLE
) )
2941 ppsp
->pszTitle
= NULL
;
2943 return (HPROPSHEETPAGE
)ppsp
;
2946 /******************************************************************************
2947 * CreatePropertySheetPageW (COMCTL32.@)
2949 * See CreatePropertySheetA.
2951 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
2953 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2955 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEW
)));
2957 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
2959 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( ppsp
->u
.pszTemplate
) )
2961 int len
= strlenW(lpPropSheetPage
->u
.pszTemplate
);
2963 ppsp
->u
.pszTemplate
= Alloc( (len
+1)*sizeof (WCHAR
) );
2964 strcpyW( (WCHAR
*)ppsp
->u
.pszTemplate
, lpPropSheetPage
->u
.pszTemplate
);
2966 if ( (ppsp
->dwFlags
& PSP_USEICONID
) && HIWORD( ppsp
->u2
.pszIcon
) )
2968 int len
= strlenW(lpPropSheetPage
->u2
.pszIcon
);
2969 ppsp
->u2
.pszIcon
= Alloc( (len
+1)*sizeof (WCHAR
) );
2970 strcpyW( (WCHAR
*)ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2973 if ((ppsp
->dwFlags
& PSP_USETITLE
) && HIWORD( ppsp
->pszTitle
))
2975 int len
= strlenW(lpPropSheetPage
->pszTitle
);
2976 ppsp
->pszTitle
= Alloc( (len
+1)*sizeof (WCHAR
) );
2977 strcpyW( (WCHAR
*)ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2979 else if ( !(ppsp
->dwFlags
& PSP_USETITLE
) )
2980 ppsp
->pszTitle
= NULL
;
2982 return (HPROPSHEETPAGE
)ppsp
;
2985 /******************************************************************************
2986 * DestroyPropertySheetPage (COMCTL32.@)
2988 * Destroys a property sheet page previously created with
2989 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
2996 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
2998 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3003 if ( !(psp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( psp
->u
.pszTemplate
) )
3004 Free ((LPVOID
)psp
->u
.pszTemplate
);
3006 if ( (psp
->dwFlags
& PSP_USEICONID
) && HIWORD( psp
->u2
.pszIcon
) )
3007 Free ((LPVOID
)psp
->u2
.pszIcon
);
3009 if ((psp
->dwFlags
& PSP_USETITLE
) && HIWORD( psp
->pszTitle
))
3010 Free ((LPVOID
)psp
->pszTitle
);
3017 /******************************************************************************
3018 * PROPSHEET_IsDialogMessage
3020 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3022 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3025 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3028 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3031 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3033 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3035 switch (lpMsg
->wParam
)
3038 if (GetKeyState(VK_SHIFT
) & 0x8000)
3044 case VK_NEXT
: new_page
= 1; break;
3045 case VK_PRIOR
: new_page
= -1; break;
3051 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3053 new_page
+= psInfo
->active_page
;
3056 new_page
= psInfo
->nPages
- 1;
3057 else if (new_page
>= psInfo
->nPages
)
3060 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3067 return IsDialogMessageW(hwnd
, lpMsg
);
3070 /******************************************************************************
3071 * PROPSHEET_DoCommand
3073 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3079 case IDC_APPLY_BUTTON
:
3081 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3083 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3088 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3092 if (psInfo
->restartWindows
)
3093 result
= ID_PSRESTARTWINDOWS
;
3095 /* reboot system takes precedence over restart windows */
3096 if (psInfo
->rebootSystem
)
3097 result
= ID_PSREBOOTSYSTEM
;
3099 if (psInfo
->isModeless
)
3100 psInfo
->activeValid
= FALSE
;
3102 psInfo
->ended
= TRUE
;
3105 EnableWindow(hwndApplyBtn
, FALSE
);
3110 case IDC_BACK_BUTTON
:
3111 PROPSHEET_Back(hwnd
);
3114 case IDC_NEXT_BUTTON
:
3115 PROPSHEET_Next(hwnd
);
3118 case IDC_FINISH_BUTTON
:
3119 PROPSHEET_Finish(hwnd
);
3123 PROPSHEET_Cancel(hwnd
, 0);
3127 PROPSHEET_Help(hwnd
);
3137 /******************************************************************************
3140 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3142 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3147 HPALETTE hOldPal
= 0;
3151 LPCPROPSHEETPAGEW ppshpage
;
3152 WCHAR szBuffer
[256];
3155 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3158 hdcSrc
= CreateCompatibleDC(0);
3159 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3161 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3162 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3164 if ( (!(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3165 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3166 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3168 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3170 COLORREF clrOld
= 0;
3173 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3174 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3176 GetClientRect(hwndLineHeader
, &r
);
3177 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3178 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3180 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), (LPVOID
)&bm
);
3182 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3184 /* Fill the unoccupied part of the header with color of the
3185 * left-top pixel, but do it only when needed.
3187 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3189 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3190 CopyRect(&r
, &rzone
);
3191 if (bm
.bmWidth
< r
.right
)
3193 r
.left
= bm
.bmWidth
;
3194 FillRect(hdc
, &r
, hbr
);
3196 if (bm
.bmHeight
< r
.bottom
)
3199 r
.top
= bm
.bmHeight
;
3200 FillRect(hdc
, &r
, hbr
);
3205 /* Draw the header itself. */
3207 bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3208 hdcSrc
, 0, 0, SRCCOPY
);
3212 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3213 FillRect(hdc
, &rzone
, hbr
);
3215 /* Draw the header bitmap. It's always centered like a
3216 * common 49 x 49 bitmap. */
3217 BitBlt(hdc
, rzone
.right
- 49 - ((rzone
.bottom
- 49) / 2),
3218 (rzone
.bottom
- 49) / 2,
3219 bm
.bmWidth
, bm
.bmHeight
,
3220 hdcSrc
, 0, 0, SRCCOPY
);
3222 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3223 * if its height is smaller than 49 pixels. Because the reason
3224 * for this bug is unknown the current code doesn't try to
3228 clrOld
= SetTextColor (hdc
, 0x00000000);
3229 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3231 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3232 SetRect(&r
, 20, 10, 0, 0);
3233 if (HIWORD(ppshpage
->pszHeaderTitle
))
3235 if (psInfo
->unicode
)
3236 DrawTextW(hdc
, (LPWSTR
)ppshpage
->pszHeaderTitle
,
3237 -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3239 DrawTextA(hdc
, (LPCSTR
)ppshpage
->pszHeaderTitle
,
3240 -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3244 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderTitle
,
3248 DrawTextW(hdc
, szBuffer
, nLength
,
3249 &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3254 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3255 SelectObject(hdc
, psInfo
->hFont
);
3256 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3257 if (HIWORD(ppshpage
->pszHeaderTitle
))
3259 if (psInfo
->unicode
)
3260 DrawTextW(hdc
, (LPWSTR
)ppshpage
->pszHeaderSubTitle
,
3261 -1, &r
, DT_LEFT
| DT_SINGLELINE
);
3263 DrawTextA(hdc
, (LPCSTR
)ppshpage
->pszHeaderSubTitle
,
3264 -1, &r
, DT_LEFT
| DT_SINGLELINE
);
3268 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderSubTitle
,
3272 DrawTextW(hdc
, szBuffer
, nLength
,
3273 &r
, DT_LEFT
| DT_SINGLELINE
);
3278 offsety
= rzone
.bottom
+ 2;
3280 SetTextColor(hdc
, clrOld
);
3281 SetBkMode(hdc
, oldBkMode
);
3282 SelectObject(hdc
, hOldFont
);
3283 SelectObject(hdcSrc
, hbmp
);
3286 if ( (ppshpage
->dwFlags
& PSP_HIDEHEADER
) &&
3287 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3288 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3290 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3292 GetClientRect(hwndLine
, &r
);
3293 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3297 rzone
.right
= r
.right
;
3298 rzone
.bottom
= r
.top
- 1;
3300 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3301 FillRect(hdc
, &rzone
, hbr
);
3303 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), (LPVOID
)&bm
);
3304 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3306 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3307 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3309 /* If the bitmap is not big enough, fill the remaining area
3310 with the color of pixel (0,0) of bitmap - see MSDN */
3311 if (r
.top
> bm
.bmHeight
) {
3312 r
.bottom
= r
.top
- 1;
3313 r
.top
= bm
.bmHeight
;
3315 r
.right
= bm
.bmWidth
;
3316 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3317 FillRect(hdc
, &r
, hbr
);
3321 SelectObject(hdcSrc
, hbmp
);
3324 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3325 SelectPalette(hdc
, hOldPal
, FALSE
);
3329 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3334 /******************************************************************************
3335 * PROPSHEET_DialogProc
3338 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3340 TRACE("hwnd=%p msg=0x%04x wparam=%x lparam=%lx\n",
3341 hwnd
, uMsg
, wParam
, lParam
);
3347 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3348 WCHAR
* strCaption
= (WCHAR
*)Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3349 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3350 LPCPROPSHEETPAGEW ppshpage
;
3354 /* Using PropSheetInfoStr to store extra data doesn't match the native
3355 * common control: native uses TCM_[GS]ETITEM
3357 SetPropW(hwnd
, PropSheetInfoStr
, (HANDLE
)psInfo
);
3360 * psInfo->hwnd is not being used by WINE code - it exists
3361 * for compatibility with "real" Windoze. The same about
3362 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3365 psInfo
->hwnd
= hwnd
;
3366 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3368 /* set up the Next and Back buttons by default */
3369 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3372 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3373 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3374 logFont
.lfWeight
= FW_BOLD
;
3375 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3378 * Small icon in the title bar.
3380 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3381 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3384 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3385 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3387 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3388 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3389 psInfo
->ppshheader
.u
.pszIcon
,
3394 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3396 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3399 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3400 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3402 psInfo
->strPropertiesFor
= strCaption
;
3404 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3406 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3408 PROPSHEET_LoadWizardBitmaps(psInfo
);
3410 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3412 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3413 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3414 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3418 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3420 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3421 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3425 if (psInfo
->useCallback
)
3426 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
,
3427 PSCB_INITIALIZED
, (LPARAM
)0);
3429 idx
= psInfo
->active_page
;
3430 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[idx
].hpage
;
3431 psInfo
->active_page
= -1;
3433 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3435 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3436 * as some programs call TCM_GETCURSEL to get the current selection
3437 * from which to switch to the next page */
3438 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3440 if (!HIWORD(psInfo
->ppshheader
.pszCaption
) &&
3441 psInfo
->ppshheader
.hInstance
)
3445 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3446 (UINT_PTR
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3447 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3451 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3452 psInfo
->ppshheader
.pszCaption
);
3459 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3463 PROPSHEET_CleanUp(hwnd
);
3467 PROPSHEET_Cancel(hwnd
, 1);
3471 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3473 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3478 /* No default handler, forward notification to active page */
3479 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3481 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3482 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3488 switch(wParam
& 0xfff0)
3491 PROPSHEET_Cancel(hwnd
, 1);
3500 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3502 if (pnmh
->code
== TCN_SELCHANGE
)
3504 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3505 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3508 if(pnmh
->code
== TCN_SELCHANGING
)
3510 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3511 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3518 case WM_SYSCOLORCHANGE
:
3519 COMCTL32_RefreshSysColors();
3522 case PSM_GETCURRENTPAGEHWND
:
3524 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3531 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3532 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3534 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3540 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3544 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3547 case PSM_GETTABCONTROL
:
3549 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3551 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3560 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3561 if(msgResult
!= FALSE
)
3563 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3566 (HPROPSHEETPAGE
)lParam
);
3569 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3574 case PSM_CANCELTOCLOSE
:
3576 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3577 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3578 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3580 EnableWindow(hwndCancel
, FALSE
);
3581 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, sizeof(buf
)))
3582 SetWindowTextW(hwndOK
, buf
);
3587 case PSM_RESTARTWINDOWS
:
3589 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3595 psInfo
->restartWindows
= TRUE
;
3599 case PSM_REBOOTSYSTEM
:
3601 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3607 psInfo
->rebootSystem
= TRUE
;
3612 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3616 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3621 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3623 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3628 case PSM_QUERYSIBLINGS
:
3630 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3632 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3640 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3641 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3642 * on success or FALSE otherwise, as specified on MSDN Online.
3643 * Also see the MFC code for
3644 * CPropertySheet::AddPage(CPropertyPage* pPage).
3647 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3649 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3654 case PSM_REMOVEPAGE
:
3655 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3658 case PSM_ISDIALOGMESSAGE
:
3660 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3661 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3665 case PSM_PRESSBUTTON
:
3666 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3669 case PSM_SETFINISHTEXTA
:
3670 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3673 case PSM_SETWIZBUTTONS
:
3674 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3677 case PSM_SETCURSELID
:
3678 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3681 case PSM_SETFINISHTEXTW
:
3682 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3685 case PSM_INSERTPAGE
:
3687 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3688 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3692 case PSM_SETHEADERTITLEW
:
3693 PROPSHEET_SetHeaderTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3696 case PSM_SETHEADERTITLEA
:
3697 PROPSHEET_SetHeaderTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3700 case PSM_SETHEADERSUBTITLEW
:
3701 PROPSHEET_SetHeaderSubTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3704 case PSM_SETHEADERSUBTITLEA
:
3705 PROPSHEET_SetHeaderSubTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3708 case PSM_HWNDTOINDEX
:
3710 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3711 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3715 case PSM_INDEXTOHWND
:
3717 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3718 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3722 case PSM_PAGETOINDEX
:
3724 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3725 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3729 case PSM_INDEXTOPAGE
:
3731 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3732 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3738 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3739 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3745 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3746 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3752 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3753 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3757 case PSM_RECALCPAGESIZES
:
3759 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3760 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);