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
;
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 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_WIZARDHASFINISH 0x00000010
237 * PSH_RTLREADING 0x00000800
238 * PSH_STRETCHWATERMARK 0x00040000
239 * PSH_USEPAGELANG 0x00200000
242 add_flag(PSH_WIZARDHASFINISH
);
243 add_flag(PSH_RTLREADING
);
244 add_flag(PSH_STRETCHWATERMARK
);
245 add_flag(PSH_USEPAGELANG
);
246 if (string
[0] != '\0')
247 FIXME("%s\n", string
);
251 /******************************************************************************
252 * PROPSHEET_GetPageRect
254 * Retrieve rect from tab control and map into the dialog for SetWindowPos
256 static void PROPSHEET_GetPageRect(const PropSheetInfo
* psInfo
, HWND hwndDlg
,
257 RECT
*rc
, LPCPROPSHEETPAGEW ppshpage
)
259 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) {
263 if (((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
264 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
265 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) ||
266 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
))
268 rc
->left
= rc
->top
= WIZARD_PADDING
;
272 rc
->left
= rc
->top
= 0;
274 rc
->right
= psInfo
->width
- rc
->left
;
275 rc
->bottom
= psInfo
->height
- rc
->top
;
276 MapDialogRect(hwndDlg
, rc
);
278 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
279 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
280 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
))
282 hwndChild
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
283 GetClientRect(hwndChild
, &r
);
284 MapWindowPoints(hwndChild
, hwndDlg
, (LPPOINT
) &r
, 2);
285 rc
->top
+= r
.bottom
+ 1;
288 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
289 GetClientRect(hwndTabCtrl
, rc
);
290 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)rc
);
291 MapWindowPoints(hwndTabCtrl
, hwndDlg
, (LPPOINT
)rc
, 2);
295 /******************************************************************************
296 * PROPSHEET_FindPageByResId
298 * Find page index corresponding to page resource id.
300 static INT
PROPSHEET_FindPageByResId(PropSheetInfo
* psInfo
, LRESULT resId
)
304 for (i
= 0; i
< psInfo
->nPages
; i
++)
306 LPCPROPSHEETPAGEA lppsp
= (LPCPROPSHEETPAGEA
)psInfo
->proppage
[i
].hpage
;
308 /* Fixme: if resource ID is a string shall we use strcmp ??? */
309 if (lppsp
->u
.pszTemplate
== (LPVOID
)resId
)
316 /******************************************************************************
319 * Convert ASCII to Unicode since all data is saved as Unicode.
321 static void PROPSHEET_AtoW(LPCWSTR
*tostr
, LPCSTR frstr
)
325 TRACE("<%s>\n", frstr
);
326 len
= MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, 0, 0);
327 *tostr
= Alloc(len
* sizeof(WCHAR
));
328 MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, (LPWSTR
)*tostr
, len
);
331 /******************************************************************************
332 * PROPSHEET_CollectSheetInfoA
334 * Collect relevant data.
336 static BOOL
PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh
,
337 PropSheetInfo
* psInfo
)
339 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERA
));
340 DWORD dwFlags
= lppsh
->dwFlags
;
342 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
343 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
344 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
)&& (lppsh
->pfnCallback
);
345 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
347 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
348 TRACE("\n** PROPSHEETHEADER **\ndwSize\t\t%ld\ndwFlags\t\t%08lx\nhwndParent\t%p\nhInstance\t%p\npszCaption\t'%s'\nnPages\t\t%d\npfnCallback\t%p\n",
349 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
,
350 debugstr_a(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
352 PROPSHEET_UnImplementedFlags(lppsh
->dwFlags
);
354 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
355 psInfo
->ppshheader
.pszCaption
= NULL
;
358 if (HIWORD(lppsh
->pszCaption
))
360 int len
= MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, NULL
, 0);
361 psInfo
->ppshheader
.pszCaption
= Alloc( len
*sizeof (WCHAR
) );
362 MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, (LPWSTR
) psInfo
->ppshheader
.pszCaption
, len
);
365 psInfo
->nPages
= lppsh
->nPages
;
367 if (dwFlags
& PSH_USEPSTARTPAGE
)
369 TRACE("PSH_USEPSTARTPAGE is on\n");
370 psInfo
->active_page
= 0;
373 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
375 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
376 psInfo
->active_page
= 0;
378 psInfo
->restartWindows
= FALSE
;
379 psInfo
->rebootSystem
= FALSE
;
380 psInfo
->hImageList
= 0;
381 psInfo
->activeValid
= FALSE
;
386 /******************************************************************************
387 * PROPSHEET_CollectSheetInfoW
389 * Collect relevant data.
391 static BOOL
PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
392 PropSheetInfo
* psInfo
)
394 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERW
));
395 DWORD dwFlags
= lppsh
->dwFlags
;
397 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
398 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
399 psInfo
->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
;
456 psInfo
->proppage
[index
].hpage
= (HPROPSHEETPAGE
)lppsp
;
457 psInfo
->proppage
[index
].hwndPage
= 0;
458 psInfo
->proppage
[index
].isDirty
= FALSE
;
461 * Process property page flags.
463 dwFlags
= lppsp
->dwFlags
;
464 psInfo
->proppage
[index
].useCallback
= (dwFlags
& PSP_USECALLBACK
) && (lppsp
->pfnCallback
);
465 psInfo
->proppage
[index
].hasHelp
= dwFlags
& PSP_HASHELP
;
466 psInfo
->proppage
[index
].hasIcon
= dwFlags
& (PSP_USEHICON
| PSP_USEICONID
);
468 /* as soon as we have a page with the help flag, set the sheet flag on */
469 if (psInfo
->proppage
[index
].hasHelp
)
470 psInfo
->hasHelp
= TRUE
;
473 * Process page template.
475 if (dwFlags
& PSP_DLGINDIRECT
)
476 pTemplate
= (DLGTEMPLATE
*)lppsp
->u
.pResource
;
477 else if(dwFlags
& PSP_INTERNAL_UNICODE
)
479 HRSRC hResource
= FindResourceW(lppsp
->hInstance
,
480 lppsp
->u
.pszTemplate
,
482 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
484 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
488 HRSRC hResource
= FindResourceA(lppsp
->hInstance
,
489 (LPSTR
)lppsp
->u
.pszTemplate
,
491 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
493 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
497 * Extract the size of the page and the caption.
502 p
= (const WORD
*)pTemplate
;
504 if (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
506 /* DLGTEMPLATEEX (not defined in any std. header file) */
510 p
+= 2; /* help ID */
511 p
+= 2; /* ext style */
519 p
+= 2; /* ext style */
525 width
= (WORD
)*p
; p
++;
526 height
= (WORD
)*p
; p
++;
528 /* Special calculation for interior wizard pages so the largest page is
529 * calculated correctly. We need to add all the padding and space occupied
530 * by the header so the width and height sums up to the whole wizard client
532 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
533 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
534 !(dwFlags
& PSP_HIDEHEADER
))
536 height
+= 2 * WIZARD_PADDING
+ WIZARD_HEADER_HEIGHT
;
537 width
+= 2 * WIZARD_PADDING
;
539 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
)
541 height
+= 2 * WIZARD_PADDING
;
542 width
+= 2 * WIZARD_PADDING
;
545 /* remember the largest width and height */
546 if (width
> psInfo
->width
)
547 psInfo
->width
= width
;
549 if (height
> psInfo
->height
)
550 psInfo
->height
= height
;
562 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
576 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
580 /* Extract the caption */
581 psInfo
->proppage
[index
].pszText
= (LPCWSTR
)p
;
582 TRACE("Tab %d %s\n",index
,debugstr_w((LPCWSTR
)p
));
583 p
+= lstrlenW((LPCWSTR
)p
) + 1;
585 if (dwFlags
& PSP_USETITLE
)
589 static const WCHAR pszNull
[] = { '(','n','u','l','l',')',0 };
592 if ( !HIWORD( lppsp
->pszTitle
) )
594 if (!LoadStringW( lppsp
->hInstance
, (UINT
)lppsp
->pszTitle
,szTitle
,sizeof(szTitle
) ))
597 FIXME("Could not load resource #%04x?\n",LOWORD(lppsp
->pszTitle
));
603 pTitle
= lppsp
->pszTitle
;
605 len
= strlenW(pTitle
);
606 psInfo
->proppage
[index
].pszText
= Alloc( (len
+1)*sizeof (WCHAR
) );
607 strcpyW( (LPWSTR
)psInfo
->proppage
[index
].pszText
,pTitle
);
611 * Build the image list for icons
613 if ((dwFlags
& PSP_USEHICON
) || (dwFlags
& PSP_USEICONID
))
616 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
617 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
619 if (dwFlags
& PSP_USEICONID
)
620 hIcon
= LoadImageW(lppsp
->hInstance
, lppsp
->u2
.pszIcon
, IMAGE_ICON
,
621 icon_cx
, icon_cy
, LR_DEFAULTCOLOR
);
623 hIcon
= lppsp
->u2
.hIcon
;
627 if (psInfo
->hImageList
== 0 )
628 psInfo
->hImageList
= ImageList_Create(icon_cx
, icon_cy
, ILC_COLOR
, 1, 1);
630 ImageList_AddIcon(psInfo
->hImageList
, hIcon
);
638 /******************************************************************************
639 * PROPSHEET_CreateDialog
641 * Creates the actual property sheet.
643 int PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
)
650 WORD resID
= IDD_PROPSHEET
;
653 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
656 if( psInfo
->unicode
)
658 if(!(hRes
= FindResourceW(COMCTL32_hModule
,
659 MAKEINTRESOURCEW(resID
),
665 if(!(hRes
= FindResourceA(COMCTL32_hModule
,
666 MAKEINTRESOURCEA(resID
),
671 if(!(template = (LPVOID
)LoadResource(COMCTL32_hModule
, hRes
)))
675 * Make a copy of the dialog template.
677 resSize
= SizeofResource(COMCTL32_hModule
, hRes
);
679 temp
= Alloc(resSize
);
684 memcpy(temp
, template, resSize
);
686 if (psInfo
->ppshheader
.dwFlags
& PSH_NOCONTEXTHELP
)
688 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
689 ((MyDLGTEMPLATEEX
*)temp
)->style
&= ~DS_CONTEXTHELP
;
691 ((DLGTEMPLATE
*)temp
)->style
&= ~DS_CONTEXTHELP
;
693 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
694 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARDCONTEXTHELP
))
696 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
697 ((MyDLGTEMPLATEEX
*)temp
)->style
|= DS_CONTEXTHELP
;
699 ((DLGTEMPLATE
*)temp
)->style
|= DS_CONTEXTHELP
;
702 if (psInfo
->useCallback
)
703 (*(psInfo
->ppshheader
.pfnCallback
))(0, PSCB_PRECREATE
, (LPARAM
)temp
);
705 /* NOTE: MSDN states "Returns a positive value if successful, or -1
706 * otherwise for modal property sheets.", but this is wrong. The
707 * actual return value is either TRUE (success), FALSE (cancel) or
709 if( psInfo
->unicode
)
711 ret
= (int)CreateDialogIndirectParamW(psInfo
->ppshheader
.hInstance
,
712 (LPDLGTEMPLATEW
) temp
,
713 psInfo
->ppshheader
.hwndParent
,
714 PROPSHEET_DialogProc
,
716 if ( !ret
) ret
= -1;
720 ret
= (int)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
721 (LPDLGTEMPLATEA
) temp
,
722 psInfo
->ppshheader
.hwndParent
,
723 PROPSHEET_DialogProc
,
725 if ( !ret
) ret
= -1;
733 /******************************************************************************
734 * PROPSHEET_SizeMismatch
736 * Verify that the tab control and the "largest" property sheet page dlg. template
739 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, PropSheetInfo
* psInfo
)
741 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
742 RECT rcOrigTab
, rcPage
;
747 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
748 TRACE("orig tab %ld %ld %ld %ld\n", rcOrigTab
.left
, rcOrigTab
.top
,
749 rcOrigTab
.right
, rcOrigTab
.bottom
);
756 rcPage
.right
= psInfo
->width
;
757 rcPage
.bottom
= psInfo
->height
;
759 MapDialogRect(hwndDlg
, &rcPage
);
760 TRACE("biggest page %ld %ld %ld %ld\n", rcPage
.left
, rcPage
.top
,
761 rcPage
.right
, rcPage
.bottom
);
763 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
765 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
771 /******************************************************************************
772 * PROPSHEET_AdjustSize
774 * Resizes the property sheet and the tab control to fit the largest page.
776 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
778 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
779 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
781 int tabOffsetX
, tabOffsetY
, buttonHeight
;
782 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
785 /* Get the height of buttons */
786 GetClientRect(hwndButton
, &rc
);
787 buttonHeight
= rc
.bottom
;
794 rc
.right
= psInfo
->width
;
795 rc
.bottom
= psInfo
->height
;
797 MapDialogRect(hwndDlg
, &rc
);
799 /* retrieve the dialog units */
800 units
.left
= units
.right
= 4;
801 units
.top
= units
.bottom
= 8;
802 MapDialogRect(hwndDlg
, &units
);
805 * Resize the tab control.
807 GetClientRect(hwndTabCtrl
,&tabRect
);
809 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
811 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
813 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
814 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
817 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
819 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
820 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
823 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
825 tabOffsetX
= -(rc
.left
);
826 tabOffsetY
= -(rc
.top
);
830 TRACE("setting tab %08lx, rc (0,0)-(%ld,%ld)\n",
831 (DWORD
)hwndTabCtrl
, rc
.right
, rc
.bottom
);
832 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
833 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
835 GetClientRect(hwndTabCtrl
, &rc
);
837 TRACE("tab client rc %ld %ld %ld %ld\n",
838 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
840 rc
.right
+= ((padding
.x
* 2) + tabOffsetX
);
841 rc
.bottom
+= (buttonHeight
+ (3 * padding
.y
) + tabOffsetY
);
844 * Resize the property sheet.
846 TRACE("setting dialog %08lx, rc (0,0)-(%ld,%ld)\n",
847 (DWORD
)hwndDlg
, rc
.right
, rc
.bottom
);
848 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
849 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
853 /******************************************************************************
854 * PROPSHEET_AdjustSizeWizard
856 * Resizes the property sheet to fit the largest page.
858 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, PropSheetInfo
* psInfo
)
860 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
861 RECT rc
, lineRect
, dialogRect
;
863 /* Biggest page size */
866 rc
.right
= psInfo
->width
;
867 rc
.bottom
= psInfo
->height
;
868 MapDialogRect(hwndDlg
, &rc
);
870 TRACE("Biggest page %ld %ld %ld %ld\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
872 /* Add space for the buttons row */
873 GetWindowRect(hwndLine
, &lineRect
);
874 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
875 GetClientRect(hwndDlg
, &dialogRect
);
876 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
878 /* Convert the client coordinates to window coordinates */
879 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
881 /* Resize the property sheet */
882 TRACE("setting dialog %08lx, rc (0,0)-(%ld,%ld)\n",
883 (DWORD
)hwndDlg
, rc
.right
, rc
.bottom
);
884 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
885 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
890 /******************************************************************************
891 * PROPSHEET_AdjustButtons
893 * Adjusts the buttons' positions.
895 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, PropSheetInfo
* psInfo
)
897 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
901 int buttonWidth
, buttonHeight
;
902 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
904 if (psInfo
->hasApply
)
911 * Obtain the size of the buttons.
913 GetClientRect(hwndButton
, &rcSheet
);
914 buttonWidth
= rcSheet
.right
;
915 buttonHeight
= rcSheet
.bottom
;
918 * Get the size of the property sheet.
920 GetClientRect(hwndParent
, &rcSheet
);
923 * All buttons will be at this y coordinate.
925 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
928 * Position OK button and make it default.
930 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
932 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
934 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
935 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
937 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
941 * Position Cancel button.
943 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
945 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1));
947 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
948 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
951 * Position Apply button.
953 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
955 if (psInfo
->hasApply
)
958 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * 2);
960 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
962 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
963 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
965 EnableWindow(hwndButton
, FALSE
);
968 ShowWindow(hwndButton
, SW_HIDE
);
971 * Position Help button.
973 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
977 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
979 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
980 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
983 ShowWindow(hwndButton
, SW_HIDE
);
988 /******************************************************************************
989 * PROPSHEET_AdjustButtonsWizard
991 * Adjusts the buttons' positions.
993 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
994 PropSheetInfo
* psInfo
)
996 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
997 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
998 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
1001 int num_buttons
= 3;
1002 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
1003 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
1005 if (psInfo
->hasHelp
)
1009 * Obtain the size of the buttons.
1011 GetClientRect(hwndButton
, &rcSheet
);
1012 buttonWidth
= rcSheet
.right
;
1013 buttonHeight
= rcSheet
.bottom
;
1015 GetClientRect(hwndLine
, &rcSheet
);
1016 lineHeight
= rcSheet
.bottom
;
1019 * Get the size of the property sheet.
1021 GetClientRect(hwndParent
, &rcSheet
);
1024 * All buttons will be at this y coordinate.
1026 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
1029 * Position the Next and the Finish buttons.
1031 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
1033 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1));
1035 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1036 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1038 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
1040 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1041 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1043 ShowWindow(hwndButton
, SW_HIDE
);
1046 * Position the Back button.
1048 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
1052 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1053 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1056 * Position the Cancel button.
1058 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1060 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 2));
1062 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1063 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1066 * Position Help button.
1068 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1070 if (psInfo
->hasHelp
)
1072 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
1074 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1075 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1078 ShowWindow(hwndButton
, SW_HIDE
);
1080 if (psInfo
->ppshheader
.dwFlags
&
1081 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1085 * Position and resize the sunken line.
1088 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1090 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1091 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1092 SWP_NOZORDER
| SWP_NOACTIVATE
);
1095 * Position and resize the header sunken line.
1098 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1099 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1100 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1101 ShowWindow(hwndLineHeader
, SW_HIDE
);
1106 /******************************************************************************
1107 * PROPSHEET_GetPaddingInfo
1109 * Returns the layout information.
1111 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1113 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1116 PADDING_INFO padding
;
1118 GetWindowRect(hwndTab
, &rcTab
);
1123 ScreenToClient(hwndDlg
, &tl
);
1131 /******************************************************************************
1132 * PROPSHEET_GetPaddingInfoWizard
1134 * Returns the layout information.
1135 * Vertical spacing is the distance between the line and the buttons.
1136 * Do NOT use the Help button to gather padding information when it isn't mapped
1137 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1138 * for it in this case !
1139 * FIXME: I'm not sure about any other coordinate problems with these evil
1140 * buttons. Fix it in case additional problems appear or maybe calculate
1141 * a padding in a completely different way, as this is somewhat messy.
1143 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1146 PADDING_INFO padding
;
1150 POINT ptButton
, ptLine
;
1153 if (psInfo
->hasHelp
)
1159 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1161 idButton
= IDC_NEXT_BUTTON
;
1165 /* hopefully this is ok */
1166 idButton
= IDCANCEL
;
1170 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1171 GetWindowRect(hwndControl
, &rc
);
1173 ptButton
.x
= rc
.left
;
1174 ptButton
.y
= rc
.top
;
1176 ScreenToClient(hwndDlg
, &ptButton
);
1179 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1180 GetWindowRect(hwndControl
, &rc
);
1183 ptLine
.y
= rc
.bottom
;
1185 ScreenToClient(hwndDlg
, &ptLine
);
1187 padding
.y
= ptButton
.y
- ptLine
.y
;
1190 ERR("padding negative ! Please report this !\n");
1192 /* this is most probably not correct, but the best we have now */
1193 padding
.x
= padding
.y
;
1197 /******************************************************************************
1198 * PROPSHEET_CreateTabControl
1200 * Insert the tabs in the tab control.
1202 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1203 PropSheetInfo
* psInfo
)
1205 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1211 item
.mask
= TCIF_TEXT
;
1212 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1214 nTabs
= psInfo
->nPages
;
1217 * Set the image list for icons.
1219 if (psInfo
->hImageList
)
1221 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1224 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 0, 0);
1225 for (i
= 0; i
< nTabs
; i
++)
1227 if ( psInfo
->proppage
[i
].hasIcon
)
1229 item
.mask
|= TCIF_IMAGE
;
1230 item
.iImage
= iImage
++;
1234 item
.mask
&= ~TCIF_IMAGE
;
1237 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1238 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, (WPARAM
)i
, (LPARAM
)&item
);
1240 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 1, 0);
1245 /******************************************************************************
1246 * PROPSHEET_WizardSubclassProc
1248 * Subclassing window procedure for wizard extrior pages to prevent drawing
1249 * background and so drawing above the watermark.
1251 static LRESULT CALLBACK
1252 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1259 case WM_CTLCOLORSTATIC
:
1260 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1261 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1264 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1268 * Get the size of an in-memory Template
1270 *( Based on the code of PROPSHEET_CollectPageInfo)
1271 * See also dialog.c/DIALOG_ParseTemplate32().
1274 static UINT
GetTemplateSize(DLGTEMPLATE
* pTemplate
)
1277 const WORD
* p
= (const WORD
*)pTemplate
;
1278 BOOL istemplateex
= (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1283 /* DLGTEMPLATEEX (not defined in any std. header file) */
1285 TRACE("is DLGTEMPLATEEX\n");
1287 p
++; /* signature */
1288 p
+= 2; /* help ID */
1289 p
+= 2; /* ext style */
1296 TRACE("is DLGTEMPLATE\n");
1298 p
+= 2; /* ext style */
1301 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1317 TRACE("menu %s\n",debugstr_w((LPCWSTR
)p
));
1318 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1329 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1332 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1333 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1338 TRACE("title %s\n",debugstr_w((LPCWSTR
)p
));
1339 p
+= lstrlenW((LPCWSTR
)p
) + 1;
1341 /* font, if DS_SETFONT set */
1342 if ((DS_SETFONT
& ((istemplateex
)? ((MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1345 p
+=(istemplateex
)?3:1;
1346 TRACE("font %s\n",debugstr_w((LPCWSTR
)p
));
1347 p
+= lstrlenW( (LPCWSTR
)p
) + 1; /* the font name */
1350 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1351 * that are following the DLGTEMPLATE(EX) data */
1352 TRACE("%d items\n",nrofitems
);
1353 while (nrofitems
> 0)
1355 p
= (WORD
*)(((DWORD
)p
+ 3) & ~3); /* DWORD align */
1358 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1367 TRACE("class ordinal 0x%08lx\n",*(DWORD
*)p
);
1371 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1372 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1376 /* check title text */
1383 TRACE("text ordinal 0x%08lx\n",*(DWORD
*)p
);
1387 TRACE("text %s\n",debugstr_w((LPCWSTR
)p
));
1388 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1391 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1395 TRACE("%p %p size 0x%08x\n",p
, (WORD
*)pTemplate
,sizeof(WORD
)*(p
- (WORD
*)pTemplate
));
1396 return (p
- (WORD
*)pTemplate
)*sizeof(WORD
);
1400 /******************************************************************************
1401 * PROPSHEET_CreatePage
1405 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1407 const PropSheetInfo
* psInfo
,
1408 LPCPROPSHEETPAGEW ppshpage
)
1410 DLGTEMPLATE
* pTemplate
;
1415 TRACE("index %d\n", index
);
1417 if (ppshpage
== NULL
)
1422 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1424 pTemplate
= (DLGTEMPLATE
*)ppshpage
->u
.pResource
;
1425 resSize
= GetTemplateSize(pTemplate
);
1427 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1432 hResource
= FindResourceW(ppshpage
->hInstance
,
1433 ppshpage
->u
.pszTemplate
,
1438 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1440 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1444 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
1446 * Make a copy of the dialog template to make it writable
1454 hResource
= FindResourceA(ppshpage
->hInstance
,
1455 (LPSTR
)ppshpage
->u
.pszTemplate
,
1460 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1462 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1466 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
1468 * Make a copy of the dialog template to make it writable
1471 temp
= Alloc(resSize
);
1475 TRACE("copying pTemplate %p into temp %p (%ld)\n", pTemplate
, temp
, resSize
);
1476 memcpy(temp
, pTemplate
, resSize
);
1479 if (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
1481 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1482 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~DS_MODALFRAME
;
1483 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_CAPTION
;
1484 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_SYSMENU
;
1485 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_POPUP
;
1486 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_DISABLED
;
1487 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_VISIBLE
;
1488 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_THICKFRAME
;
1490 ((MyDLGTEMPLATEEX
*)pTemplate
)->exStyle
|= WS_EX_CONTROLPARENT
;
1494 pTemplate
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1495 pTemplate
->style
&= ~DS_MODALFRAME
;
1496 pTemplate
->style
&= ~WS_CAPTION
;
1497 pTemplate
->style
&= ~WS_SYSMENU
;
1498 pTemplate
->style
&= ~WS_POPUP
;
1499 pTemplate
->style
&= ~WS_DISABLED
;
1500 pTemplate
->style
&= ~WS_VISIBLE
;
1501 pTemplate
->style
&= ~WS_THICKFRAME
;
1503 pTemplate
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1506 if (psInfo
->proppage
[index
].useCallback
)
1507 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1508 (LPPROPSHEETPAGEW
)ppshpage
);
1510 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1511 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1514 ppshpage
->pfnDlgProc
,
1517 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1520 ppshpage
->pfnDlgProc
,
1522 /* Free a no more needed copy */
1526 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1528 /* Subclass exterior wizard pages */
1529 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1530 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1531 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1533 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1534 (DWORD_PTR
)ppshpage
);
1540 /******************************************************************************
1541 * PROPSHEET_LoadWizardBitmaps
1543 * Loads the watermark and header bitmaps for a wizard.
1545 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1547 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1549 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1550 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1551 considers hbmWatermark as valid. */
1552 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1553 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1555 ((PropSheetInfo
*)psInfo
)->ppshheader
.u4
.hbmWatermark
=
1556 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1559 /* Same behavior as for watermarks */
1560 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1561 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1563 ((PropSheetInfo
*)psInfo
)->ppshheader
.u5
.hbmHeader
=
1564 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1570 /******************************************************************************
1571 * PROPSHEET_ShowPage
1573 * Displays or creates the specified page.
1575 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1578 HWND hwndLineHeader
;
1579 LPCPROPSHEETPAGEW ppshpage
;
1581 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1582 if (index
== psInfo
->active_page
)
1584 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1585 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1589 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1590 if (psInfo
->proppage
[index
].hwndPage
== 0)
1592 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1595 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
1596 (ppshpage
->dwFlags
& PSP_USETITLE
))
1598 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1599 psInfo
->proppage
[index
].pszText
);
1602 if (psInfo
->active_page
!= -1)
1603 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1605 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1607 /* Synchronize current selection with tab control
1608 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1609 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1610 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1612 psInfo
->active_page
= index
;
1613 psInfo
->activeValid
= TRUE
;
1615 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1617 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1618 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1620 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1621 ShowWindow(hwndLineHeader
, SW_HIDE
);
1623 ShowWindow(hwndLineHeader
, SW_SHOW
);
1629 /******************************************************************************
1632 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1636 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1641 TRACE("active_page %d\n", psInfo
->active_page
);
1642 if (psInfo
->active_page
< 0)
1645 psn
.hdr
.code
= PSN_WIZBACK
;
1646 psn
.hdr
.hwndFrom
= hwndDlg
;
1650 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1652 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1655 else if (result
== 0)
1656 idx
= psInfo
->active_page
- 1;
1658 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1660 if (idx
>= 0 && idx
< psInfo
->nPages
)
1662 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1663 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1668 /******************************************************************************
1671 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1675 LRESULT msgResult
= 0;
1676 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1680 TRACE("active_page %d\n", psInfo
->active_page
);
1681 if (psInfo
->active_page
< 0)
1684 psn
.hdr
.code
= PSN_WIZNEXT
;
1685 psn
.hdr
.hwndFrom
= hwndDlg
;
1689 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1691 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1692 if (msgResult
== -1)
1694 else if (msgResult
== 0)
1695 idx
= psInfo
->active_page
+ 1;
1697 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1699 if (idx
< psInfo
->nPages
)
1701 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1702 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1708 /******************************************************************************
1711 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1715 LRESULT msgResult
= 0;
1716 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1719 TRACE("active_page %d\n", psInfo
->active_page
);
1720 if (psInfo
->active_page
< 0)
1723 psn
.hdr
.code
= PSN_WIZFINISH
;
1724 psn
.hdr
.hwndFrom
= hwndDlg
;
1728 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1730 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1732 TRACE("msg result %ld\n", msgResult
);
1737 if (psInfo
->isModeless
)
1738 psInfo
->activeValid
= FALSE
;
1740 psInfo
->ended
= TRUE
;
1745 /******************************************************************************
1748 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1753 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1756 TRACE("active_page %d\n", psInfo
->active_page
);
1757 if (psInfo
->active_page
< 0)
1760 psn
.hdr
.hwndFrom
= hwndDlg
;
1766 * Send PSN_KILLACTIVE to the current page.
1768 psn
.hdr
.code
= PSN_KILLACTIVE
;
1770 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1772 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1776 * Send PSN_APPLY to all pages.
1778 psn
.hdr
.code
= PSN_APPLY
;
1779 psn
.lParam
= lParam
;
1781 for (i
= 0; i
< psInfo
->nPages
; i
++)
1783 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1786 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1788 case PSNRET_INVALID
:
1789 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1791 case PSNRET_INVALID_NOCHANGEPAGE
:
1799 psInfo
->activeValid
= FALSE
;
1801 else if(psInfo
->active_page
>= 0)
1803 psn
.hdr
.code
= PSN_SETACTIVE
;
1805 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1806 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1812 /******************************************************************************
1815 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1817 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1823 TRACE("active_page %d\n", psInfo
->active_page
);
1824 if (psInfo
->active_page
< 0)
1827 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1828 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1829 psn
.hdr
.hwndFrom
= hwndDlg
;
1833 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1836 psn
.hdr
.code
= PSN_RESET
;
1837 psn
.lParam
= lParam
;
1839 for (i
= 0; i
< psInfo
->nPages
; i
++)
1841 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1844 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1847 if (psInfo
->isModeless
)
1849 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1850 psInfo
->activeValid
= FALSE
;
1853 psInfo
->ended
= TRUE
;
1856 /******************************************************************************
1859 static void PROPSHEET_Help(HWND hwndDlg
)
1861 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1866 TRACE("active_page %d\n", psInfo
->active_page
);
1867 if (psInfo
->active_page
< 0)
1870 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1871 psn
.hdr
.code
= PSN_HELP
;
1872 psn
.hdr
.hwndFrom
= hwndDlg
;
1876 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1879 /******************************************************************************
1882 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1885 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1889 if (!psInfo
) return;
1891 * Set the dirty flag of this page.
1893 for (i
= 0; i
< psInfo
->nPages
; i
++)
1895 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1896 psInfo
->proppage
[i
].isDirty
= TRUE
;
1900 * Enable the Apply button.
1902 if (psInfo
->hasApply
)
1904 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1906 EnableWindow(hwndApplyBtn
, TRUE
);
1910 /******************************************************************************
1911 * PROPSHEET_UnChanged
1913 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1916 BOOL noPageDirty
= TRUE
;
1917 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1918 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1922 if ( !psInfo
) return;
1923 for (i
= 0; i
< psInfo
->nPages
; i
++)
1925 /* set the specified page as clean */
1926 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1927 psInfo
->proppage
[i
].isDirty
= FALSE
;
1929 /* look to see if there's any dirty pages */
1930 if (psInfo
->proppage
[i
].isDirty
)
1931 noPageDirty
= FALSE
;
1935 * Disable Apply button.
1938 EnableWindow(hwndApplyBtn
, FALSE
);
1941 /******************************************************************************
1942 * PROPSHEET_PressButton
1944 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1946 TRACE("buttonID %d\n", buttonID
);
1949 case PSBTN_APPLYNOW
:
1950 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1953 PROPSHEET_Back(hwndDlg
);
1956 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1959 PROPSHEET_Finish(hwndDlg
);
1962 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1965 PROPSHEET_Next(hwndDlg
);
1968 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1971 FIXME("Invalid button index %d\n", buttonID
);
1976 /*************************************************************************
1977 * BOOL PROPSHEET_CanSetCurSel [Internal]
1979 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1982 * hwndDlg [I] handle to a Dialog hWnd
1985 * TRUE if Current Selection can change
1989 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
1991 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1997 TRACE("active_page %d\n", psInfo
->active_page
);
2004 if (psInfo
->active_page
< 0)
2011 * Notify the current page.
2013 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
2014 psn
.hdr
.code
= PSN_KILLACTIVE
;
2015 psn
.hdr
.hwndFrom
= hwndDlg
;
2019 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2022 TRACE("<-- %d\n", res
);
2026 /******************************************************************************
2027 * PROPSHEET_SetCurSel
2029 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
2032 HPROPSHEETPAGE hpage
2035 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2036 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
2037 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2039 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
2040 /* hpage takes precedence over index */
2042 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2044 if (index
< 0 || index
>= psInfo
->nPages
)
2046 TRACE("Could not find page to select!\n");
2054 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2057 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
2059 psn
.hdr
.code
= PSN_SETACTIVE
;
2060 psn
.hdr
.hwndFrom
= hwndDlg
;
2064 if (!psInfo
->proppage
[index
].hwndPage
) {
2065 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
2068 /* Resize the property sheet page to the fit in the Tab control
2069 * (for regular property sheets) or to fit in the client area (for
2071 * NOTE: The resizing happens every time the page is selected and
2072 * not only when it's created (some applications depend on it). */
2073 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2074 TRACE("setting page %p, rc (%ld,%ld)-(%ld,%ld) w=%ld, h=%ld\n",
2075 psInfo
->proppage
[index
].hwndPage
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
2076 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2077 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2079 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2081 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2088 WARN("Tried to skip before first property sheet page!\n");
2091 if (index
>= psInfo
->nPages
) {
2092 WARN("Tried to skip after last property sheet page!\n");
2093 index
= psInfo
->nPages
-1;
2097 else if (result
!= 0)
2099 int old_index
= index
;
2100 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2101 if(index
>= psInfo
->nPages
) {
2103 WARN("Tried to skip to nonexistant page by res id\n");
2110 * Display the new page.
2112 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2114 if (psInfo
->proppage
[index
].hasHelp
)
2115 EnableWindow(hwndHelp
, TRUE
);
2117 EnableWindow(hwndHelp
, FALSE
);
2122 /******************************************************************************
2123 * PROPSHEET_SetCurSelId
2125 * Selects the page, specified by resource id.
2127 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2130 PropSheetInfo
* psInfo
=
2131 (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2133 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2134 if (idx
< psInfo
->nPages
)
2136 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2137 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2141 /******************************************************************************
2142 * PROPSHEET_SetTitleA
2144 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2146 if(HIWORD(lpszText
))
2149 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2150 szTitle
, sizeof(szTitle
));
2151 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2155 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2159 /******************************************************************************
2160 * PROPSHEET_SetTitleW
2162 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2164 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2167 TRACE("'%s' (style %08lx)\n", debugstr_w(lpszText
), dwStyle
);
2168 if (HIWORD(lpszText
) == 0) {
2169 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2170 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)-sizeof(WCHAR
)))
2174 if (dwStyle
& PSH_PROPTITLE
)
2177 int lentitle
= strlenW(lpszText
);
2178 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2180 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2181 strcpyW(dest
, psInfo
->strPropertiesFor
);
2182 strcatW(dest
, lpszText
);
2184 SetWindowTextW(hwndDlg
, dest
);
2188 SetWindowTextW(hwndDlg
, lpszText
);
2191 /******************************************************************************
2192 * PROPSHEET_SetFinishTextA
2194 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2196 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2198 TRACE("'%s'\n", lpszText
);
2199 /* Set text, show and enable the Finish button */
2200 SetWindowTextA(hwndButton
, lpszText
);
2201 ShowWindow(hwndButton
, SW_SHOW
);
2202 EnableWindow(hwndButton
, TRUE
);
2204 /* Make it default pushbutton */
2205 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2207 /* Hide Back button */
2208 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2209 ShowWindow(hwndButton
, SW_HIDE
);
2211 /* Hide Next button */
2212 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2213 ShowWindow(hwndButton
, SW_HIDE
);
2216 /******************************************************************************
2217 * PROPSHEET_SetFinishTextW
2219 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2221 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2223 TRACE("'%s'\n", debugstr_w(lpszText
));
2224 /* Set text, show and enable the Finish button */
2225 SetWindowTextW(hwndButton
, lpszText
);
2226 ShowWindow(hwndButton
, SW_SHOW
);
2227 EnableWindow(hwndButton
, TRUE
);
2229 /* Make it default pushbutton */
2230 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2232 /* Hide Back button */
2233 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2234 ShowWindow(hwndButton
, SW_HIDE
);
2236 /* Hide Next button */
2237 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2238 ShowWindow(hwndButton
, SW_HIDE
);
2241 /******************************************************************************
2242 * PROPSHEET_QuerySiblings
2244 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2245 WPARAM wParam
, LPARAM lParam
)
2249 LRESULT msgResult
= 0;
2250 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2252 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2254 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2255 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2263 /******************************************************************************
2266 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
2267 HPROPSHEETPAGE hpage
)
2269 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2271 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2273 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2275 TRACE("hpage %p\n", hpage
);
2277 * Allocate and fill in a new PropPageInfo entry.
2279 psInfo
->proppage
= (PropPageInfo
*) ReAlloc(psInfo
->proppage
,
2280 sizeof(PropPageInfo
) *
2281 (psInfo
->nPages
+ 1));
2282 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, psInfo
->nPages
))
2285 psInfo
->proppage
[psInfo
->nPages
].hpage
= hpage
;
2287 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2289 /* Create the page but don't show it */
2290 PROPSHEET_CreatePage(hwndDlg
, psInfo
->nPages
, psInfo
, ppsp
);
2294 * Add a new tab to the tab control.
2296 item
.mask
= TCIF_TEXT
;
2297 item
.pszText
= (LPWSTR
) psInfo
->proppage
[psInfo
->nPages
].pszText
;
2298 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2300 if (psInfo
->hImageList
)
2302 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2305 if ( psInfo
->proppage
[psInfo
->nPages
].hasIcon
)
2307 item
.mask
|= TCIF_IMAGE
;
2308 item
.iImage
= psInfo
->nPages
;
2311 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, psInfo
->nPages
+ 1,
2316 /* If it is the only page - show it */
2317 if(psInfo
->nPages
== 1)
2318 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2322 /******************************************************************************
2323 * PROPSHEET_RemovePage
2325 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2327 HPROPSHEETPAGE hpage
)
2329 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2331 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2332 PropPageInfo
* oldPages
;
2334 TRACE("index %d, hpage %p\n", index
, hpage
);
2339 * hpage takes precedence over index.
2343 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2346 /* Make sure that index is within range */
2347 if (index
< 0 || index
>= psInfo
->nPages
)
2349 TRACE("Could not find page to remove!\n");
2353 TRACE("total pages %d removing page %d active page %d\n",
2354 psInfo
->nPages
, index
, psInfo
->active_page
);
2356 * Check if we're removing the active page.
2358 if (index
== psInfo
->active_page
)
2360 if (psInfo
->nPages
> 1)
2364 /* activate previous page */
2365 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2369 /* activate the next page */
2370 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2371 psInfo
->active_page
= index
;
2376 psInfo
->active_page
= -1;
2377 if (!psInfo
->isModeless
)
2379 psInfo
->ended
= TRUE
;
2384 else if (index
< psInfo
->active_page
)
2385 psInfo
->active_page
--;
2387 /* Unsubclass the page dialog window */
2388 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2389 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2390 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2392 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2393 PROPSHEET_WizardSubclassProc
, 1);
2396 /* Destroy page dialog window */
2397 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2399 /* Free page resources */
2400 if(psInfo
->proppage
[index
].hpage
)
2402 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2404 if ((psp
->dwFlags
& PSP_USETITLE
) && psInfo
->proppage
[index
].pszText
)
2405 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2407 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2410 /* Remove the tab */
2411 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2413 oldPages
= psInfo
->proppage
;
2415 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2418 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2420 if (index
< psInfo
->nPages
)
2421 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2422 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2429 /******************************************************************************
2430 * PROPSHEET_SetWizButtons
2432 * This code will work if (and assumes that) the Next button is on top of the
2433 * Finish button. ie. Finish comes after Next in the Z order.
2434 * This means make sure the dialog template reflects this.
2437 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2439 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2440 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2441 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2443 TRACE("%ld\n", dwFlags
);
2445 EnableWindow(hwndBack
, FALSE
);
2446 EnableWindow(hwndNext
, FALSE
);
2447 EnableWindow(hwndFinish
, FALSE
);
2449 if (dwFlags
& PSWIZB_BACK
)
2450 EnableWindow(hwndBack
, TRUE
);
2452 if (dwFlags
& PSWIZB_NEXT
)
2454 /* Hide the Finish button */
2455 ShowWindow(hwndFinish
, SW_HIDE
);
2457 /* Show and enable the Next button */
2458 ShowWindow(hwndNext
, SW_SHOW
);
2459 EnableWindow(hwndNext
, TRUE
);
2461 /* Set the Next button as the default pushbutton */
2462 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2465 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2467 /* Hide the Next button */
2468 ShowWindow(hwndNext
, SW_HIDE
);
2470 /* Show the Finish button */
2471 ShowWindow(hwndFinish
, SW_SHOW
);
2473 if (dwFlags
& PSWIZB_FINISH
)
2474 EnableWindow(hwndFinish
, TRUE
);
2476 /* Set the Finish button as the default pushbutton */
2477 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2481 /******************************************************************************
2482 * PROPSHEET_InsertPage
2484 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2486 if (!HIWORD(hpageInsertAfter
))
2487 FIXME("(%p, %d, %p): stub\n", hwndDlg
, LOWORD(hpageInsertAfter
), hpage
);
2489 FIXME("(%p, %p, %p): stub\n", hwndDlg
, hpageInsertAfter
, hpage
);
2493 /******************************************************************************
2494 * PROPSHEET_SetHeaderTitleW
2496 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderTitle
)
2498 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderTitle
));
2501 /******************************************************************************
2502 * PROPSHEET_SetHeaderTitleA
2504 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderTitle
)
2506 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderTitle
));
2509 /******************************************************************************
2510 * PROPSHEET_SetHeaderSubTitleW
2512 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderSubTitle
)
2514 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderSubTitle
));
2517 /******************************************************************************
2518 * PROPSHEET_SetHeaderSubTitleA
2520 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderSubTitle
)
2522 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderSubTitle
));
2525 /******************************************************************************
2526 * PROPSHEET_HwndToIndex
2528 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2531 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2534 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2536 for (index
= 0; index
< psInfo
->nPages
; index
++)
2537 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2539 WARN("%p not found\n", hPageDlg
);
2543 /******************************************************************************
2544 * PROPSHEET_IndexToHwnd
2546 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2548 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2550 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2551 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2552 WARN("%d out of range.\n", iPageIndex
);
2555 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2558 /******************************************************************************
2559 * PROPSHEET_PageToIndex
2561 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2564 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2567 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2569 for (index
= 0; index
< psInfo
->nPages
; index
++)
2570 if (psInfo
->proppage
[index
].hpage
== hPage
)
2572 WARN("%p not found\n", hPage
);
2576 /******************************************************************************
2577 * PROPSHEET_IndexToPage
2579 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2581 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2583 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2584 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2585 WARN("%d out of range.\n", iPageIndex
);
2588 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2591 /******************************************************************************
2592 * PROPSHEET_IdToIndex
2594 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2596 FIXME("(%p, %d): stub\n", hwndDlg
, iPageId
);
2600 /******************************************************************************
2601 * PROPSHEET_IndexToId
2603 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2605 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2607 LPCPROPSHEETPAGEW psp
;
2608 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2609 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2610 WARN("%d out of range.\n", iPageIndex
);
2613 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2614 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| HIWORD(psp
->u
.pszTemplate
)) {
2617 return (LRESULT
)psp
->u
.pszTemplate
;
2620 /******************************************************************************
2621 * PROPSHEET_GetResult
2623 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2625 FIXME("(%p): stub\n", hwndDlg
);
2629 /******************************************************************************
2630 * PROPSHEET_RecalcPageSizes
2632 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2634 FIXME("(%p): stub\n", hwndDlg
);
2638 /******************************************************************************
2639 * PROPSHEET_GetPageIndex
2641 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2642 * the array of PropPageInfo.
2644 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, PropSheetInfo
* psInfo
)
2649 TRACE("hpage %p\n", hpage
);
2650 while ((index
< psInfo
->nPages
) && (found
== FALSE
))
2652 if (psInfo
->proppage
[index
].hpage
== hpage
)
2664 /******************************************************************************
2667 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2670 PropSheetInfo
* psInfo
= (PropSheetInfo
*) RemovePropW(hwndDlg
,
2674 if (!psInfo
) return;
2675 if (HIWORD(psInfo
->ppshheader
.pszCaption
))
2676 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2678 for (i
= 0; i
< psInfo
->nPages
; i
++)
2680 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2682 /* Unsubclass the page dialog window */
2683 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2684 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2685 (psp
->dwFlags
& PSP_HIDEHEADER
))
2687 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2688 PROPSHEET_WizardSubclassProc
, 1);
2691 if(psInfo
->proppage
[i
].hwndPage
)
2692 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2696 if ((psp
->dwFlags
& PSP_USETITLE
) && psInfo
->proppage
[i
].pszText
)
2697 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2699 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2703 DeleteObject(psInfo
->hFont
);
2704 DeleteObject(psInfo
->hFontBold
);
2705 /* If we created the bitmaps, destroy them */
2706 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2707 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2708 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2709 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2710 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2711 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2713 Free(psInfo
->proppage
);
2714 Free(psInfo
->strPropertiesFor
);
2715 ImageList_Destroy(psInfo
->hImageList
);
2717 GlobalFree((HGLOBAL
)psInfo
);
2720 static INT
do_loop(PropSheetInfo
*psInfo
)
2724 HWND hwnd
= psInfo
->hwnd
;
2726 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2731 if(!IsDialogMessageW(hwnd
, &msg
))
2733 TranslateMessage(&msg
);
2734 DispatchMessageW(&msg
);
2740 PostQuitMessage(msg
.wParam
);
2744 DestroyWindow(hwnd
);
2748 /******************************************************************************
2749 * PropertySheet (COMCTL32.@)
2750 * PropertySheetA (COMCTL32.@)
2752 * Creates a property sheet in the specified property sheet header.
2755 * Modal property sheets: Positive if successful or -1 otherwise.
2756 * Modeless property sheets: Property sheet handle.
2758 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2759 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2761 INT WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2764 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2765 sizeof(PropSheetInfo
));
2769 TRACE("(%p)\n", lppsh
);
2771 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2773 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2775 pByte
= (BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2777 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2779 if (!(lppsh
->dwFlags
& PSH_PROPSHEETPAGE
))
2780 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2783 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2784 pByte
+= ((LPPROPSHEETPAGEA
)pByte
)->dwSize
;
2787 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2790 if (lppsh
->dwFlags
& PSH_PROPSHEETPAGE
)
2791 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2797 psInfo
->unicode
= FALSE
;
2798 psInfo
->ended
= FALSE
;
2800 bRet
= PROPSHEET_CreateDialog(psInfo
);
2801 if(!psInfo
->isModeless
)
2802 bRet
= do_loop(psInfo
);
2807 /******************************************************************************
2808 * PropertySheetW (COMCTL32.@)
2810 * See PropertySheetA.
2812 INT WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2815 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2816 sizeof(PropSheetInfo
));
2820 TRACE("(%p)\n", lppsh
);
2822 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2824 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2826 pByte
= (BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2828 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2830 if (!(lppsh
->dwFlags
& PSH_PROPSHEETPAGE
))
2831 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2834 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2835 pByte
+= ((LPPROPSHEETPAGEW
)pByte
)->dwSize
;
2838 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2841 if (lppsh
->dwFlags
& PSH_PROPSHEETPAGE
)
2842 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2848 psInfo
->unicode
= TRUE
;
2849 psInfo
->ended
= FALSE
;
2851 bRet
= PROPSHEET_CreateDialog(psInfo
);
2852 if(!psInfo
->isModeless
)
2853 bRet
= do_loop(psInfo
);
2858 /******************************************************************************
2859 * CreatePropertySheetPage (COMCTL32.@)
2860 * CreatePropertySheetPageA (COMCTL32.@)
2862 * Creates a new property sheet page.
2865 * Success: Handle to new property sheet page.
2869 * An application must use the PSM_ADDPAGE message to add the new page to
2870 * an existing property sheet.
2872 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2873 LPCPROPSHEETPAGEA lpPropSheetPage
)
2875 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2877 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEA
)));
2879 ppsp
->dwFlags
&= ~ PSP_INTERNAL_UNICODE
;
2880 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( ppsp
->u
.pszTemplate
) )
2882 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
);
2884 ppsp
->u
.pszTemplate
= Alloc( len
+1 );
2885 strcpy( (LPSTR
)ppsp
->u
.pszTemplate
, lpPropSheetPage
->u
.pszTemplate
);
2887 if ( (ppsp
->dwFlags
& PSP_USEICONID
) && HIWORD( ppsp
->u2
.pszIcon
) )
2889 PROPSHEET_AtoW(&ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2892 if ((ppsp
->dwFlags
& PSP_USETITLE
) && HIWORD( ppsp
->pszTitle
))
2894 PROPSHEET_AtoW(&ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2896 else if ( !(ppsp
->dwFlags
& PSP_USETITLE
) )
2897 ppsp
->pszTitle
= NULL
;
2899 return (HPROPSHEETPAGE
)ppsp
;
2902 /******************************************************************************
2903 * CreatePropertySheetPageW (COMCTL32.@)
2905 * See CreatePropertySheetA.
2907 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
2909 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2911 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEW
)));
2913 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
2915 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( ppsp
->u
.pszTemplate
) )
2917 int len
= strlenW(lpPropSheetPage
->u
.pszTemplate
);
2919 ppsp
->u
.pszTemplate
= Alloc( (len
+1)*sizeof (WCHAR
) );
2920 strcpyW( (WCHAR
*)ppsp
->u
.pszTemplate
, lpPropSheetPage
->u
.pszTemplate
);
2922 if ( (ppsp
->dwFlags
& PSP_USEICONID
) && HIWORD( ppsp
->u2
.pszIcon
) )
2924 int len
= strlenW(lpPropSheetPage
->u2
.pszIcon
);
2925 ppsp
->u2
.pszIcon
= Alloc( (len
+1)*sizeof (WCHAR
) );
2926 strcpyW( (WCHAR
*)ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2929 if ((ppsp
->dwFlags
& PSP_USETITLE
) && HIWORD( ppsp
->pszTitle
))
2931 int len
= strlenW(lpPropSheetPage
->pszTitle
);
2932 ppsp
->pszTitle
= Alloc( (len
+1)*sizeof (WCHAR
) );
2933 strcpyW( (WCHAR
*)ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2935 else if ( !(ppsp
->dwFlags
& PSP_USETITLE
) )
2936 ppsp
->pszTitle
= NULL
;
2938 return (HPROPSHEETPAGE
)ppsp
;
2941 /******************************************************************************
2942 * DestroyPropertySheetPage (COMCTL32.@)
2944 * Destroys a property sheet page previously created with
2945 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
2952 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
2954 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
2959 if ( !(psp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( psp
->u
.pszTemplate
) )
2960 Free ((LPVOID
)psp
->u
.pszTemplate
);
2962 if ( (psp
->dwFlags
& PSP_USEICONID
) && HIWORD( psp
->u2
.pszIcon
) )
2963 Free ((LPVOID
)psp
->u2
.pszIcon
);
2965 if ((psp
->dwFlags
& PSP_USETITLE
) && HIWORD( psp
->pszTitle
))
2966 Free ((LPVOID
)psp
->pszTitle
);
2973 /******************************************************************************
2974 * PROPSHEET_IsDialogMessage
2976 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
2978 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
2981 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
2984 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
2987 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
2989 if (!(dlgCode
& DLGC_WANTMESSAGE
))
2991 switch (lpMsg
->wParam
)
2994 if (GetKeyState(VK_SHIFT
) & 0x8000)
3000 case VK_NEXT
: new_page
= 1; break;
3001 case VK_PRIOR
: new_page
= -1; break;
3007 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3009 new_page
+= psInfo
->active_page
;
3012 new_page
= psInfo
->nPages
- 1;
3013 else if (new_page
>= psInfo
->nPages
)
3016 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3023 return IsDialogMessageW(hwnd
, lpMsg
);
3026 /******************************************************************************
3027 * PROPSHEET_DoCommand
3029 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3035 case IDC_APPLY_BUTTON
:
3037 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3039 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3044 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3048 if (psInfo
->restartWindows
)
3049 result
= ID_PSRESTARTWINDOWS
;
3051 /* reboot system takes precedence over restart windows */
3052 if (psInfo
->rebootSystem
)
3053 result
= ID_PSREBOOTSYSTEM
;
3055 if (psInfo
->isModeless
)
3056 psInfo
->activeValid
= FALSE
;
3058 psInfo
->ended
= TRUE
;
3061 EnableWindow(hwndApplyBtn
, FALSE
);
3066 case IDC_BACK_BUTTON
:
3067 PROPSHEET_Back(hwnd
);
3070 case IDC_NEXT_BUTTON
:
3071 PROPSHEET_Next(hwnd
);
3074 case IDC_FINISH_BUTTON
:
3075 PROPSHEET_Finish(hwnd
);
3079 PROPSHEET_Cancel(hwnd
, 0);
3083 PROPSHEET_Help(hwnd
);
3093 /******************************************************************************
3096 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3098 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3103 HPALETTE hOldPal
= 0;
3107 LPCPROPSHEETPAGEW ppshpage
;
3108 WCHAR szBuffer
[256];
3111 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3114 hdcSrc
= CreateCompatibleDC(0);
3115 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3117 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3118 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3120 if ( (!(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3121 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3122 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3124 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3126 COLORREF clrOld
= 0;
3129 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3130 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3132 GetClientRect(hwndLineHeader
, &r
);
3133 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3134 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3136 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), (LPVOID
)&bm
);
3138 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3140 /* Fill the unoccupied part of the header with color of the
3141 * left-top pixel, but do it only when needed.
3143 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3145 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3146 CopyRect(&r
, &rzone
);
3147 if (bm
.bmWidth
< r
.right
)
3149 r
.left
= bm
.bmWidth
;
3150 FillRect(hdc
, &r
, hbr
);
3152 if (bm
.bmHeight
< r
.bottom
)
3155 r
.top
= bm
.bmHeight
;
3156 FillRect(hdc
, &r
, hbr
);
3161 /* Draw the header itself. */
3163 bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3164 hdcSrc
, 0, 0, SRCCOPY
);
3168 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3169 FillRect(hdc
, &rzone
, hbr
);
3171 /* Draw the header bitmap. It's always centered like a
3172 * common 49 x 49 bitmap. */
3173 BitBlt(hdc
, rzone
.right
- 49 - ((rzone
.bottom
- 49) / 2),
3174 (rzone
.bottom
- 49) / 2,
3175 bm
.bmWidth
, bm
.bmHeight
,
3176 hdcSrc
, 0, 0, SRCCOPY
);
3178 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3179 * if its height is smaller than 49 pixels. Because the reason
3180 * for this bug is unknown the current code doesn't try to
3184 clrOld
= SetTextColor (hdc
, 0x00000000);
3185 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3187 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3188 SetRect(&r
, 20, 10, 0, 0);
3189 if (HIWORD(ppshpage
->pszHeaderTitle
))
3191 if (psInfo
->unicode
)
3192 DrawTextW(hdc
, (LPWSTR
)ppshpage
->pszHeaderTitle
,
3193 -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3195 DrawTextA(hdc
, (LPCSTR
)ppshpage
->pszHeaderTitle
,
3196 -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3200 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT
)ppshpage
->pszHeaderTitle
,
3204 DrawTextW(hdc
, szBuffer
, nLength
,
3205 &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3210 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3211 SelectObject(hdc
, psInfo
->hFont
);
3212 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3213 if (HIWORD(ppshpage
->pszHeaderTitle
))
3215 if (psInfo
->unicode
)
3216 DrawTextW(hdc
, (LPWSTR
)ppshpage
->pszHeaderSubTitle
,
3217 -1, &r
, DT_LEFT
| DT_SINGLELINE
);
3219 DrawTextA(hdc
, (LPCSTR
)ppshpage
->pszHeaderSubTitle
,
3220 -1, &r
, DT_LEFT
| DT_SINGLELINE
);
3224 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT
)ppshpage
->pszHeaderSubTitle
,
3228 DrawTextW(hdc
, szBuffer
, nLength
,
3229 &r
, DT_LEFT
| DT_SINGLELINE
);
3234 offsety
= rzone
.bottom
+ 2;
3236 SetTextColor(hdc
, clrOld
);
3237 SetBkMode(hdc
, oldBkMode
);
3238 SelectObject(hdc
, hOldFont
);
3239 SelectObject(hdcSrc
, hbmp
);
3242 if ( (ppshpage
->dwFlags
& PSP_HIDEHEADER
) &&
3243 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3244 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3246 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3248 GetClientRect(hwndLine
, &r
);
3249 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3253 rzone
.right
= r
.right
;
3254 rzone
.bottom
= r
.top
- 1;
3256 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3257 FillRect(hdc
, &rzone
, hbr
);
3259 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), (LPVOID
)&bm
);
3260 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3262 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3263 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3265 /* If the bitmap is not big enough, fill the remaining area
3266 with the color of pixel (0,0) of bitmap - see MSDN */
3267 if (r
.top
> bm
.bmHeight
) {
3268 r
.bottom
= r
.top
- 1;
3269 r
.top
= bm
.bmHeight
;
3271 r
.right
= bm
.bmWidth
;
3272 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3273 FillRect(hdc
, &r
, hbr
);
3277 SelectObject(hdcSrc
, hbmp
);
3280 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3281 SelectPalette(hdc
, hOldPal
, FALSE
);
3285 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3290 /******************************************************************************
3291 * PROPSHEET_DialogProc
3294 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3296 TRACE("hwnd=%p msg=0x%04x wparam=%x lparam=%lx\n",
3297 hwnd
, uMsg
, wParam
, lParam
);
3303 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3304 WCHAR
* strCaption
= (WCHAR
*)Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3305 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3306 LPCPROPSHEETPAGEW ppshpage
;
3310 /* Using PropSheetInfoStr to store extra data doesn't match the native
3311 * common control: native uses TCM_[GS]ETITEM
3313 SetPropW(hwnd
, PropSheetInfoStr
, (HANDLE
)psInfo
);
3316 * psInfo->hwnd is not being used by WINE code - it exists
3317 * for compatibility with "real" Windoze. The same about
3318 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3321 psInfo
->hwnd
= hwnd
;
3322 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3324 /* set up the Next and Back buttons by default */
3325 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3328 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3329 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3330 logFont
.lfWeight
= FW_BOLD
;
3331 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3334 * Small icon in the title bar.
3336 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3337 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3340 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3341 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3343 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3344 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3345 psInfo
->ppshheader
.u
.pszIcon
,
3350 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3352 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3355 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3356 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3358 psInfo
->strPropertiesFor
= strCaption
;
3360 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3362 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3364 PROPSHEET_LoadWizardBitmaps(psInfo
);
3366 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3368 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3369 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3370 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3374 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3376 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3377 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3381 if (psInfo
->useCallback
)
3382 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
,
3383 PSCB_INITIALIZED
, (LPARAM
)0);
3385 idx
= psInfo
->active_page
;
3386 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[idx
].hpage
;
3387 psInfo
->active_page
= -1;
3389 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3391 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3392 * as some programs call TCM_GETCURSEL to get the current selection
3393 * from which to switch to the next page */
3394 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3396 if (!HIWORD(psInfo
->ppshheader
.pszCaption
) &&
3397 psInfo
->ppshheader
.hInstance
)
3401 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3402 (UINT
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3403 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3407 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3408 psInfo
->ppshheader
.pszCaption
);
3415 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3419 PROPSHEET_CleanUp(hwnd
);
3423 PROPSHEET_Cancel(hwnd
, 1);
3427 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3429 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3434 /* No default handler, forward notification to active page */
3435 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3437 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3438 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3444 switch(wParam
& 0xfff0)
3447 PROPSHEET_Cancel(hwnd
, 1);
3456 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3458 if (pnmh
->code
== TCN_SELCHANGE
)
3460 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3461 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3464 if(pnmh
->code
== TCN_SELCHANGING
)
3466 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3467 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3474 case WM_SYSCOLORCHANGE
:
3475 COMCTL32_RefreshSysColors();
3478 case PSM_GETCURRENTPAGEHWND
:
3480 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3487 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3488 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3490 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3496 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3500 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3503 case PSM_GETTABCONTROL
:
3505 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3507 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3516 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3517 if(msgResult
!= FALSE
)
3519 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3522 (HPROPSHEETPAGE
)lParam
);
3525 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3530 case PSM_CANCELTOCLOSE
:
3532 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3533 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3534 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3536 EnableWindow(hwndCancel
, FALSE
);
3537 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, sizeof(buf
)))
3538 SetWindowTextW(hwndOK
, buf
);
3543 case PSM_RESTARTWINDOWS
:
3545 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3551 psInfo
->restartWindows
= TRUE
;
3555 case PSM_REBOOTSYSTEM
:
3557 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3563 psInfo
->rebootSystem
= TRUE
;
3568 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3572 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3577 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3579 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3584 case PSM_QUERYSIBLINGS
:
3586 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3588 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3596 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3597 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3598 * on success or FALSE otherwise, as specified on MSDN Online.
3599 * Also see the MFC code for
3600 * CPropertySheet::AddPage(CPropertyPage* pPage).
3603 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3605 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3610 case PSM_REMOVEPAGE
:
3611 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3614 case PSM_ISDIALOGMESSAGE
:
3616 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3617 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3621 case PSM_PRESSBUTTON
:
3622 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3625 case PSM_SETFINISHTEXTA
:
3626 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3629 case PSM_SETWIZBUTTONS
:
3630 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3633 case PSM_SETCURSELID
:
3634 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3637 case PSM_SETFINISHTEXTW
:
3638 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3641 case PSM_INSERTPAGE
:
3643 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3644 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3648 case PSM_SETHEADERTITLEW
:
3649 PROPSHEET_SetHeaderTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3652 case PSM_SETHEADERTITLEA
:
3653 PROPSHEET_SetHeaderTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3656 case PSM_SETHEADERSUBTITLEW
:
3657 PROPSHEET_SetHeaderSubTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3660 case PSM_SETHEADERSUBTITLEA
:
3661 PROPSHEET_SetHeaderSubTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3664 case PSM_HWNDTOINDEX
:
3666 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3667 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3671 case PSM_INDEXTOHWND
:
3673 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3674 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3678 case PSM_PAGETOINDEX
:
3680 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3681 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3685 case PSM_INDEXTOPAGE
:
3687 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3688 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3694 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3695 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3701 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3702 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3708 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3709 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3713 case PSM_RECALCPAGESIZES
:
3715 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3716 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);