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
38 * o PSM_RECALCPAGESIZES
39 * o PSM_SETHEADERSUBTITLE
40 * o PSM_SETHEADERTITLE
45 * o PSN_QUERYINITIALFOCUS
46 * o PSN_TRANSLATEACCELERATOR
48 * o PSH_WIZARDHASFINISH
50 * o PSH_STRETCHWATERMARK
54 * o PSP_USEFUSIONCONTEXT
61 #define NONAMELESSUNION
62 #define NONAMELESSSTRUCT
72 #include "wine/debug.h"
73 #include "wine/unicode.h"
75 /******************************************************************************
99 } MyDLGITEMTEMPLATEEX
;
102 typedef struct tagPropPageInfo
104 HPROPSHEETPAGE hpage
; /* to keep track of pages not passed to PropertySheet */
113 typedef struct tagPropSheetInfo
116 PROPSHEETHEADERW ppshheader
;
118 LPWSTR strPropertiesFor
;
128 PropPageInfo
* proppage
;
133 HIMAGELIST hImageList
;
142 /******************************************************************************
143 * Defines and global variables
146 const WCHAR PropSheetInfoStr
[] =
147 {'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0 };
149 #define PSP_INTERNAL_UNICODE 0x80000000
151 #define MAX_CAPTION_LENGTH 255
152 #define MAX_TABTEXT_LENGTH 255
153 #define MAX_BUTTONTEXT_LENGTH 64
155 #define INTRNL_ANY_WIZARD (PSH_WIZARD | PSH_WIZARD97_OLD | PSH_WIZARD97_NEW | PSH_WIZARD_LITE)
157 /* Wizard metrics specified in DLUs */
158 #define WIZARD_PADDING 7
159 #define WIZARD_HEADER_HEIGHT 36
161 /******************************************************************************
164 static int PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
);
165 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, PropSheetInfo
* psInfo
);
166 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
);
167 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, PropSheetInfo
* psInfo
);
168 static BOOL
PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh
,
169 PropSheetInfo
* psInfo
);
170 static BOOL
PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
171 PropSheetInfo
* psInfo
);
172 static BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
173 PropSheetInfo
* psInfo
,
175 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
176 PropSheetInfo
* psInfo
);
177 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
, int index
,
178 const PropSheetInfo
* psInfo
,
179 LPCPROPSHEETPAGEW ppshpage
);
180 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
);
181 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
);
182 static BOOL
PROPSHEET_Back(HWND hwndDlg
);
183 static BOOL
PROPSHEET_Next(HWND hwndDlg
);
184 static BOOL
PROPSHEET_Finish(HWND hwndDlg
);
185 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
);
186 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
);
187 static void PROPSHEET_Help(HWND hwndDlg
);
188 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
);
189 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
);
190 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
);
191 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
);
192 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
);
193 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
);
194 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
);
195 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
);
196 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
199 HPROPSHEETPAGE hpage
);
200 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
);
201 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
202 WPARAM wParam
, LPARAM lParam
);
203 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
204 HPROPSHEETPAGE hpage
);
206 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
208 HPROPSHEETPAGE hpage
);
209 static void PROPSHEET_CleanUp(HWND hwndDlg
);
210 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, PropSheetInfo
* psInfo
);
211 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
);
212 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
);
213 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
);
214 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
);
217 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
219 WINE_DEFAULT_DEBUG_CHANNEL(propsheet
);
221 #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");}
222 /******************************************************************************
223 * PROPSHEET_UnImplementedFlags
225 * Document use of flags we don't implement yet.
227 static VOID
PROPSHEET_UnImplementedFlags(DWORD dwFlags
)
234 * unhandled header flags:
235 * PSH_WIZARDHASFINISH 0x00000010
236 * PSH_RTLREADING 0x00000800
237 * PSH_STRETCHWATERMARK 0x00040000
238 * PSH_USEPAGELANG 0x00200000
241 add_flag(PSH_WIZARDHASFINISH
);
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 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
->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
->useCallback
= (dwFlags
& PSH_USECALLBACK
) && (lppsh
->pfnCallback
);
399 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
401 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
402 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",
403 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
, debugstr_w(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
405 PROPSHEET_UnImplementedFlags(lppsh
->dwFlags
);
407 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
408 psInfo
->ppshheader
.pszCaption
= NULL
;
411 if (HIWORD(lppsh
->pszCaption
))
413 int len
= strlenW(lppsh
->pszCaption
);
414 psInfo
->ppshheader
.pszCaption
= Alloc( (len
+1)*sizeof(WCHAR
) );
415 strcpyW( (WCHAR
*)psInfo
->ppshheader
.pszCaption
, lppsh
->pszCaption
);
418 psInfo
->nPages
= lppsh
->nPages
;
420 if (dwFlags
& PSH_USEPSTARTPAGE
)
422 TRACE("PSH_USEPSTARTPAGE is on\n");
423 psInfo
->active_page
= 0;
426 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
428 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
429 psInfo
->active_page
= 0;
431 psInfo
->restartWindows
= FALSE
;
432 psInfo
->rebootSystem
= FALSE
;
433 psInfo
->hImageList
= 0;
434 psInfo
->activeValid
= FALSE
;
439 /******************************************************************************
440 * PROPSHEET_CollectPageInfo
442 * Collect property sheet data.
443 * With code taken from DIALOG_ParseTemplate32.
445 BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
446 PropSheetInfo
* psInfo
,
449 DLGTEMPLATE
* pTemplate
;
455 psInfo
->proppage
[index
].hpage
= (HPROPSHEETPAGE
)lppsp
;
456 psInfo
->proppage
[index
].hwndPage
= 0;
457 psInfo
->proppage
[index
].isDirty
= FALSE
;
460 * Process property page flags.
462 dwFlags
= lppsp
->dwFlags
;
463 psInfo
->proppage
[index
].useCallback
= (dwFlags
& PSP_USECALLBACK
) && (lppsp
->pfnCallback
);
464 psInfo
->proppage
[index
].hasHelp
= dwFlags
& PSP_HASHELP
;
465 psInfo
->proppage
[index
].hasIcon
= dwFlags
& (PSP_USEHICON
| PSP_USEICONID
);
467 /* as soon as we have a page with the help flag, set the sheet flag on */
468 if (psInfo
->proppage
[index
].hasHelp
)
469 psInfo
->hasHelp
= TRUE
;
472 * Process page template.
474 if (dwFlags
& PSP_DLGINDIRECT
)
475 pTemplate
= (DLGTEMPLATE
*)lppsp
->u
.pResource
;
476 else if(dwFlags
& PSP_INTERNAL_UNICODE
)
478 HRSRC hResource
= FindResourceW(lppsp
->hInstance
,
479 lppsp
->u
.pszTemplate
,
481 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
483 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
487 HRSRC hResource
= FindResourceA(lppsp
->hInstance
,
488 (LPSTR
)lppsp
->u
.pszTemplate
,
490 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
492 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
496 * Extract the size of the page and the caption.
501 p
= (const WORD
*)pTemplate
;
503 if (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
505 /* DLGTEMPLATEEX (not defined in any std. header file) */
509 p
+= 2; /* help ID */
510 p
+= 2; /* ext style */
518 p
+= 2; /* ext style */
524 width
= (WORD
)*p
; p
++;
525 height
= (WORD
)*p
; p
++;
527 /* Special calculation for interior wizard pages so the largest page is
528 * calculated correctly. We need to add all the padding and space occupied
529 * by the header so the width and height sums up to the whole wizard client
531 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
532 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
533 !(dwFlags
& PSP_HIDEHEADER
))
535 height
+= 2 * WIZARD_PADDING
+ WIZARD_HEADER_HEIGHT
;
536 width
+= 2 * WIZARD_PADDING
;
538 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
)
540 height
+= 2 * WIZARD_PADDING
;
541 width
+= 2 * WIZARD_PADDING
;
544 /* remember the largest width and height */
545 if (width
> psInfo
->width
)
546 psInfo
->width
= width
;
548 if (height
> psInfo
->height
)
549 psInfo
->height
= height
;
561 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
575 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
579 /* Extract the caption */
580 psInfo
->proppage
[index
].pszText
= (LPCWSTR
)p
;
581 TRACE("Tab %d %s\n",index
,debugstr_w((LPCWSTR
)p
));
582 p
+= lstrlenW((LPCWSTR
)p
) + 1;
584 if (dwFlags
& PSP_USETITLE
)
588 static const WCHAR pszNull
[] = { '(','n','u','l','l',')',0 };
591 if ( !HIWORD( lppsp
->pszTitle
) )
593 if (!LoadStringW( lppsp
->hInstance
, (UINT
)lppsp
->pszTitle
,szTitle
,sizeof(szTitle
) ))
596 FIXME("Could not load resource #%04x?\n",LOWORD(lppsp
->pszTitle
));
602 pTitle
= lppsp
->pszTitle
;
604 len
= strlenW(pTitle
);
605 psInfo
->proppage
[index
].pszText
= Alloc( (len
+1)*sizeof (WCHAR
) );
606 strcpyW( (LPWSTR
)psInfo
->proppage
[index
].pszText
,pTitle
);
610 * Build the image list for icons
612 if ((dwFlags
& PSP_USEHICON
) || (dwFlags
& PSP_USEICONID
))
615 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
616 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
618 if (dwFlags
& PSP_USEICONID
)
619 hIcon
= LoadImageW(lppsp
->hInstance
, lppsp
->u2
.pszIcon
, IMAGE_ICON
,
620 icon_cx
, icon_cy
, LR_DEFAULTCOLOR
);
622 hIcon
= lppsp
->u2
.hIcon
;
626 if (psInfo
->hImageList
== 0 )
627 psInfo
->hImageList
= ImageList_Create(icon_cx
, icon_cy
, ILC_COLOR
, 1, 1);
629 ImageList_AddIcon(psInfo
->hImageList
, hIcon
);
637 /******************************************************************************
638 * PROPSHEET_CreateDialog
640 * Creates the actual property sheet.
642 int PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
)
649 WORD resID
= IDD_PROPSHEET
;
652 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
655 if( psInfo
->unicode
)
657 if(!(hRes
= FindResourceW(COMCTL32_hModule
,
658 MAKEINTRESOURCEW(resID
),
664 if(!(hRes
= FindResourceA(COMCTL32_hModule
,
665 MAKEINTRESOURCEA(resID
),
670 if(!(template = (LPVOID
)LoadResource(COMCTL32_hModule
, hRes
)))
674 * Make a copy of the dialog template.
676 resSize
= SizeofResource(COMCTL32_hModule
, hRes
);
678 temp
= Alloc(resSize
);
683 memcpy(temp
, template, resSize
);
685 if (psInfo
->ppshheader
.dwFlags
& PSH_NOCONTEXTHELP
)
687 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
688 ((MyDLGTEMPLATEEX
*)temp
)->style
&= ~DS_CONTEXTHELP
;
690 ((DLGTEMPLATE
*)temp
)->style
&= ~DS_CONTEXTHELP
;
692 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
693 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARDCONTEXTHELP
))
695 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
696 ((MyDLGTEMPLATEEX
*)temp
)->style
|= DS_CONTEXTHELP
;
698 ((DLGTEMPLATE
*)temp
)->style
|= DS_CONTEXTHELP
;
701 if (psInfo
->useCallback
)
702 (*(psInfo
->ppshheader
.pfnCallback
))(0, PSCB_PRECREATE
, (LPARAM
)temp
);
704 /* NOTE: MSDN states "Returns a positive value if successful, or -1
705 * otherwise for modal property sheets.", but this is wrong. The
706 * actual return value is either TRUE (success), FALSE (cancel) or
708 if( psInfo
->unicode
)
710 if (!(psInfo
->ppshheader
.dwFlags
& PSH_MODELESS
))
711 ret
= DialogBoxIndirectParamW(psInfo
->ppshheader
.hInstance
,
712 (LPDLGTEMPLATEW
) temp
,
713 psInfo
->ppshheader
.hwndParent
,
714 PROPSHEET_DialogProc
,
718 ret
= (int)CreateDialogIndirectParamW(psInfo
->ppshheader
.hInstance
,
719 (LPDLGTEMPLATEW
) temp
,
720 psInfo
->ppshheader
.hwndParent
,
721 PROPSHEET_DialogProc
,
723 if ( !ret
) ret
= -1;
728 if (!(psInfo
->ppshheader
.dwFlags
& PSH_MODELESS
))
729 ret
= DialogBoxIndirectParamA(psInfo
->ppshheader
.hInstance
,
730 (LPDLGTEMPLATEA
) temp
,
731 psInfo
->ppshheader
.hwndParent
,
732 PROPSHEET_DialogProc
,
736 ret
= (int)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
737 (LPDLGTEMPLATEA
) temp
,
738 psInfo
->ppshheader
.hwndParent
,
739 PROPSHEET_DialogProc
,
741 if ( !ret
) ret
= -1;
750 /******************************************************************************
751 * PROPSHEET_SizeMismatch
753 * Verify that the tab control and the "largest" property sheet page dlg. template
756 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, PropSheetInfo
* psInfo
)
758 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
759 RECT rcOrigTab
, rcPage
;
764 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
765 TRACE("orig tab %ld %ld %ld %ld\n", rcOrigTab
.left
, rcOrigTab
.top
,
766 rcOrigTab
.right
, rcOrigTab
.bottom
);
773 rcPage
.right
= psInfo
->width
;
774 rcPage
.bottom
= psInfo
->height
;
776 MapDialogRect(hwndDlg
, &rcPage
);
777 TRACE("biggest page %ld %ld %ld %ld\n", rcPage
.left
, rcPage
.top
,
778 rcPage
.right
, rcPage
.bottom
);
780 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
782 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
788 /******************************************************************************
789 * PROPSHEET_AdjustSize
791 * Resizes the property sheet and the tab control to fit the largest page.
793 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
795 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
796 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
798 int tabOffsetX
, tabOffsetY
, buttonHeight
;
799 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
802 /* Get the height of buttons */
803 GetClientRect(hwndButton
, &rc
);
804 buttonHeight
= rc
.bottom
;
811 rc
.right
= psInfo
->width
;
812 rc
.bottom
= psInfo
->height
;
814 MapDialogRect(hwndDlg
, &rc
);
816 /* retrieve the dialog units */
817 units
.left
= units
.right
= 4;
818 units
.top
= units
.bottom
= 8;
819 MapDialogRect(hwndDlg
, &units
);
822 * Resize the tab control.
824 GetClientRect(hwndTabCtrl
,&tabRect
);
826 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
828 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
830 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
831 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
834 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
836 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
837 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
840 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
842 tabOffsetX
= -(rc
.left
);
843 tabOffsetY
= -(rc
.top
);
847 TRACE("setting tab %08lx, rc (0,0)-(%ld,%ld)\n",
848 (DWORD
)hwndTabCtrl
, rc
.right
, rc
.bottom
);
849 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
850 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
852 GetClientRect(hwndTabCtrl
, &rc
);
854 TRACE("tab client rc %ld %ld %ld %ld\n",
855 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
857 rc
.right
+= ((padding
.x
* 2) + tabOffsetX
);
858 rc
.bottom
+= (buttonHeight
+ (3 * padding
.y
) + tabOffsetY
);
861 * Resize the property sheet.
863 TRACE("setting dialog %08lx, rc (0,0)-(%ld,%ld)\n",
864 (DWORD
)hwndDlg
, rc
.right
, rc
.bottom
);
865 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
866 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
870 /******************************************************************************
871 * PROPSHEET_AdjustSizeWizard
873 * Resizes the property sheet to fit the largest page.
875 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, PropSheetInfo
* psInfo
)
877 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
878 RECT rc
, lineRect
, dialogRect
;
880 /* Biggest page size */
883 rc
.right
= psInfo
->width
;
884 rc
.bottom
= psInfo
->height
;
885 MapDialogRect(hwndDlg
, &rc
);
887 TRACE("Biggest page %ld %ld %ld %ld\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
889 /* Add space for the buttons row */
890 GetWindowRect(hwndLine
, &lineRect
);
891 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
892 GetClientRect(hwndDlg
, &dialogRect
);
893 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
895 /* Convert the client coordinates to window coordinates */
896 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
898 /* Resize the property sheet */
899 TRACE("setting dialog %08lx, rc (0,0)-(%ld,%ld)\n",
900 (DWORD
)hwndDlg
, rc
.right
, rc
.bottom
);
901 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
902 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
907 /******************************************************************************
908 * PROPSHEET_AdjustButtons
910 * Adjusts the buttons' positions.
912 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, PropSheetInfo
* psInfo
)
914 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
918 int buttonWidth
, buttonHeight
;
919 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
921 if (psInfo
->hasApply
)
928 * Obtain the size of the buttons.
930 GetClientRect(hwndButton
, &rcSheet
);
931 buttonWidth
= rcSheet
.right
;
932 buttonHeight
= rcSheet
.bottom
;
935 * Get the size of the property sheet.
937 GetClientRect(hwndParent
, &rcSheet
);
940 * All buttons will be at this y coordinate.
942 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
945 * Position OK button and make it default.
947 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
949 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
951 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
952 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
954 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
958 * Position Cancel button.
960 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
962 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1));
964 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
965 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
968 * Position Apply button.
970 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
972 if (psInfo
->hasApply
)
975 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * 2);
977 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
979 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
980 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
982 EnableWindow(hwndButton
, FALSE
);
985 ShowWindow(hwndButton
, SW_HIDE
);
988 * Position Help button.
990 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
994 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
996 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
997 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1000 ShowWindow(hwndButton
, SW_HIDE
);
1005 /******************************************************************************
1006 * PROPSHEET_AdjustButtonsWizard
1008 * Adjusts the buttons' positions.
1010 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
1011 PropSheetInfo
* psInfo
)
1013 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1014 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
1015 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
1018 int num_buttons
= 3;
1019 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
1020 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
1022 if (psInfo
->hasHelp
)
1026 * Obtain the size of the buttons.
1028 GetClientRect(hwndButton
, &rcSheet
);
1029 buttonWidth
= rcSheet
.right
;
1030 buttonHeight
= rcSheet
.bottom
;
1032 GetClientRect(hwndLine
, &rcSheet
);
1033 lineHeight
= rcSheet
.bottom
;
1036 * Get the size of the property sheet.
1038 GetClientRect(hwndParent
, &rcSheet
);
1041 * All buttons will be at this y coordinate.
1043 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
1046 * Position the Next and the Finish buttons.
1048 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
1050 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1));
1052 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1053 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1055 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
1057 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1058 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1060 ShowWindow(hwndButton
, SW_HIDE
);
1063 * Position the Back button.
1065 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
1069 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1070 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1073 * Position the Cancel button.
1075 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1077 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 2));
1079 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1080 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1083 * Position Help button.
1085 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1087 if (psInfo
->hasHelp
)
1089 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
1091 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1092 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1095 ShowWindow(hwndButton
, SW_HIDE
);
1097 if (psInfo
->ppshheader
.dwFlags
&
1098 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1102 * Position and resize the sunken line.
1105 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1107 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1108 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1109 SWP_NOZORDER
| SWP_NOACTIVATE
);
1112 * Position and resize the header sunken line.
1115 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1116 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1117 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1118 ShowWindow(hwndLineHeader
, SW_HIDE
);
1123 /******************************************************************************
1124 * PROPSHEET_GetPaddingInfo
1126 * Returns the layout information.
1128 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1130 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1133 PADDING_INFO padding
;
1135 GetWindowRect(hwndTab
, &rcTab
);
1140 ScreenToClient(hwndDlg
, &tl
);
1148 /******************************************************************************
1149 * PROPSHEET_GetPaddingInfoWizard
1151 * Returns the layout information.
1152 * Vertical spacing is the distance between the line and the buttons.
1153 * Do NOT use the Help button to gather padding information when it isn't mapped
1154 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1155 * for it in this case !
1156 * FIXME: I'm not sure about any other coordinate problems with these evil
1157 * buttons. Fix it in case additional problems appear or maybe calculate
1158 * a padding in a completely different way, as this is somewhat messy.
1160 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1163 PADDING_INFO padding
;
1167 POINT ptButton
, ptLine
;
1170 if (psInfo
->hasHelp
)
1176 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1178 idButton
= IDC_NEXT_BUTTON
;
1182 /* hopefully this is ok */
1183 idButton
= IDCANCEL
;
1187 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1188 GetWindowRect(hwndControl
, &rc
);
1190 ptButton
.x
= rc
.left
;
1191 ptButton
.y
= rc
.top
;
1193 ScreenToClient(hwndDlg
, &ptButton
);
1196 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1197 GetWindowRect(hwndControl
, &rc
);
1200 ptLine
.y
= rc
.bottom
;
1202 ScreenToClient(hwndDlg
, &ptLine
);
1204 padding
.y
= ptButton
.y
- ptLine
.y
;
1207 ERR("padding negative ! Please report this !\n");
1209 /* this is most probably not correct, but the best we have now */
1210 padding
.x
= padding
.y
;
1214 /******************************************************************************
1215 * PROPSHEET_CreateTabControl
1217 * Insert the tabs in the tab control.
1219 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1220 PropSheetInfo
* psInfo
)
1222 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1228 item
.mask
= TCIF_TEXT
;
1229 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1231 nTabs
= psInfo
->nPages
;
1234 * Set the image list for icons.
1236 if (psInfo
->hImageList
)
1238 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1241 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 0, 0);
1242 for (i
= 0; i
< nTabs
; i
++)
1244 if ( psInfo
->proppage
[i
].hasIcon
)
1246 item
.mask
|= TCIF_IMAGE
;
1247 item
.iImage
= iImage
++;
1251 item
.mask
&= ~TCIF_IMAGE
;
1254 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1255 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, (WPARAM
)i
, (LPARAM
)&item
);
1257 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 1, 0);
1262 /******************************************************************************
1263 * PROPSHEET_WizardSubclassProc
1265 * Subclassing window procedure for wizard extrior pages to prevent drawing
1266 * background and so drawing above the watermark.
1269 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1276 case WM_CTLCOLORSTATIC
:
1277 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1278 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1281 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1285 * Get the size of an in-memory Template
1287 *( Based on the code of PROPSHEET_CollectPageInfo)
1288 * See also dialog.c/DIALOG_ParseTemplate32().
1291 static UINT
GetTemplateSize(DLGTEMPLATE
* pTemplate
)
1294 const WORD
* p
= (const WORD
*)pTemplate
;
1295 BOOL istemplateex
= (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1300 /* DLGTEMPLATEEX (not defined in any std. header file) */
1302 TRACE("is DLGTEMPLATEEX\n");
1304 p
++; /* signature */
1305 p
+= 2; /* help ID */
1306 p
+= 2; /* ext style */
1313 TRACE("is DLGTEMPLATE\n");
1315 p
+= 2; /* ext style */
1318 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1334 TRACE("menu %s\n",debugstr_w((LPCWSTR
)p
));
1335 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1346 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1349 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1350 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1355 TRACE("title %s\n",debugstr_w((LPCWSTR
)p
));
1356 p
+= lstrlenW((LPCWSTR
)p
) + 1;
1358 /* font, if DS_SETFONT set */
1359 if ((DS_SETFONT
& ((istemplateex
)? ((MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1362 p
+=(istemplateex
)?3:1;
1363 TRACE("font %s\n",debugstr_w((LPCWSTR
)p
));
1364 p
+= lstrlenW( (LPCWSTR
)p
) + 1; /* the font name */
1367 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1368 * that are following the DLGTEMPLATE(EX) data */
1369 TRACE("%d items\n",nrofitems
);
1370 while (nrofitems
> 0)
1372 p
= (WORD
*)(((DWORD
)p
+ 3) & ~3); /* DWORD align */
1375 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1384 TRACE("class ordinal 0x%08lx\n",*(DWORD
*)p
);
1388 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1389 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1393 /* check title text */
1400 TRACE("text ordinal 0x%08lx\n",*(DWORD
*)p
);
1404 TRACE("text %s\n",debugstr_w((LPCWSTR
)p
));
1405 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1408 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1412 TRACE("%p %p size 0x%08x\n",p
, (WORD
*)pTemplate
,sizeof(WORD
)*(p
- (WORD
*)pTemplate
));
1413 return (p
- (WORD
*)pTemplate
)*sizeof(WORD
);
1417 /******************************************************************************
1418 * PROPSHEET_CreatePage
1422 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1424 const PropSheetInfo
* psInfo
,
1425 LPCPROPSHEETPAGEW ppshpage
)
1427 DLGTEMPLATE
* pTemplate
;
1432 TRACE("index %d\n", index
);
1434 if (ppshpage
== NULL
)
1439 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1441 pTemplate
= (DLGTEMPLATE
*)ppshpage
->u
.pResource
;
1442 resSize
= GetTemplateSize(pTemplate
);
1444 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1449 hResource
= FindResourceW(ppshpage
->hInstance
,
1450 ppshpage
->u
.pszTemplate
,
1455 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1457 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1461 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
1463 * Make a copy of the dialog template to make it writable
1471 hResource
= FindResourceA(ppshpage
->hInstance
,
1472 (LPSTR
)ppshpage
->u
.pszTemplate
,
1477 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1479 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1483 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
1485 * Make a copy of the dialog template to make it writable
1488 temp
= Alloc(resSize
);
1492 TRACE("copying pTemplate %p into temp %p (%ld)\n", pTemplate
, temp
, resSize
);
1493 memcpy(temp
, pTemplate
, resSize
);
1496 if (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
1498 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1499 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~DS_MODALFRAME
;
1500 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_CAPTION
;
1501 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_SYSMENU
;
1502 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_POPUP
;
1503 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_DISABLED
;
1504 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_VISIBLE
;
1505 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_THICKFRAME
;
1507 ((MyDLGTEMPLATEEX
*)pTemplate
)->exStyle
|= WS_EX_CONTROLPARENT
;
1511 pTemplate
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1512 pTemplate
->style
&= ~DS_MODALFRAME
;
1513 pTemplate
->style
&= ~WS_CAPTION
;
1514 pTemplate
->style
&= ~WS_SYSMENU
;
1515 pTemplate
->style
&= ~WS_POPUP
;
1516 pTemplate
->style
&= ~WS_DISABLED
;
1517 pTemplate
->style
&= ~WS_VISIBLE
;
1518 pTemplate
->style
&= ~WS_THICKFRAME
;
1520 pTemplate
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1523 if (psInfo
->proppage
[index
].useCallback
)
1524 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1525 (LPPROPSHEETPAGEW
)ppshpage
);
1527 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1528 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1531 ppshpage
->pfnDlgProc
,
1534 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1537 ppshpage
->pfnDlgProc
,
1539 /* Free a no more needed copy */
1543 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1545 /* Subclass exterior wizard pages */
1546 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1547 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1548 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1550 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1551 (DWORD_PTR
)ppshpage
);
1557 /******************************************************************************
1558 * PROPSHEET_LoadWizardBitmaps
1560 * Loads the watermark and header bitmaps for a wizard.
1562 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1564 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1566 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1567 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1568 considers hbmWatermark as valid. */
1569 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1570 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1572 ((PropSheetInfo
*)psInfo
)->ppshheader
.u4
.hbmWatermark
=
1573 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1576 /* Same behavior as for watermarks */
1577 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1578 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1580 ((PropSheetInfo
*)psInfo
)->ppshheader
.u5
.hbmHeader
=
1581 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1587 /******************************************************************************
1588 * PROPSHEET_ShowPage
1590 * Displays or creates the specified page.
1592 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1595 HWND hwndLineHeader
;
1596 LPCPROPSHEETPAGEW ppshpage
;
1598 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1599 if (index
== psInfo
->active_page
)
1601 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1602 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1606 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1607 if (psInfo
->proppage
[index
].hwndPage
== 0)
1609 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1612 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
1613 (ppshpage
->dwFlags
& PSP_USETITLE
))
1615 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1616 psInfo
->proppage
[index
].pszText
);
1619 if (psInfo
->active_page
!= -1)
1620 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1622 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1624 /* Synchronize current selection with tab control
1625 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1626 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1627 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1629 psInfo
->active_page
= index
;
1630 psInfo
->activeValid
= TRUE
;
1632 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1634 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1635 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1637 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1638 ShowWindow(hwndLineHeader
, SW_HIDE
);
1640 ShowWindow(hwndLineHeader
, SW_SHOW
);
1643 InvalidateRgn(hwndDlg
, NULL
, TRUE
);
1644 UpdateWindow(hwndDlg
);
1649 /******************************************************************************
1652 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1656 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1661 TRACE("active_page %d\n", psInfo
->active_page
);
1662 if (psInfo
->active_page
< 0)
1665 psn
.hdr
.code
= PSN_WIZBACK
;
1666 psn
.hdr
.hwndFrom
= hwndDlg
;
1670 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1672 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1675 else if (result
== 0)
1676 idx
= psInfo
->active_page
- 1;
1678 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1680 if (idx
>= 0 && idx
< psInfo
->nPages
)
1682 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1683 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1688 /******************************************************************************
1691 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1695 LRESULT msgResult
= 0;
1696 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1700 TRACE("active_page %d\n", psInfo
->active_page
);
1701 if (psInfo
->active_page
< 0)
1704 psn
.hdr
.code
= PSN_WIZNEXT
;
1705 psn
.hdr
.hwndFrom
= hwndDlg
;
1709 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1711 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1712 if (msgResult
== -1)
1714 else if (msgResult
== 0)
1715 idx
= psInfo
->active_page
+ 1;
1717 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1719 if (idx
< psInfo
->nPages
)
1721 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1722 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1728 /******************************************************************************
1731 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1735 LRESULT msgResult
= 0;
1736 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1739 TRACE("active_page %d\n", psInfo
->active_page
);
1740 if (psInfo
->active_page
< 0)
1743 psn
.hdr
.code
= PSN_WIZFINISH
;
1744 psn
.hdr
.hwndFrom
= hwndDlg
;
1748 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1750 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1752 TRACE("msg result %ld\n", msgResult
);
1757 if (psInfo
->isModeless
)
1758 psInfo
->activeValid
= FALSE
;
1760 EndDialog(hwndDlg
, TRUE
);
1765 /******************************************************************************
1768 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1773 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1776 TRACE("active_page %d\n", psInfo
->active_page
);
1777 if (psInfo
->active_page
< 0)
1780 psn
.hdr
.hwndFrom
= hwndDlg
;
1786 * Send PSN_KILLACTIVE to the current page.
1788 psn
.hdr
.code
= PSN_KILLACTIVE
;
1790 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1792 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1796 * Send PSN_APPLY to all pages.
1798 psn
.hdr
.code
= PSN_APPLY
;
1799 psn
.lParam
= lParam
;
1801 for (i
= 0; i
< psInfo
->nPages
; i
++)
1803 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1806 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1808 case PSNRET_INVALID
:
1809 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1811 case PSNRET_INVALID_NOCHANGEPAGE
:
1819 psInfo
->activeValid
= FALSE
;
1821 else if(psInfo
->active_page
>= 0)
1823 psn
.hdr
.code
= PSN_SETACTIVE
;
1825 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1826 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1832 /******************************************************************************
1835 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1837 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1843 TRACE("active_page %d\n", psInfo
->active_page
);
1844 if (psInfo
->active_page
< 0)
1847 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1848 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1849 psn
.hdr
.hwndFrom
= hwndDlg
;
1853 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1856 psn
.hdr
.code
= PSN_RESET
;
1857 psn
.lParam
= lParam
;
1859 for (i
= 0; i
< psInfo
->nPages
; i
++)
1861 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1864 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1867 if (psInfo
->isModeless
)
1869 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1870 psInfo
->activeValid
= FALSE
;
1873 EndDialog(hwndDlg
, FALSE
);
1876 /******************************************************************************
1879 static void PROPSHEET_Help(HWND hwndDlg
)
1881 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1886 TRACE("active_page %d\n", psInfo
->active_page
);
1887 if (psInfo
->active_page
< 0)
1890 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1891 psn
.hdr
.code
= PSN_HELP
;
1892 psn
.hdr
.hwndFrom
= hwndDlg
;
1896 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1899 /******************************************************************************
1902 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1905 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1909 if (!psInfo
) return;
1911 * Set the dirty flag of this page.
1913 for (i
= 0; i
< psInfo
->nPages
; i
++)
1915 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1916 psInfo
->proppage
[i
].isDirty
= TRUE
;
1920 * Enable the Apply button.
1922 if (psInfo
->hasApply
)
1924 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1926 EnableWindow(hwndApplyBtn
, TRUE
);
1930 /******************************************************************************
1931 * PROPSHEET_UnChanged
1933 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1936 BOOL noPageDirty
= TRUE
;
1937 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1938 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1942 if ( !psInfo
) return;
1943 for (i
= 0; i
< psInfo
->nPages
; i
++)
1945 /* set the specified page as clean */
1946 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1947 psInfo
->proppage
[i
].isDirty
= FALSE
;
1949 /* look to see if there's any dirty pages */
1950 if (psInfo
->proppage
[i
].isDirty
)
1951 noPageDirty
= FALSE
;
1955 * Disable Apply button.
1958 EnableWindow(hwndApplyBtn
, FALSE
);
1961 /******************************************************************************
1962 * PROPSHEET_PressButton
1964 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1966 TRACE("buttonID %d\n", buttonID
);
1969 case PSBTN_APPLYNOW
:
1970 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1973 PROPSHEET_Back(hwndDlg
);
1976 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1979 PROPSHEET_Finish(hwndDlg
);
1982 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1985 PROPSHEET_Next(hwndDlg
);
1988 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1991 FIXME("Invalid button index %d\n", buttonID
);
1996 /*************************************************************************
1997 * BOOL PROPSHEET_CanSetCurSel [Internal]
1999 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
2002 * hwndDlg [I] handle to a Dialog hWnd
2005 * TRUE if Current Selection can change
2009 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
2011 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2017 TRACE("active_page %d\n", psInfo
->active_page
);
2024 if (psInfo
->active_page
< 0)
2031 * Notify the current page.
2033 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
2034 psn
.hdr
.code
= PSN_KILLACTIVE
;
2035 psn
.hdr
.hwndFrom
= hwndDlg
;
2039 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2042 TRACE("<-- %d\n", res
);
2046 /******************************************************************************
2047 * PROPSHEET_SetCurSel
2049 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
2052 HPROPSHEETPAGE hpage
2055 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2056 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
2057 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2059 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
2060 /* hpage takes precedence over index */
2062 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2064 if (index
< 0 || index
>= psInfo
->nPages
)
2066 TRACE("Could not find page to select!\n");
2074 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2077 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
2079 psn
.hdr
.code
= PSN_SETACTIVE
;
2080 psn
.hdr
.hwndFrom
= hwndDlg
;
2084 if (!psInfo
->proppage
[index
].hwndPage
) {
2085 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
2088 /* Resize the property sheet page to the fit in the Tab control
2089 * (for regular property sheets) or to fit in the client area (for
2091 * NOTE: The resizing happens every time the page is selected and
2092 * not only when it's created (some applications depend on it). */
2093 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2094 TRACE("setting page %p, rc (%ld,%ld)-(%ld,%ld) w=%ld, h=%ld\n",
2095 psInfo
->proppage
[index
].hwndPage
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
2096 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2097 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2099 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2101 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2108 WARN("Tried to skip before first property sheet page!\n");
2111 if (index
>= psInfo
->nPages
) {
2112 WARN("Tried to skip after last property sheet page!\n");
2113 index
= psInfo
->nPages
-1;
2117 else if (result
!= 0)
2119 int old_index
= index
;
2120 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2121 if(index
>= psInfo
->nPages
) {
2123 WARN("Tried to skip to nonexistant page by res id\n");
2130 * Display the new page.
2132 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2134 if (psInfo
->proppage
[index
].hasHelp
)
2135 EnableWindow(hwndHelp
, TRUE
);
2137 EnableWindow(hwndHelp
, FALSE
);
2142 /******************************************************************************
2143 * PROPSHEET_SetCurSelId
2145 * Selects the page, specified by resource id.
2147 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2150 PropSheetInfo
* psInfo
=
2151 (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2153 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2154 if (idx
< psInfo
->nPages
)
2156 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2157 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2161 /******************************************************************************
2162 * PROPSHEET_SetTitleA
2164 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2166 if(HIWORD(lpszText
))
2169 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2170 szTitle
, sizeof(szTitle
));
2171 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2175 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2179 /******************************************************************************
2180 * PROPSHEET_SetTitleW
2182 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2184 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2187 TRACE("'%s' (style %08lx)\n", debugstr_w(lpszText
), dwStyle
);
2188 if (HIWORD(lpszText
) == 0) {
2189 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2190 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)-sizeof(WCHAR
)))
2194 if (dwStyle
& PSH_PROPTITLE
)
2197 int lentitle
= strlenW(lpszText
);
2198 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2200 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2201 strcpyW(dest
, psInfo
->strPropertiesFor
);
2202 strcatW(dest
, lpszText
);
2204 SetWindowTextW(hwndDlg
, dest
);
2208 SetWindowTextW(hwndDlg
, lpszText
);
2211 /******************************************************************************
2212 * PROPSHEET_SetFinishTextA
2214 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2216 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2218 TRACE("'%s'\n", lpszText
);
2219 /* Set text, show and enable the Finish button */
2220 SetWindowTextA(hwndButton
, lpszText
);
2221 ShowWindow(hwndButton
, SW_SHOW
);
2222 EnableWindow(hwndButton
, TRUE
);
2224 /* Make it default pushbutton */
2225 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2227 /* Hide Back button */
2228 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2229 ShowWindow(hwndButton
, SW_HIDE
);
2231 /* Hide Next button */
2232 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2233 ShowWindow(hwndButton
, SW_HIDE
);
2236 /******************************************************************************
2237 * PROPSHEET_SetFinishTextW
2239 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2241 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2243 TRACE("'%s'\n", debugstr_w(lpszText
));
2244 /* Set text, show and enable the Finish button */
2245 SetWindowTextW(hwndButton
, lpszText
);
2246 ShowWindow(hwndButton
, SW_SHOW
);
2247 EnableWindow(hwndButton
, TRUE
);
2249 /* Make it default pushbutton */
2250 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2252 /* Hide Back button */
2253 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2254 ShowWindow(hwndButton
, SW_HIDE
);
2256 /* Hide Next button */
2257 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2258 ShowWindow(hwndButton
, SW_HIDE
);
2261 /******************************************************************************
2262 * PROPSHEET_QuerySiblings
2264 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2265 WPARAM wParam
, LPARAM lParam
)
2269 LRESULT msgResult
= 0;
2270 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2272 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2274 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2275 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2283 /******************************************************************************
2286 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
2287 HPROPSHEETPAGE hpage
)
2289 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2291 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2293 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2295 TRACE("hpage %p\n", hpage
);
2297 * Allocate and fill in a new PropPageInfo entry.
2299 psInfo
->proppage
= (PropPageInfo
*) ReAlloc(psInfo
->proppage
,
2300 sizeof(PropPageInfo
) *
2301 (psInfo
->nPages
+ 1));
2302 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, psInfo
->nPages
))
2305 psInfo
->proppage
[psInfo
->nPages
].hpage
= hpage
;
2307 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2309 /* Create the page but don't show it */
2310 PROPSHEET_CreatePage(hwndDlg
, psInfo
->nPages
, psInfo
, ppsp
);
2314 * Add a new tab to the tab control.
2316 item
.mask
= TCIF_TEXT
;
2317 item
.pszText
= (LPWSTR
) psInfo
->proppage
[psInfo
->nPages
].pszText
;
2318 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2320 if (psInfo
->hImageList
)
2322 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2325 if ( psInfo
->proppage
[psInfo
->nPages
].hasIcon
)
2327 item
.mask
|= TCIF_IMAGE
;
2328 item
.iImage
= psInfo
->nPages
;
2331 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, psInfo
->nPages
+ 1,
2336 /* If it is the only page - show it */
2337 if(psInfo
->nPages
== 1)
2338 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2342 /******************************************************************************
2343 * PROPSHEET_RemovePage
2345 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2347 HPROPSHEETPAGE hpage
)
2349 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2351 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2352 PropPageInfo
* oldPages
;
2354 TRACE("index %d, hpage %p\n", index
, hpage
);
2359 * hpage takes precedence over index.
2363 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2366 /* Make sure that index is within range */
2367 if (index
< 0 || index
>= psInfo
->nPages
)
2369 TRACE("Could not find page to remove!\n");
2373 TRACE("total pages %d removing page %d active page %d\n",
2374 psInfo
->nPages
, index
, psInfo
->active_page
);
2376 * Check if we're removing the active page.
2378 if (index
== psInfo
->active_page
)
2380 if (psInfo
->nPages
> 1)
2384 /* activate previous page */
2385 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2389 /* activate the next page */
2390 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2391 psInfo
->active_page
= index
;
2396 psInfo
->active_page
= -1;
2397 if (!psInfo
->isModeless
)
2399 EndDialog(hwndDlg
, FALSE
);
2404 else if (index
< psInfo
->active_page
)
2405 psInfo
->active_page
--;
2407 /* Unsubclass the page dialog window */
2408 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2409 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2410 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2412 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2413 PROPSHEET_WizardSubclassProc
, 1);
2416 /* Destroy page dialog window */
2417 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2419 /* Free page resources */
2420 if(psInfo
->proppage
[index
].hpage
)
2422 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2424 if ((psp
->dwFlags
& PSP_USETITLE
) && psInfo
->proppage
[index
].pszText
)
2425 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2427 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2430 /* Remove the tab */
2431 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2433 oldPages
= psInfo
->proppage
;
2435 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2438 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2440 if (index
< psInfo
->nPages
)
2441 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2442 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2449 /******************************************************************************
2450 * PROPSHEET_SetWizButtons
2452 * This code will work if (and assumes that) the Next button is on top of the
2453 * Finish button. ie. Finish comes after Next in the Z order.
2454 * This means make sure the dialog template reflects this.
2457 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2459 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2460 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2461 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2463 TRACE("%ld\n", dwFlags
);
2465 EnableWindow(hwndBack
, FALSE
);
2466 EnableWindow(hwndNext
, FALSE
);
2467 EnableWindow(hwndFinish
, FALSE
);
2469 if (dwFlags
& PSWIZB_BACK
)
2470 EnableWindow(hwndBack
, TRUE
);
2472 if (dwFlags
& PSWIZB_NEXT
)
2474 /* Hide the Finish button */
2475 ShowWindow(hwndFinish
, SW_HIDE
);
2477 /* Show and enable the Next button */
2478 ShowWindow(hwndNext
, SW_SHOW
);
2479 EnableWindow(hwndNext
, TRUE
);
2481 /* Set the Next button as the default pushbutton */
2482 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2485 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2487 /* Hide the Next button */
2488 ShowWindow(hwndNext
, SW_HIDE
);
2490 /* Show the Finish button */
2491 ShowWindow(hwndFinish
, SW_SHOW
);
2493 if (dwFlags
& PSWIZB_FINISH
)
2494 EnableWindow(hwndFinish
, TRUE
);
2496 /* Set the Finish button as the default pushbutton */
2497 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2501 /******************************************************************************
2502 * PROPSHEET_InsertPage
2504 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2506 if (!HIWORD(hpageInsertAfter
))
2507 FIXME("(%p, %d, %p): stub\n", hwndDlg
, LOWORD(hpageInsertAfter
), hpage
);
2509 FIXME("(%p, %p, %p): stub\n", hwndDlg
, hpageInsertAfter
, hpage
);
2513 /******************************************************************************
2514 * PROPSHEET_SetHeaderTitleW
2516 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderTitle
)
2518 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderTitle
));
2521 /******************************************************************************
2522 * PROPSHEET_SetHeaderTitleA
2524 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderTitle
)
2526 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderTitle
));
2529 /******************************************************************************
2530 * PROPSHEET_SetHeaderSubTitleW
2532 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderSubTitle
)
2534 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderSubTitle
));
2537 /******************************************************************************
2538 * PROPSHEET_SetHeaderSubTitleA
2540 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderSubTitle
)
2542 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderSubTitle
));
2545 /******************************************************************************
2546 * PROPSHEET_HwndToIndex
2548 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2551 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2554 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2556 for (index
= 0; index
< psInfo
->nPages
; index
++)
2557 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2559 WARN("%p not found\n", hPageDlg
);
2563 /******************************************************************************
2564 * PROPSHEET_IndexToHwnd
2566 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2568 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2570 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2571 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2572 WARN("%d out of range.\n", iPageIndex
);
2575 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2578 /******************************************************************************
2579 * PROPSHEET_PageToIndex
2581 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2584 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2587 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2589 for (index
= 0; index
< psInfo
->nPages
; index
++)
2590 if (psInfo
->proppage
[index
].hpage
== hPage
)
2592 WARN("%p not found\n", hPage
);
2596 /******************************************************************************
2597 * PROPSHEET_IndexToPage
2599 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2601 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2603 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2604 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2605 WARN("%d out of range.\n", iPageIndex
);
2608 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2611 /******************************************************************************
2612 * PROPSHEET_IdToIndex
2614 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2616 FIXME("(%p, %d): stub\n", hwndDlg
, iPageId
);
2620 /******************************************************************************
2621 * PROPSHEET_IndexToId
2623 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2625 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2627 LPCPROPSHEETPAGEW psp
;
2628 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2629 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2630 WARN("%d out of range.\n", iPageIndex
);
2633 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2634 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| HIWORD(psp
->u
.pszTemplate
)) {
2637 return (LRESULT
)psp
->u
.pszTemplate
;
2640 /******************************************************************************
2641 * PROPSHEET_GetResult
2643 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2645 FIXME("(%p): stub\n", hwndDlg
);
2649 /******************************************************************************
2650 * PROPSHEET_RecalcPageSizes
2652 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2654 FIXME("(%p): stub\n", hwndDlg
);
2658 /******************************************************************************
2659 * PROPSHEET_GetPageIndex
2661 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2662 * the array of PropPageInfo.
2664 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, PropSheetInfo
* psInfo
)
2669 TRACE("hpage %p\n", hpage
);
2670 while ((index
< psInfo
->nPages
) && (found
== FALSE
))
2672 if (psInfo
->proppage
[index
].hpage
== hpage
)
2684 /******************************************************************************
2687 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2690 PropSheetInfo
* psInfo
= (PropSheetInfo
*) RemovePropW(hwndDlg
,
2694 if (!psInfo
) return;
2695 if (HIWORD(psInfo
->ppshheader
.pszCaption
))
2696 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2698 for (i
= 0; i
< psInfo
->nPages
; i
++)
2700 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2702 /* Unsubclass the page dialog window */
2703 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2704 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2705 (psp
->dwFlags
& PSP_HIDEHEADER
))
2707 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2708 PROPSHEET_WizardSubclassProc
, 1);
2711 if(psInfo
->proppage
[i
].hwndPage
)
2712 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2716 if ((psp
->dwFlags
& PSP_USETITLE
) && psInfo
->proppage
[i
].pszText
)
2717 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2719 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2723 DeleteObject(psInfo
->hFont
);
2724 DeleteObject(psInfo
->hFontBold
);
2725 /* If we created the bitmaps, destroy them */
2726 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2727 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2728 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2729 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2730 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2731 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2733 Free(psInfo
->proppage
);
2734 Free(psInfo
->strPropertiesFor
);
2735 ImageList_Destroy(psInfo
->hImageList
);
2737 GlobalFree((HGLOBAL
)psInfo
);
2740 /******************************************************************************
2741 * PropertySheet (COMCTL32.@)
2742 * PropertySheetA (COMCTL32.@)
2744 * Creates a property sheet in the specified property sheet header.
2747 * Modal property sheets: Positive if successful or -1 otherwise.
2748 * Modeless property sheets: Property sheet handle.
2750 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2751 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2753 INT WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2756 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2757 sizeof(PropSheetInfo
));
2761 TRACE("(%p)\n", lppsh
);
2763 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2765 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2767 pByte
= (BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2769 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2771 if (!(lppsh
->dwFlags
& PSH_PROPSHEETPAGE
))
2772 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2775 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2776 pByte
+= ((LPPROPSHEETPAGEA
)pByte
)->dwSize
;
2779 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2782 if (lppsh
->dwFlags
& PSH_PROPSHEETPAGE
)
2783 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2789 psInfo
->unicode
= FALSE
;
2790 bRet
= PROPSHEET_CreateDialog(psInfo
);
2795 /******************************************************************************
2796 * PropertySheetW (COMCTL32.@)
2798 * See PropertySheetA.
2800 INT WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2803 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2804 sizeof(PropSheetInfo
));
2808 TRACE("(%p)\n", lppsh
);
2810 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2812 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2814 pByte
= (BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2816 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2818 if (!(lppsh
->dwFlags
& PSH_PROPSHEETPAGE
))
2819 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2822 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2823 pByte
+= ((LPPROPSHEETPAGEW
)pByte
)->dwSize
;
2826 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2829 if (lppsh
->dwFlags
& PSH_PROPSHEETPAGE
)
2830 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2836 psInfo
->unicode
= TRUE
;
2837 bRet
= PROPSHEET_CreateDialog(psInfo
);
2842 /******************************************************************************
2843 * CreatePropertySheetPage (COMCTL32.@)
2844 * CreatePropertySheetPageA (COMCTL32.@)
2846 * Creates a new property sheet page.
2849 * Success: Handle to new property sheet page.
2853 * An application must use the PSM_ADDPAGE message to add the new page to
2854 * an existing property sheet.
2856 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2857 LPCPROPSHEETPAGEA lpPropSheetPage
)
2859 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2861 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEA
)));
2863 ppsp
->dwFlags
&= ~ PSP_INTERNAL_UNICODE
;
2864 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( ppsp
->u
.pszTemplate
) )
2866 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
);
2868 ppsp
->u
.pszTemplate
= Alloc( len
+1 );
2869 strcpy( (LPSTR
)ppsp
->u
.pszTemplate
, lpPropSheetPage
->u
.pszTemplate
);
2871 if ( (ppsp
->dwFlags
& PSP_USEICONID
) && HIWORD( ppsp
->u2
.pszIcon
) )
2873 PROPSHEET_AtoW(&ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2876 if ((ppsp
->dwFlags
& PSP_USETITLE
) && HIWORD( ppsp
->pszTitle
))
2878 PROPSHEET_AtoW(&ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2880 else if ( !(ppsp
->dwFlags
& PSP_USETITLE
) )
2881 ppsp
->pszTitle
= NULL
;
2883 return (HPROPSHEETPAGE
)ppsp
;
2886 /******************************************************************************
2887 * CreatePropertySheetPageW (COMCTL32.@)
2889 * See CreatePropertySheetA.
2891 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
2893 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2895 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEW
)));
2897 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
2899 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( ppsp
->u
.pszTemplate
) )
2901 int len
= strlenW(lpPropSheetPage
->u
.pszTemplate
);
2903 ppsp
->u
.pszTemplate
= Alloc( (len
+1)*sizeof (WCHAR
) );
2904 strcpyW( (WCHAR
*)ppsp
->u
.pszTemplate
, lpPropSheetPage
->u
.pszTemplate
);
2906 if ( (ppsp
->dwFlags
& PSP_USEICONID
) && HIWORD( ppsp
->u2
.pszIcon
) )
2908 int len
= strlenW(lpPropSheetPage
->u2
.pszIcon
);
2909 ppsp
->u2
.pszIcon
= Alloc( (len
+1)*sizeof (WCHAR
) );
2910 strcpyW( (WCHAR
*)ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2913 if ((ppsp
->dwFlags
& PSP_USETITLE
) && HIWORD( ppsp
->pszTitle
))
2915 int len
= strlenW(lpPropSheetPage
->pszTitle
);
2916 ppsp
->pszTitle
= Alloc( (len
+1)*sizeof (WCHAR
) );
2917 strcpyW( (WCHAR
*)ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2919 else if ( !(ppsp
->dwFlags
& PSP_USETITLE
) )
2920 ppsp
->pszTitle
= NULL
;
2922 return (HPROPSHEETPAGE
)ppsp
;
2925 /******************************************************************************
2926 * DestroyPropertySheetPage (COMCTL32.@)
2928 * Destroys a property sheet page previously created with
2929 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
2936 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
2938 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
2943 if ( !(psp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( psp
->u
.pszTemplate
) )
2944 Free ((LPVOID
)psp
->u
.pszTemplate
);
2946 if ( (psp
->dwFlags
& PSP_USEICONID
) && HIWORD( psp
->u2
.pszIcon
) )
2947 Free ((LPVOID
)psp
->u2
.pszIcon
);
2949 if ((psp
->dwFlags
& PSP_USETITLE
) && HIWORD( psp
->pszTitle
))
2950 Free ((LPVOID
)psp
->pszTitle
);
2957 /******************************************************************************
2958 * PROPSHEET_IsDialogMessage
2960 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
2962 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
2965 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
2968 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
2971 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
2973 if (!(dlgCode
& DLGC_WANTMESSAGE
))
2975 switch (lpMsg
->wParam
)
2978 if (GetKeyState(VK_SHIFT
) & 0x8000)
2984 case VK_NEXT
: new_page
= 1; break;
2985 case VK_PRIOR
: new_page
= -1; break;
2991 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
2993 new_page
+= psInfo
->active_page
;
2996 new_page
= psInfo
->nPages
- 1;
2997 else if (new_page
>= psInfo
->nPages
)
3000 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3007 return IsDialogMessageW(hwnd
, lpMsg
);
3010 /******************************************************************************
3011 * PROPSHEET_DoCommand
3013 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3019 case IDC_APPLY_BUTTON
:
3021 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3023 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3028 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3032 if (psInfo
->restartWindows
)
3033 result
= ID_PSRESTARTWINDOWS
;
3035 /* reboot system takes precedence over restart windows */
3036 if (psInfo
->rebootSystem
)
3037 result
= ID_PSREBOOTSYSTEM
;
3039 if (psInfo
->isModeless
)
3040 psInfo
->activeValid
= FALSE
;
3042 EndDialog(hwnd
, result
);
3045 EnableWindow(hwndApplyBtn
, FALSE
);
3050 case IDC_BACK_BUTTON
:
3051 PROPSHEET_Back(hwnd
);
3054 case IDC_NEXT_BUTTON
:
3055 PROPSHEET_Next(hwnd
);
3058 case IDC_FINISH_BUTTON
:
3059 PROPSHEET_Finish(hwnd
);
3063 PROPSHEET_Cancel(hwnd
, 0);
3067 PROPSHEET_Help(hwnd
);
3077 /******************************************************************************
3080 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3082 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3087 HPALETTE hOldPal
= 0;
3091 LPCPROPSHEETPAGEW ppshpage
;
3092 WCHAR szBuffer
[256];
3095 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3098 hdcSrc
= CreateCompatibleDC(0);
3099 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3101 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3102 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3104 if ( (!(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3105 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3106 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3108 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3110 COLORREF clrOld
= 0;
3113 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3114 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3116 GetClientRect(hwndLineHeader
, &r
);
3117 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3118 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3120 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), (LPVOID
)&bm
);
3122 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3124 /* Fill the unoccupied part of the header with color of the
3125 * left-top pixel, but do it only when needed.
3127 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3129 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3130 CopyRect(&r
, &rzone
);
3131 if (bm
.bmWidth
< r
.right
)
3133 r
.left
= bm
.bmWidth
;
3134 FillRect(hdc
, &r
, hbr
);
3136 if (bm
.bmHeight
< r
.bottom
)
3139 r
.top
= bm
.bmHeight
;
3140 FillRect(hdc
, &r
, hbr
);
3145 /* Draw the header itself. */
3147 bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3148 hdcSrc
, 0, 0, SRCCOPY
);
3152 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3153 FillRect(hdc
, &rzone
, hbr
);
3155 /* Draw the header bitmap. It's always centered like a
3156 * common 49 x 49 bitmap. */
3157 BitBlt(hdc
, rzone
.right
- 49 - ((rzone
.bottom
- 49) / 2),
3158 (rzone
.bottom
- 49) / 2,
3159 bm
.bmWidth
, bm
.bmHeight
,
3160 hdcSrc
, 0, 0, SRCCOPY
);
3162 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3163 * if its height is smaller than 49 pixels. Because the reason
3164 * for this bug is unknown the current code doesn't try to
3168 clrOld
= SetTextColor (hdc
, 0x00000000);
3169 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3171 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3172 SetRect(&r
, 20, 10, 0, 0);
3173 if (HIWORD(ppshpage
->pszHeaderTitle
))
3175 if (psInfo
->unicode
)
3176 DrawTextW(hdc
, (LPWSTR
)ppshpage
->pszHeaderTitle
,
3177 -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3179 DrawTextA(hdc
, (LPCSTR
)ppshpage
->pszHeaderTitle
,
3180 -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3184 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT
)ppshpage
->pszHeaderTitle
,
3188 DrawTextW(hdc
, szBuffer
, nLength
,
3189 &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3194 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3195 SelectObject(hdc
, psInfo
->hFont
);
3196 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3197 if (HIWORD(ppshpage
->pszHeaderTitle
))
3199 if (psInfo
->unicode
)
3200 DrawTextW(hdc
, (LPWSTR
)ppshpage
->pszHeaderSubTitle
,
3201 -1, &r
, DT_LEFT
| DT_SINGLELINE
);
3203 DrawTextA(hdc
, (LPCSTR
)ppshpage
->pszHeaderSubTitle
,
3204 -1, &r
, DT_LEFT
| DT_SINGLELINE
);
3208 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT
)ppshpage
->pszHeaderSubTitle
,
3212 DrawTextW(hdc
, szBuffer
, nLength
,
3213 &r
, DT_LEFT
| DT_SINGLELINE
);
3218 offsety
= rzone
.bottom
+ 2;
3220 SetTextColor(hdc
, clrOld
);
3221 SetBkMode(hdc
, oldBkMode
);
3222 SelectObject(hdc
, hOldFont
);
3223 SelectObject(hdcSrc
, hbmp
);
3226 if ( (ppshpage
->dwFlags
& PSP_HIDEHEADER
) &&
3227 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3228 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3230 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3232 GetClientRect(hwndLine
, &r
);
3233 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3237 rzone
.right
= r
.right
;
3238 rzone
.bottom
= r
.top
- 1;
3240 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3241 FillRect(hdc
, &rzone
, hbr
);
3243 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), (LPVOID
)&bm
);
3244 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3246 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3247 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3249 /* If the bitmap is not big enough, fill the remaining area
3250 with the color of pixel (0,0) of bitmap - see MSDN */
3251 if (r
.top
> bm
.bmHeight
) {
3252 r
.bottom
= r
.top
- 1;
3253 r
.top
= bm
.bmHeight
;
3255 r
.right
= bm
.bmWidth
;
3256 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3257 FillRect(hdc
, &r
, hbr
);
3261 SelectObject(hdcSrc
, hbmp
);
3264 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3265 SelectPalette(hdc
, hOldPal
, FALSE
);
3269 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3274 /******************************************************************************
3275 * PROPSHEET_DialogProc
3278 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3280 TRACE("hwnd=%p msg=0x%04x wparam=%x lparam=%lx\n",
3281 hwnd
, uMsg
, wParam
, lParam
);
3287 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3288 WCHAR
* strCaption
= (WCHAR
*)Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3289 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3290 LPCPROPSHEETPAGEW ppshpage
;
3294 /* Using PropSheetInfoStr to store extra data doesn't match the native
3295 * common control: native uses TCM_[GS]ETITEM
3297 SetPropW(hwnd
, PropSheetInfoStr
, (HANDLE
)psInfo
);
3300 * psInfo->hwnd is not being used by WINE code - it exists
3301 * for compatibility with "real" Windoze. The same about
3302 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3305 psInfo
->hwnd
= hwnd
;
3306 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3308 /* set up the Next and Back buttons by default */
3309 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3312 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3313 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3314 logFont
.lfWeight
= FW_BOLD
;
3315 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3318 * Small icon in the title bar.
3320 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3321 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3324 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3325 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3327 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3328 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3329 psInfo
->ppshheader
.u
.pszIcon
,
3334 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3336 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3339 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3340 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3342 psInfo
->strPropertiesFor
= strCaption
;
3344 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3346 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3348 PROPSHEET_LoadWizardBitmaps(psInfo
);
3350 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3352 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3353 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3354 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3358 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3360 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3361 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3365 if (psInfo
->useCallback
)
3366 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
,
3367 PSCB_INITIALIZED
, (LPARAM
)0);
3369 idx
= psInfo
->active_page
;
3370 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[idx
].hpage
;
3371 psInfo
->active_page
= -1;
3373 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3375 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3376 * as some programs call TCM_GETCURSEL to get the current selection
3377 * from which to switch to the next page */
3378 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3380 if (!HIWORD(psInfo
->ppshheader
.pszCaption
) &&
3381 psInfo
->ppshheader
.hInstance
)
3385 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3386 (UINT
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3387 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3391 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3392 psInfo
->ppshheader
.pszCaption
);
3399 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3403 PROPSHEET_CleanUp(hwnd
);
3407 PROPSHEET_Cancel(hwnd
, 1);
3411 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3413 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3418 /* No default handler, forward notification to active page */
3419 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3421 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3422 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3429 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3431 if (pnmh
->code
== TCN_SELCHANGE
)
3433 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3434 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3437 if(pnmh
->code
== TCN_SELCHANGING
)
3439 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3440 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3447 case PSM_GETCURRENTPAGEHWND
:
3449 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3456 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3457 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3459 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3465 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3469 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3472 case PSM_GETTABCONTROL
:
3474 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3476 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3485 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3486 if(msgResult
!= FALSE
)
3488 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3491 (HPROPSHEETPAGE
)lParam
);
3494 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3499 case PSM_CANCELTOCLOSE
:
3501 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3502 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3503 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3505 EnableWindow(hwndCancel
, FALSE
);
3506 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, sizeof(buf
)))
3507 SetWindowTextW(hwndOK
, buf
);
3512 case PSM_RESTARTWINDOWS
:
3514 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3520 psInfo
->restartWindows
= TRUE
;
3524 case PSM_REBOOTSYSTEM
:
3526 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3532 psInfo
->rebootSystem
= TRUE
;
3537 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3541 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3546 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3548 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3553 case PSM_QUERYSIBLINGS
:
3555 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3557 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3565 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3566 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3567 * on success or FALSE otherwise, as specified on MSDN Online.
3568 * Also see the MFC code for
3569 * CPropertySheet::AddPage(CPropertyPage* pPage).
3572 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3574 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3579 case PSM_REMOVEPAGE
:
3580 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3583 case PSM_ISDIALOGMESSAGE
:
3585 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3586 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3590 case PSM_PRESSBUTTON
:
3591 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3594 case PSM_SETFINISHTEXTA
:
3595 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3598 case PSM_SETWIZBUTTONS
:
3599 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3602 case PSM_SETCURSELID
:
3603 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3606 case PSM_SETFINISHTEXTW
:
3607 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3610 case PSM_INSERTPAGE
:
3612 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3613 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3617 case PSM_SETHEADERTITLEW
:
3618 PROPSHEET_SetHeaderTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3621 case PSM_SETHEADERTITLEA
:
3622 PROPSHEET_SetHeaderTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3625 case PSM_SETHEADERSUBTITLEW
:
3626 PROPSHEET_SetHeaderSubTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3629 case PSM_SETHEADERSUBTITLEA
:
3630 PROPSHEET_SetHeaderSubTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3633 case PSM_HWNDTOINDEX
:
3635 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3636 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3640 case PSM_INDEXTOHWND
:
3642 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3643 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3647 case PSM_PAGETOINDEX
:
3649 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3650 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3654 case PSM_INDEXTOPAGE
:
3656 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3657 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3663 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3664 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3670 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3671 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3677 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3678 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3682 case PSM_RECALCPAGESIZES
:
3684 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3685 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);