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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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
36 * o PSM_RECALCPAGESIZES
37 * o PSM_SETHEADERSUBTITLE
38 * o PSM_SETHEADERTITLE
43 * o PSN_QUERYINITIALFOCUS
44 * o PSN_TRANSLATEACCELERATOR
47 * o PSH_STRETCHWATERMARK
51 * o PSP_USEFUSIONCONTEXT
58 #define NONAMELESSUNION
59 #define NONAMELESSSTRUCT
70 #include "wine/debug.h"
71 #include "wine/unicode.h"
73 /******************************************************************************
97 } MyDLGITEMTEMPLATEEX
;
100 typedef struct tagPropPageInfo
102 HPROPSHEETPAGE hpage
; /* to keep track of pages not passed to PropertySheet */
111 typedef struct tagPropSheetInfo
114 PROPSHEETHEADERW ppshheader
;
116 LPWSTR strPropertiesFor
;
126 PropPageInfo
* proppage
;
131 HIMAGELIST hImageList
;
142 /******************************************************************************
143 * Defines and global variables
146 static 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 PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
);
165 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
);
166 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
);
167 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
170 HPROPSHEETPAGE hpage
);
171 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, const PropSheetInfo
* psInfo
);
172 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
);
173 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
);
175 static INT_PTR CALLBACK
176 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
178 WINE_DEFAULT_DEBUG_CHANNEL(propsheet
);
180 #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");}
181 /******************************************************************************
182 * PROPSHEET_UnImplementedFlags
184 * Document use of flags we don't implement yet.
186 static VOID
PROPSHEET_UnImplementedFlags(DWORD dwFlags
)
193 * unhandled header flags:
194 * PSH_RTLREADING 0x00000800
195 * PSH_STRETCHWATERMARK 0x00040000
196 * PSH_USEPAGELANG 0x00200000
199 add_flag(PSH_RTLREADING
);
200 add_flag(PSH_STRETCHWATERMARK
);
201 add_flag(PSH_USEPAGELANG
);
202 if (string
[0] != '\0')
203 FIXME("%s\n", string
);
207 /******************************************************************************
208 * PROPSHEET_GetPageRect
210 * Retrieve rect from tab control and map into the dialog for SetWindowPos
212 static void PROPSHEET_GetPageRect(const PropSheetInfo
* psInfo
, HWND hwndDlg
,
213 RECT
*rc
, LPCPROPSHEETPAGEW ppshpage
)
215 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) {
219 if (((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
220 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
221 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) ||
222 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
))
224 rc
->left
= rc
->top
= WIZARD_PADDING
;
228 rc
->left
= rc
->top
= 0;
230 rc
->right
= psInfo
->width
- rc
->left
;
231 rc
->bottom
= psInfo
->height
- rc
->top
;
232 MapDialogRect(hwndDlg
, rc
);
234 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
235 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
236 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
))
238 hwndChild
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
239 GetClientRect(hwndChild
, &r
);
240 MapWindowPoints(hwndChild
, hwndDlg
, (LPPOINT
) &r
, 2);
241 rc
->top
+= r
.bottom
+ 1;
244 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
245 GetClientRect(hwndTabCtrl
, rc
);
246 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)rc
);
247 MapWindowPoints(hwndTabCtrl
, hwndDlg
, (LPPOINT
)rc
, 2);
251 /******************************************************************************
252 * PROPSHEET_FindPageByResId
254 * Find page index corresponding to page resource id.
256 static INT
PROPSHEET_FindPageByResId(const PropSheetInfo
* psInfo
, LRESULT resId
)
260 for (i
= 0; i
< psInfo
->nPages
; i
++)
262 LPCPROPSHEETPAGEA lppsp
= (LPCPROPSHEETPAGEA
)psInfo
->proppage
[i
].hpage
;
264 /* Fixme: if resource ID is a string shall we use strcmp ??? */
265 if (lppsp
->u
.pszTemplate
== (LPVOID
)resId
)
272 /******************************************************************************
275 * Convert ASCII to Unicode since all data is saved as Unicode.
277 static void PROPSHEET_AtoW(LPCWSTR
*tostr
, LPCSTR frstr
)
282 TRACE("<%s>\n", frstr
);
283 len
= MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, 0, 0);
284 to
= Alloc(len
* sizeof(WCHAR
));
285 MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, to
, len
);
289 /******************************************************************************
290 * PROPSHEET_CollectSheetInfoCommon
292 * Common code for PROPSHEET_CollectSheetInfoA/W
294 static void PROPSHEET_CollectSheetInfoCommon(PropSheetInfo
* psInfo
, DWORD dwFlags
)
296 PROPSHEET_UnImplementedFlags(dwFlags
);
298 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
299 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
300 psInfo
->hasFinish
= dwFlags
& PSH_WIZARDHASFINISH
;
301 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
302 psInfo
->usePropPage
= dwFlags
& PSH_PROPSHEETPAGE
;
303 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
304 psInfo
->active_page
= 0;
307 psInfo
->hImageList
= 0;
308 psInfo
->activeValid
= FALSE
;
311 /******************************************************************************
312 * PROPSHEET_CollectSheetInfoA
314 * Collect relevant data.
316 static void PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh
,
317 PropSheetInfo
* psInfo
)
319 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERA
));
320 DWORD dwFlags
= lppsh
->dwFlags
;
322 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
)&& (lppsh
->pfnCallback
);
324 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
325 TRACE("\n** PROPSHEETHEADER **\ndwSize\t\t%d\ndwFlags\t\t%08x\nhwndParent\t%p\nhInstance\t%p\npszCaption\t'%s'\nnPages\t\t%d\npfnCallback\t%p\n",
326 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
,
327 debugstr_a(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
329 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
330 psInfo
->ppshheader
.pszCaption
= NULL
;
333 if (HIWORD(lppsh
->pszCaption
))
335 int len
= MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, NULL
, 0);
336 WCHAR
*caption
= Alloc( len
*sizeof (WCHAR
) );
338 MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, caption
, len
);
339 psInfo
->ppshheader
.pszCaption
= caption
;
342 psInfo
->nPages
= lppsh
->nPages
;
344 if (dwFlags
& PSH_USEPSTARTPAGE
)
346 TRACE("PSH_USEPSTARTPAGE is on\n");
347 psInfo
->active_page
= 0;
350 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
352 PROPSHEET_CollectSheetInfoCommon(psInfo
, dwFlags
);
355 /******************************************************************************
356 * PROPSHEET_CollectSheetInfoW
358 * Collect relevant data.
360 static void PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
361 PropSheetInfo
* psInfo
)
363 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERW
));
364 DWORD dwFlags
= lppsh
->dwFlags
;
366 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
) && (lppsh
->pfnCallback
);
368 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
369 TRACE("\n** PROPSHEETHEADER **\ndwSize\t\t%d\ndwFlags\t\t%08x\nhwndParent\t%p\nhInstance\t%p\npszCaption\t%s\nnPages\t\t%d\npfnCallback\t%p\n",
370 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
, debugstr_w(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
372 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
373 psInfo
->ppshheader
.pszCaption
= NULL
;
376 if (HIWORD(lppsh
->pszCaption
))
378 int len
= strlenW(lppsh
->pszCaption
);
379 WCHAR
*caption
= Alloc( (len
+1)*sizeof(WCHAR
) );
381 psInfo
->ppshheader
.pszCaption
= strcpyW( caption
, lppsh
->pszCaption
);
384 psInfo
->nPages
= lppsh
->nPages
;
386 if (dwFlags
& PSH_USEPSTARTPAGE
)
388 TRACE("PSH_USEPSTARTPAGE is on\n");
389 psInfo
->active_page
= 0;
392 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
394 PROPSHEET_CollectSheetInfoCommon(psInfo
, dwFlags
);
397 /******************************************************************************
398 * PROPSHEET_CollectPageInfo
400 * Collect property sheet data.
401 * With code taken from DIALOG_ParseTemplate32.
403 static BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
404 PropSheetInfo
* psInfo
,
407 const DLGTEMPLATE
* pTemplate
;
416 psInfo
->proppage
[index
].hpage
= (HPROPSHEETPAGE
)lppsp
;
417 psInfo
->proppage
[index
].hwndPage
= 0;
418 psInfo
->proppage
[index
].isDirty
= FALSE
;
421 * Process property page flags.
423 dwFlags
= lppsp
->dwFlags
;
424 psInfo
->proppage
[index
].useCallback
= (dwFlags
& PSP_USECALLBACK
) && (lppsp
->pfnCallback
);
425 psInfo
->proppage
[index
].hasHelp
= dwFlags
& PSP_HASHELP
;
426 psInfo
->proppage
[index
].hasIcon
= dwFlags
& (PSP_USEHICON
| PSP_USEICONID
);
428 /* as soon as we have a page with the help flag, set the sheet flag on */
429 if (psInfo
->proppage
[index
].hasHelp
)
430 psInfo
->hasHelp
= TRUE
;
433 * Process page template.
435 if (dwFlags
& PSP_DLGINDIRECT
)
436 pTemplate
= lppsp
->u
.pResource
;
437 else if(dwFlags
& PSP_INTERNAL_UNICODE
)
439 HRSRC hResource
= FindResourceW(lppsp
->hInstance
,
440 lppsp
->u
.pszTemplate
,
442 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
444 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
448 HRSRC hResource
= FindResourceA(lppsp
->hInstance
,
449 (LPCSTR
)lppsp
->u
.pszTemplate
,
451 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
453 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
457 * Extract the size of the page and the caption.
462 p
= (const WORD
*)pTemplate
;
464 if (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
466 /* DLGTEMPLATEEX (not defined in any std. header file) */
470 p
+= 2; /* help ID */
471 p
+= 2; /* ext style */
479 p
+= 2; /* ext style */
485 width
= (WORD
)*p
; p
++;
486 height
= (WORD
)*p
; p
++;
488 /* Special calculation for interior wizard pages so the largest page is
489 * calculated correctly. We need to add all the padding and space occupied
490 * by the header so the width and height sums up to the whole wizard client
492 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
493 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
494 !(dwFlags
& PSP_HIDEHEADER
))
496 height
+= 2 * WIZARD_PADDING
+ WIZARD_HEADER_HEIGHT
;
497 width
+= 2 * WIZARD_PADDING
;
499 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
)
501 height
+= 2 * WIZARD_PADDING
;
502 width
+= 2 * WIZARD_PADDING
;
505 /* remember the largest width and height */
506 if (width
> psInfo
->width
)
507 psInfo
->width
= width
;
509 if (height
> psInfo
->height
)
510 psInfo
->height
= height
;
522 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
536 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
540 /* Extract the caption */
541 psInfo
->proppage
[index
].pszText
= (LPCWSTR
)p
;
542 TRACE("Tab %d %s\n",index
,debugstr_w((LPCWSTR
)p
));
543 p
+= lstrlenW((LPCWSTR
)p
) + 1;
545 if (dwFlags
& PSP_USETITLE
)
549 static const WCHAR pszNull
[] = { '(','n','u','l','l',')',0 };
553 if ( !HIWORD( lppsp
->pszTitle
) )
555 if (!LoadStringW( lppsp
->hInstance
, (DWORD_PTR
)lppsp
->pszTitle
,szTitle
,sizeof(szTitle
) ))
558 FIXME("Could not load resource #%04x?\n",LOWORD(lppsp
->pszTitle
));
564 pTitle
= lppsp
->pszTitle
;
566 len
= strlenW(pTitle
);
567 text
= Alloc( (len
+1)*sizeof (WCHAR
) );
568 psInfo
->proppage
[index
].pszText
= strcpyW( text
, pTitle
);
572 * Build the image list for icons
574 if ((dwFlags
& PSP_USEHICON
) || (dwFlags
& PSP_USEICONID
))
577 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
578 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
580 if (dwFlags
& PSP_USEICONID
)
581 hIcon
= LoadImageW(lppsp
->hInstance
, lppsp
->u2
.pszIcon
, IMAGE_ICON
,
582 icon_cx
, icon_cy
, LR_DEFAULTCOLOR
);
584 hIcon
= lppsp
->u2
.hIcon
;
588 if (psInfo
->hImageList
== 0 )
589 psInfo
->hImageList
= ImageList_Create(icon_cx
, icon_cy
, ILC_COLOR
, 1, 1);
591 ImageList_AddIcon(psInfo
->hImageList
, hIcon
);
599 /******************************************************************************
600 * PROPSHEET_CreateDialog
602 * Creates the actual property sheet.
604 static INT_PTR
PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
)
611 WORD resID
= IDD_PROPSHEET
;
614 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
617 if( psInfo
->unicode
)
619 if(!(hRes
= FindResourceW(COMCTL32_hModule
,
620 MAKEINTRESOURCEW(resID
),
626 if(!(hRes
= FindResourceA(COMCTL32_hModule
,
627 MAKEINTRESOURCEA(resID
),
632 if(!(template = (LPVOID
)LoadResource(COMCTL32_hModule
, hRes
)))
636 * Make a copy of the dialog template.
638 resSize
= SizeofResource(COMCTL32_hModule
, hRes
);
640 temp
= Alloc(resSize
);
645 memcpy(temp
, template, resSize
);
647 if (psInfo
->ppshheader
.dwFlags
& PSH_NOCONTEXTHELP
)
649 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
650 ((MyDLGTEMPLATEEX
*)temp
)->style
&= ~DS_CONTEXTHELP
;
652 ((DLGTEMPLATE
*)temp
)->style
&= ~DS_CONTEXTHELP
;
654 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
655 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARDCONTEXTHELP
))
657 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
658 ((MyDLGTEMPLATEEX
*)temp
)->style
|= DS_CONTEXTHELP
;
660 ((DLGTEMPLATE
*)temp
)->style
|= DS_CONTEXTHELP
;
663 if (psInfo
->useCallback
)
664 (*(psInfo
->ppshheader
.pfnCallback
))(0, PSCB_PRECREATE
, (LPARAM
)temp
);
666 /* NOTE: MSDN states "Returns a positive value if successful, or -1
667 * otherwise for modal property sheets.", but this is wrong. The
668 * actual return value is either TRUE (success), FALSE (cancel) or
670 if( psInfo
->unicode
)
672 ret
= (INT_PTR
)CreateDialogIndirectParamW(psInfo
->ppshheader
.hInstance
,
673 (LPDLGTEMPLATEW
) temp
,
674 psInfo
->ppshheader
.hwndParent
,
675 PROPSHEET_DialogProc
,
677 if ( !ret
) ret
= -1;
681 ret
= (INT_PTR
)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
682 (LPDLGTEMPLATEA
) temp
,
683 psInfo
->ppshheader
.hwndParent
,
684 PROPSHEET_DialogProc
,
686 if ( !ret
) ret
= -1;
694 /******************************************************************************
695 * PROPSHEET_SizeMismatch
697 * Verify that the tab control and the "largest" property sheet page dlg. template
700 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
702 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
703 RECT rcOrigTab
, rcPage
;
708 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
709 TRACE("orig tab %d %d %d %d\n", rcOrigTab
.left
, rcOrigTab
.top
,
710 rcOrigTab
.right
, rcOrigTab
.bottom
);
717 rcPage
.right
= psInfo
->width
;
718 rcPage
.bottom
= psInfo
->height
;
720 MapDialogRect(hwndDlg
, &rcPage
);
721 TRACE("biggest page %d %d %d %d\n", rcPage
.left
, rcPage
.top
,
722 rcPage
.right
, rcPage
.bottom
);
724 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
726 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
732 /******************************************************************************
733 * PROPSHEET_AdjustSize
735 * Resizes the property sheet and the tab control to fit the largest page.
737 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
739 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
740 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
742 int tabOffsetX
, tabOffsetY
, buttonHeight
;
743 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
746 /* Get the height of buttons */
747 GetClientRect(hwndButton
, &rc
);
748 buttonHeight
= rc
.bottom
;
755 rc
.right
= psInfo
->width
;
756 rc
.bottom
= psInfo
->height
;
758 MapDialogRect(hwndDlg
, &rc
);
760 /* retrieve the dialog units */
761 units
.left
= units
.right
= 4;
762 units
.top
= units
.bottom
= 8;
763 MapDialogRect(hwndDlg
, &units
);
766 * Resize the tab control.
768 GetClientRect(hwndTabCtrl
,&tabRect
);
770 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
772 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
774 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
775 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
778 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
780 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
781 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
784 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
786 tabOffsetX
= -(rc
.left
);
787 tabOffsetY
= -(rc
.top
);
791 TRACE("setting tab %p, rc (0,0)-(%d,%d)\n",
792 hwndTabCtrl
, rc
.right
, rc
.bottom
);
793 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
794 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
796 GetClientRect(hwndTabCtrl
, &rc
);
798 TRACE("tab client rc %d %d %d %d\n",
799 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
801 rc
.right
+= ((padding
.x
* 2) + tabOffsetX
);
802 rc
.bottom
+= (buttonHeight
+ (3 * padding
.y
) + tabOffsetY
);
805 * Resize the property sheet.
807 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
808 hwndDlg
, rc
.right
, rc
.bottom
);
809 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
810 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
814 /******************************************************************************
815 * PROPSHEET_AdjustSizeWizard
817 * Resizes the property sheet to fit the largest page.
819 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
821 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
822 RECT rc
, lineRect
, dialogRect
;
824 /* Biggest page size */
827 rc
.right
= psInfo
->width
;
828 rc
.bottom
= psInfo
->height
;
829 MapDialogRect(hwndDlg
, &rc
);
831 TRACE("Biggest page %d %d %d %d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
833 /* Add space for the buttons row */
834 GetWindowRect(hwndLine
, &lineRect
);
835 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
836 GetClientRect(hwndDlg
, &dialogRect
);
837 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
839 /* Convert the client coordinates to window coordinates */
840 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
842 /* Resize the property sheet */
843 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
844 hwndDlg
, rc
.right
, rc
.bottom
);
845 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
846 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
851 /******************************************************************************
852 * PROPSHEET_AdjustButtons
854 * Adjusts the buttons' positions.
856 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, const PropSheetInfo
* psInfo
)
858 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
862 int buttonWidth
, buttonHeight
;
863 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
865 if (psInfo
->hasApply
)
872 * Obtain the size of the buttons.
874 GetClientRect(hwndButton
, &rcSheet
);
875 buttonWidth
= rcSheet
.right
;
876 buttonHeight
= rcSheet
.bottom
;
879 * Get the size of the property sheet.
881 GetClientRect(hwndParent
, &rcSheet
);
884 * All buttons will be at this y coordinate.
886 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
889 * Position OK button and make it default.
891 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
893 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
895 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
896 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
898 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
902 * Position Cancel button.
904 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
906 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1));
908 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
909 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
912 * Position Apply button.
914 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
916 if (psInfo
->hasApply
)
919 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * 2);
921 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
923 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
924 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
926 EnableWindow(hwndButton
, FALSE
);
929 ShowWindow(hwndButton
, SW_HIDE
);
932 * Position Help button.
934 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
938 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
940 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
941 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
944 ShowWindow(hwndButton
, SW_HIDE
);
949 /******************************************************************************
950 * PROPSHEET_AdjustButtonsWizard
952 * Adjusts the buttons' positions.
954 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
955 const PropSheetInfo
* psInfo
)
957 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
958 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
959 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
963 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
964 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
968 if (psInfo
->hasFinish
)
972 * Obtain the size of the buttons.
974 GetClientRect(hwndButton
, &rcSheet
);
975 buttonWidth
= rcSheet
.right
;
976 buttonHeight
= rcSheet
.bottom
;
978 GetClientRect(hwndLine
, &rcSheet
);
979 lineHeight
= rcSheet
.bottom
;
982 * Get the size of the property sheet.
984 GetClientRect(hwndParent
, &rcSheet
);
987 * All buttons will be at this y coordinate.
989 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
992 * Position the Back button.
994 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
996 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1)) - buttonWidth
;
998 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
999 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1002 * Position the Next button.
1004 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
1008 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1009 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1012 * Position the Finish button.
1014 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
1016 if (psInfo
->hasFinish
)
1017 x
+= padding
.x
+ buttonWidth
;
1019 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1020 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1022 if (!psInfo
->hasFinish
)
1023 ShowWindow(hwndButton
, SW_HIDE
);
1026 * Position the Cancel button.
1028 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1030 x
+= padding
.x
+ buttonWidth
;
1032 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1033 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1036 * Position Help button.
1038 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1040 if (psInfo
->hasHelp
)
1042 x
+= padding
.x
+ buttonWidth
;
1044 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1045 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1048 ShowWindow(hwndButton
, SW_HIDE
);
1050 if (psInfo
->ppshheader
.dwFlags
&
1051 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1055 * Position and resize the sunken line.
1058 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1060 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1061 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1062 SWP_NOZORDER
| SWP_NOACTIVATE
);
1065 * Position and resize the header sunken line.
1068 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1069 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1070 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1071 ShowWindow(hwndLineHeader
, SW_HIDE
);
1076 /******************************************************************************
1077 * PROPSHEET_GetPaddingInfo
1079 * Returns the layout information.
1081 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1083 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1086 PADDING_INFO padding
;
1088 GetWindowRect(hwndTab
, &rcTab
);
1093 ScreenToClient(hwndDlg
, &tl
);
1101 /******************************************************************************
1102 * PROPSHEET_GetPaddingInfoWizard
1104 * Returns the layout information.
1105 * Vertical spacing is the distance between the line and the buttons.
1106 * Do NOT use the Help button to gather padding information when it isn't mapped
1107 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1108 * for it in this case !
1109 * FIXME: I'm not sure about any other coordinate problems with these evil
1110 * buttons. Fix it in case additional problems appear or maybe calculate
1111 * a padding in a completely different way, as this is somewhat messy.
1113 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1116 PADDING_INFO padding
;
1120 POINT ptButton
, ptLine
;
1123 if (psInfo
->hasHelp
)
1129 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1131 idButton
= IDC_NEXT_BUTTON
;
1135 /* hopefully this is ok */
1136 idButton
= IDCANCEL
;
1140 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1141 GetWindowRect(hwndControl
, &rc
);
1143 ptButton
.x
= rc
.left
;
1144 ptButton
.y
= rc
.top
;
1146 ScreenToClient(hwndDlg
, &ptButton
);
1149 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1150 GetWindowRect(hwndControl
, &rc
);
1153 ptLine
.y
= rc
.bottom
;
1155 ScreenToClient(hwndDlg
, &ptLine
);
1157 padding
.y
= ptButton
.y
- ptLine
.y
;
1160 ERR("padding negative ! Please report this !\n");
1162 /* this is most probably not correct, but the best we have now */
1163 padding
.x
= padding
.y
;
1167 /******************************************************************************
1168 * PROPSHEET_CreateTabControl
1170 * Insert the tabs in the tab control.
1172 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1173 const PropSheetInfo
* psInfo
)
1175 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1181 item
.mask
= TCIF_TEXT
;
1182 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1184 nTabs
= psInfo
->nPages
;
1187 * Set the image list for icons.
1189 if (psInfo
->hImageList
)
1191 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1194 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 0, 0);
1195 for (i
= 0; i
< nTabs
; i
++)
1197 if ( psInfo
->proppage
[i
].hasIcon
)
1199 item
.mask
|= TCIF_IMAGE
;
1200 item
.iImage
= iImage
++;
1204 item
.mask
&= ~TCIF_IMAGE
;
1207 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1208 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, (WPARAM
)i
, (LPARAM
)&item
);
1210 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 1, 0);
1215 /******************************************************************************
1216 * PROPSHEET_WizardSubclassProc
1218 * Subclassing window procedure for wizard extrior pages to prevent drawing
1219 * background and so drawing above the watermark.
1221 static LRESULT CALLBACK
1222 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1229 case WM_CTLCOLORSTATIC
:
1230 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1231 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1234 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1238 * Get the size of an in-memory Template
1240 *( Based on the code of PROPSHEET_CollectPageInfo)
1241 * See also dialog.c/DIALOG_ParseTemplate32().
1244 static UINT
GetTemplateSize(const DLGTEMPLATE
* pTemplate
)
1247 const WORD
* p
= (const WORD
*)pTemplate
;
1248 BOOL istemplateex
= (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1254 /* DLGTEMPLATEEX (not defined in any std. header file) */
1256 TRACE("is DLGTEMPLATEEX\n");
1258 p
++; /* signature */
1259 p
+= 2; /* help ID */
1260 p
+= 2; /* ext style */
1267 TRACE("is DLGTEMPLATE\n");
1269 p
+= 2; /* ext style */
1272 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1288 TRACE("menu %s\n",debugstr_w((LPCWSTR
)p
));
1289 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1300 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1303 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1304 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1309 TRACE("title %s\n",debugstr_w((LPCWSTR
)p
));
1310 p
+= lstrlenW((LPCWSTR
)p
) + 1;
1312 /* font, if DS_SETFONT set */
1313 if ((DS_SETFONT
& ((istemplateex
)? ((const MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1316 p
+=(istemplateex
)?3:1;
1317 TRACE("font %s\n",debugstr_w((LPCWSTR
)p
));
1318 p
+= lstrlenW( (LPCWSTR
)p
) + 1; /* the font name */
1321 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1322 * that are following the DLGTEMPLATE(EX) data */
1323 TRACE("%d items\n",nrofitems
);
1324 while (nrofitems
> 0)
1326 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1329 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1338 TRACE("class ordinal 0x%08x\n",*(const DWORD
*)p
);
1342 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1343 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1347 /* check title text */
1354 TRACE("text ordinal 0x%08x\n",*(const DWORD
*)p
);
1358 TRACE("text %s\n",debugstr_w((LPCWSTR
)p
));
1359 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1362 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1366 ret
= (p
- (const WORD
*)pTemplate
) * sizeof(WORD
);
1367 TRACE("%p %p size 0x%08x\n", p
, pTemplate
, ret
);
1371 /******************************************************************************
1372 * PROPSHEET_CreatePage
1376 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1378 const PropSheetInfo
* psInfo
,
1379 LPCPROPSHEETPAGEW ppshpage
)
1381 DLGTEMPLATE
* pTemplate
;
1386 TRACE("index %d\n", index
);
1388 if (ppshpage
== NULL
)
1393 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1395 pTemplate
= (DLGTEMPLATE
*)ppshpage
->u
.pResource
;
1396 resSize
= GetTemplateSize(pTemplate
);
1398 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1403 hResource
= FindResourceW(ppshpage
->hInstance
,
1404 ppshpage
->u
.pszTemplate
,
1409 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1411 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1415 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
1417 * Make a copy of the dialog template to make it writable
1425 hResource
= FindResourceA(ppshpage
->hInstance
,
1426 (LPCSTR
)ppshpage
->u
.pszTemplate
,
1431 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1433 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1437 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
1439 * Make a copy of the dialog template to make it writable
1442 temp
= Alloc(resSize
);
1446 TRACE("copying pTemplate %p into temp %p (%d)\n", pTemplate
, temp
, resSize
);
1447 memcpy(temp
, pTemplate
, resSize
);
1450 if (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
1452 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1453 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~DS_MODALFRAME
;
1454 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_CAPTION
;
1455 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_SYSMENU
;
1456 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_POPUP
;
1457 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_DISABLED
;
1458 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_VISIBLE
;
1459 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_THICKFRAME
;
1461 ((MyDLGTEMPLATEEX
*)pTemplate
)->exStyle
|= WS_EX_CONTROLPARENT
;
1465 pTemplate
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1466 pTemplate
->style
&= ~DS_MODALFRAME
;
1467 pTemplate
->style
&= ~WS_CAPTION
;
1468 pTemplate
->style
&= ~WS_SYSMENU
;
1469 pTemplate
->style
&= ~WS_POPUP
;
1470 pTemplate
->style
&= ~WS_DISABLED
;
1471 pTemplate
->style
&= ~WS_VISIBLE
;
1472 pTemplate
->style
&= ~WS_THICKFRAME
;
1474 pTemplate
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1477 if (psInfo
->proppage
[index
].useCallback
)
1478 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1479 (LPPROPSHEETPAGEW
)ppshpage
);
1481 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1482 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1485 ppshpage
->pfnDlgProc
,
1488 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1491 ppshpage
->pfnDlgProc
,
1493 /* Free a no more needed copy */
1496 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1498 /* Subclass exterior wizard pages */
1499 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1500 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1501 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1503 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1504 (DWORD_PTR
)ppshpage
);
1506 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1507 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1512 /******************************************************************************
1513 * PROPSHEET_LoadWizardBitmaps
1515 * Loads the watermark and header bitmaps for a wizard.
1517 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1519 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1521 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1522 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1523 considers hbmWatermark as valid. */
1524 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1525 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1527 ((PropSheetInfo
*)psInfo
)->ppshheader
.u4
.hbmWatermark
=
1528 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1531 /* Same behavior as for watermarks */
1532 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1533 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1535 ((PropSheetInfo
*)psInfo
)->ppshheader
.u5
.hbmHeader
=
1536 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1542 /******************************************************************************
1543 * PROPSHEET_ShowPage
1545 * Displays or creates the specified page.
1547 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1550 HWND hwndLineHeader
;
1551 LPCPROPSHEETPAGEW ppshpage
;
1553 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1554 if (index
== psInfo
->active_page
)
1556 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1557 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1561 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1562 if (psInfo
->proppage
[index
].hwndPage
== 0)
1564 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1567 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1569 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1570 psInfo
->proppage
[index
].pszText
);
1573 if (psInfo
->active_page
!= -1)
1574 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1576 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1578 /* Synchronize current selection with tab control
1579 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1580 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1581 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1583 psInfo
->active_page
= index
;
1584 psInfo
->activeValid
= TRUE
;
1586 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1588 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1589 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1591 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1592 ShowWindow(hwndLineHeader
, SW_HIDE
);
1594 ShowWindow(hwndLineHeader
, SW_SHOW
);
1600 /******************************************************************************
1603 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1607 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1612 TRACE("active_page %d\n", psInfo
->active_page
);
1613 if (psInfo
->active_page
< 0)
1616 psn
.hdr
.code
= PSN_WIZBACK
;
1617 psn
.hdr
.hwndFrom
= hwndDlg
;
1621 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1623 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1626 else if (result
== 0)
1627 idx
= psInfo
->active_page
- 1;
1629 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1631 if (idx
>= 0 && idx
< psInfo
->nPages
)
1633 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1634 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1639 /******************************************************************************
1642 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1646 LRESULT msgResult
= 0;
1647 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1651 TRACE("active_page %d\n", psInfo
->active_page
);
1652 if (psInfo
->active_page
< 0)
1655 psn
.hdr
.code
= PSN_WIZNEXT
;
1656 psn
.hdr
.hwndFrom
= hwndDlg
;
1660 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1662 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1663 if (msgResult
== -1)
1665 else if (msgResult
== 0)
1666 idx
= psInfo
->active_page
+ 1;
1668 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1670 if (idx
< psInfo
->nPages
)
1672 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1673 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1679 /******************************************************************************
1682 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1686 LRESULT msgResult
= 0;
1687 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1690 TRACE("active_page %d\n", psInfo
->active_page
);
1691 if (psInfo
->active_page
< 0)
1694 psn
.hdr
.code
= PSN_WIZFINISH
;
1695 psn
.hdr
.hwndFrom
= hwndDlg
;
1699 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1701 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1703 TRACE("msg result %ld\n", msgResult
);
1708 if (psInfo
->result
== 0)
1709 psInfo
->result
= IDOK
;
1710 if (psInfo
->isModeless
)
1711 psInfo
->activeValid
= FALSE
;
1713 psInfo
->ended
= TRUE
;
1718 /******************************************************************************
1721 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1726 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1729 TRACE("active_page %d\n", psInfo
->active_page
);
1730 if (psInfo
->active_page
< 0)
1733 psn
.hdr
.hwndFrom
= hwndDlg
;
1739 * Send PSN_KILLACTIVE to the current page.
1741 psn
.hdr
.code
= PSN_KILLACTIVE
;
1743 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1745 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1749 * Send PSN_APPLY to all pages.
1751 psn
.hdr
.code
= PSN_APPLY
;
1752 psn
.lParam
= lParam
;
1754 for (i
= 0; i
< psInfo
->nPages
; i
++)
1756 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1759 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1761 case PSNRET_INVALID
:
1762 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1764 case PSNRET_INVALID_NOCHANGEPAGE
:
1772 psInfo
->activeValid
= FALSE
;
1774 else if(psInfo
->active_page
>= 0)
1776 psn
.hdr
.code
= PSN_SETACTIVE
;
1778 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1779 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1785 /******************************************************************************
1788 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1790 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1796 TRACE("active_page %d\n", psInfo
->active_page
);
1797 if (psInfo
->active_page
< 0)
1800 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1801 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1802 psn
.hdr
.hwndFrom
= hwndDlg
;
1806 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1809 psn
.hdr
.code
= PSN_RESET
;
1810 psn
.lParam
= lParam
;
1812 for (i
= 0; i
< psInfo
->nPages
; i
++)
1814 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1817 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1820 if (psInfo
->isModeless
)
1822 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1823 psInfo
->activeValid
= FALSE
;
1826 psInfo
->ended
= TRUE
;
1829 /******************************************************************************
1832 static void PROPSHEET_Help(HWND hwndDlg
)
1834 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1839 TRACE("active_page %d\n", psInfo
->active_page
);
1840 if (psInfo
->active_page
< 0)
1843 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1844 psn
.hdr
.code
= PSN_HELP
;
1845 psn
.hdr
.hwndFrom
= hwndDlg
;
1849 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1852 /******************************************************************************
1855 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1858 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1862 if (!psInfo
) return;
1864 * Set the dirty flag of this page.
1866 for (i
= 0; i
< psInfo
->nPages
; i
++)
1868 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1869 psInfo
->proppage
[i
].isDirty
= TRUE
;
1873 * Enable the Apply button.
1875 if (psInfo
->hasApply
)
1877 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1879 EnableWindow(hwndApplyBtn
, TRUE
);
1883 /******************************************************************************
1884 * PROPSHEET_UnChanged
1886 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1889 BOOL noPageDirty
= TRUE
;
1890 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1891 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1895 if ( !psInfo
) return;
1896 for (i
= 0; i
< psInfo
->nPages
; i
++)
1898 /* set the specified page as clean */
1899 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1900 psInfo
->proppage
[i
].isDirty
= FALSE
;
1902 /* look to see if there's any dirty pages */
1903 if (psInfo
->proppage
[i
].isDirty
)
1904 noPageDirty
= FALSE
;
1908 * Disable Apply button.
1911 EnableWindow(hwndApplyBtn
, FALSE
);
1914 /******************************************************************************
1915 * PROPSHEET_PressButton
1917 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1919 TRACE("buttonID %d\n", buttonID
);
1922 case PSBTN_APPLYNOW
:
1923 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1926 PROPSHEET_Back(hwndDlg
);
1929 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1932 PROPSHEET_Finish(hwndDlg
);
1935 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1938 PROPSHEET_Next(hwndDlg
);
1941 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1944 FIXME("Invalid button index %d\n", buttonID
);
1949 /*************************************************************************
1950 * BOOL PROPSHEET_CanSetCurSel [Internal]
1952 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1955 * hwndDlg [I] handle to a Dialog hWnd
1958 * TRUE if Current Selection can change
1962 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
1964 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1970 TRACE("active_page %d\n", psInfo
->active_page
);
1977 if (psInfo
->active_page
< 0)
1984 * Notify the current page.
1986 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1987 psn
.hdr
.code
= PSN_KILLACTIVE
;
1988 psn
.hdr
.hwndFrom
= hwndDlg
;
1992 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1995 TRACE("<-- %d\n", res
);
1999 /******************************************************************************
2000 * PROPSHEET_SetCurSel
2002 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
2005 HPROPSHEETPAGE hpage
2008 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2009 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
2010 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2012 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
2013 /* hpage takes precedence over index */
2015 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2017 if (index
< 0 || index
>= psInfo
->nPages
)
2019 TRACE("Could not find page to select!\n");
2023 /* unset active page while doing this transition. */
2024 if (psInfo
->active_page
!= -1)
2025 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
2026 psInfo
->active_page
= -1;
2032 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2035 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
2037 psn
.hdr
.code
= PSN_SETACTIVE
;
2038 psn
.hdr
.hwndFrom
= hwndDlg
;
2042 if (!psInfo
->proppage
[index
].hwndPage
) {
2043 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
2046 /* Resize the property sheet page to the fit in the Tab control
2047 * (for regular property sheets) or to fit in the client area (for
2049 * NOTE: The resizing happens every time the page is selected and
2050 * not only when it's created (some applications depend on it). */
2051 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2052 TRACE("setting page %p, rc (%d,%d)-(%d,%d) w=%d, h=%d\n",
2053 psInfo
->proppage
[index
].hwndPage
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
2054 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2055 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2057 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2059 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2066 WARN("Tried to skip before first property sheet page!\n");
2069 if (index
>= psInfo
->nPages
) {
2070 WARN("Tried to skip after last property sheet page!\n");
2071 index
= psInfo
->nPages
-1;
2075 else if (result
!= 0)
2077 int old_index
= index
;
2078 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2079 if(index
>= psInfo
->nPages
) {
2081 WARN("Tried to skip to nonexistant page by res id\n");
2088 /* Invalidate the header area */
2089 if ( (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
2090 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
2092 HWND hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
2095 GetClientRect(hwndLineHeader
, &r
);
2096 MapWindowPoints(hwndLineHeader
, hwndDlg
, (LPPOINT
) &r
, 2);
2097 SetRect(&r
, 0, 0, r
.right
+ 1, r
.top
- 1);
2099 InvalidateRect(hwndDlg
, &r
, TRUE
);
2103 * Display the new page.
2105 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2107 if (psInfo
->proppage
[index
].hasHelp
)
2108 EnableWindow(hwndHelp
, TRUE
);
2110 EnableWindow(hwndHelp
, FALSE
);
2115 /******************************************************************************
2116 * PROPSHEET_SetCurSelId
2118 * Selects the page, specified by resource id.
2120 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2123 PropSheetInfo
* psInfo
=
2124 (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2126 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2127 if (idx
< psInfo
->nPages
)
2129 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2130 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2134 /******************************************************************************
2135 * PROPSHEET_SetTitleA
2137 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2139 if(HIWORD(lpszText
))
2142 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2143 szTitle
, sizeof(szTitle
)/sizeof(WCHAR
));
2144 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2148 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2152 /******************************************************************************
2153 * PROPSHEET_SetTitleW
2155 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2157 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2160 TRACE("%s (style %08x)\n", debugstr_w(lpszText
), dwStyle
);
2161 if (HIWORD(lpszText
) == 0) {
2162 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2163 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)-sizeof(WCHAR
)))
2167 if (dwStyle
& PSH_PROPTITLE
)
2170 int lentitle
= strlenW(lpszText
);
2171 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2173 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2174 wsprintfW(dest
, psInfo
->strPropertiesFor
, lpszText
);
2176 SetWindowTextW(hwndDlg
, dest
);
2180 SetWindowTextW(hwndDlg
, lpszText
);
2183 /******************************************************************************
2184 * PROPSHEET_SetFinishTextA
2186 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2188 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2189 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2191 TRACE("'%s'\n", lpszText
);
2192 /* Set text, show and enable the Finish button */
2193 SetWindowTextA(hwndButton
, lpszText
);
2194 ShowWindow(hwndButton
, SW_SHOW
);
2195 EnableWindow(hwndButton
, TRUE
);
2197 /* Make it default pushbutton */
2198 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2200 /* Hide Back button */
2201 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2202 ShowWindow(hwndButton
, SW_HIDE
);
2204 if (!psInfo
->hasFinish
)
2206 /* Hide Next button */
2207 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2208 ShowWindow(hwndButton
, SW_HIDE
);
2212 /******************************************************************************
2213 * PROPSHEET_SetFinishTextW
2215 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2217 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2218 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2220 TRACE("%s\n", debugstr_w(lpszText
));
2221 /* Set text, show and enable the Finish button */
2222 SetWindowTextW(hwndButton
, lpszText
);
2223 ShowWindow(hwndButton
, SW_SHOW
);
2224 EnableWindow(hwndButton
, TRUE
);
2226 /* Make it default pushbutton */
2227 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2229 /* Hide Back button */
2230 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2231 ShowWindow(hwndButton
, SW_HIDE
);
2233 if (!psInfo
->hasFinish
)
2235 /* Hide Next button */
2236 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2237 ShowWindow(hwndButton
, SW_HIDE
);
2241 /******************************************************************************
2242 * PROPSHEET_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
)
2270 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2272 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2274 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2276 TRACE("hpage %p\n", hpage
);
2278 * Allocate and fill in a new PropPageInfo entry.
2280 ppi
= (PropPageInfo
*) ReAlloc(psInfo
->proppage
,
2281 sizeof(PropPageInfo
) *
2282 (psInfo
->nPages
+ 1));
2286 psInfo
->proppage
= ppi
;
2287 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, psInfo
->nPages
))
2290 psInfo
->proppage
[psInfo
->nPages
].hpage
= hpage
;
2292 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2294 /* Create the page but don't show it */
2295 PROPSHEET_CreatePage(hwndDlg
, psInfo
->nPages
, psInfo
, ppsp
);
2299 * Add a new tab to the tab control.
2301 item
.mask
= TCIF_TEXT
;
2302 item
.pszText
= (LPWSTR
) psInfo
->proppage
[psInfo
->nPages
].pszText
;
2303 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2305 if (psInfo
->hImageList
)
2307 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2310 if ( psInfo
->proppage
[psInfo
->nPages
].hasIcon
)
2312 item
.mask
|= TCIF_IMAGE
;
2313 item
.iImage
= psInfo
->nPages
;
2316 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, psInfo
->nPages
+ 1,
2321 /* If it is the only page - show it */
2322 if(psInfo
->nPages
== 1)
2323 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2327 /******************************************************************************
2328 * PROPSHEET_RemovePage
2330 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2332 HPROPSHEETPAGE hpage
)
2334 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2336 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2337 PropPageInfo
* oldPages
;
2339 TRACE("index %d, hpage %p\n", index
, hpage
);
2344 * hpage takes precedence over index.
2348 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2351 /* Make sure that index is within range */
2352 if (index
< 0 || index
>= psInfo
->nPages
)
2354 TRACE("Could not find page to remove!\n");
2358 TRACE("total pages %d removing page %d active page %d\n",
2359 psInfo
->nPages
, index
, psInfo
->active_page
);
2361 * Check if we're removing the active page.
2363 if (index
== psInfo
->active_page
)
2365 if (psInfo
->nPages
> 1)
2369 /* activate previous page */
2370 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2374 /* activate the next page */
2375 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2376 psInfo
->active_page
= index
;
2381 psInfo
->active_page
= -1;
2382 if (!psInfo
->isModeless
)
2384 psInfo
->ended
= TRUE
;
2389 else if (index
< psInfo
->active_page
)
2390 psInfo
->active_page
--;
2392 /* Unsubclass the page dialog window */
2393 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2394 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2395 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2397 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2398 PROPSHEET_WizardSubclassProc
, 1);
2401 /* Destroy page dialog window */
2402 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2404 /* Free page resources */
2405 if(psInfo
->proppage
[index
].hpage
)
2407 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2409 if (psp
->dwFlags
& PSP_USETITLE
)
2410 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2412 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2415 /* Remove the tab */
2416 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2418 oldPages
= psInfo
->proppage
;
2420 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2423 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2425 if (index
< psInfo
->nPages
)
2426 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2427 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2434 /******************************************************************************
2435 * PROPSHEET_SetWizButtons
2437 * This code will work if (and assumes that) the Next button is on top of the
2438 * Finish button. ie. Finish comes after Next in the Z order.
2439 * This means make sure the dialog template reflects this.
2442 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2444 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2446 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2447 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2448 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2450 TRACE("%d\n", dwFlags
);
2452 EnableWindow(hwndBack
, FALSE
);
2453 EnableWindow(hwndNext
, FALSE
);
2454 EnableWindow(hwndFinish
, FALSE
);
2456 /* set the default pushbutton to an enabled button */
2457 if (((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
))
2458 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2459 else if (dwFlags
& PSWIZB_NEXT
)
2460 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2461 else if (dwFlags
& PSWIZB_BACK
)
2462 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
2464 SendMessageW(hwndDlg
, DM_SETDEFID
, IDCANCEL
, 0);
2467 if (dwFlags
& PSWIZB_BACK
)
2468 EnableWindow(hwndBack
, TRUE
);
2470 if (dwFlags
& PSWIZB_NEXT
)
2471 EnableWindow(hwndNext
, TRUE
);
2473 if (!psInfo
->hasFinish
)
2475 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2477 /* Hide the Next button */
2478 ShowWindow(hwndNext
, SW_HIDE
);
2480 /* Show the Finish button */
2481 ShowWindow(hwndFinish
, SW_SHOW
);
2483 if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2484 EnableWindow(hwndFinish
, TRUE
);
2488 /* Hide the Finish button */
2489 ShowWindow(hwndFinish
, SW_HIDE
);
2490 /* Show the Next button */
2491 ShowWindow(hwndNext
, SW_SHOW
);
2494 else if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2495 EnableWindow(hwndFinish
, TRUE
);
2498 /******************************************************************************
2499 * PROPSHEET_InsertPage
2501 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2503 if (!HIWORD(hpageInsertAfter
))
2504 FIXME("(%p, %d, %p): stub\n", hwndDlg
, LOWORD(hpageInsertAfter
), hpage
);
2506 FIXME("(%p, %p, %p): stub\n", hwndDlg
, hpageInsertAfter
, hpage
);
2510 /******************************************************************************
2511 * PROPSHEET_SetHeaderTitleW
2513 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderTitle
)
2515 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderTitle
));
2518 /******************************************************************************
2519 * PROPSHEET_SetHeaderTitleA
2521 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderTitle
)
2523 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderTitle
));
2526 /******************************************************************************
2527 * PROPSHEET_SetHeaderSubTitleW
2529 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderSubTitle
)
2531 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderSubTitle
));
2534 /******************************************************************************
2535 * PROPSHEET_SetHeaderSubTitleA
2537 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderSubTitle
)
2539 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderSubTitle
));
2542 /******************************************************************************
2543 * PROPSHEET_HwndToIndex
2545 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2548 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2551 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2553 for (index
= 0; index
< psInfo
->nPages
; index
++)
2554 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2556 WARN("%p not found\n", hPageDlg
);
2560 /******************************************************************************
2561 * PROPSHEET_IndexToHwnd
2563 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2565 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2567 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2568 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2569 WARN("%d out of range.\n", iPageIndex
);
2572 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2575 /******************************************************************************
2576 * PROPSHEET_PageToIndex
2578 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2581 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2584 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2586 for (index
= 0; index
< psInfo
->nPages
; index
++)
2587 if (psInfo
->proppage
[index
].hpage
== hPage
)
2589 WARN("%p not found\n", hPage
);
2593 /******************************************************************************
2594 * PROPSHEET_IndexToPage
2596 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2598 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2600 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2601 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2602 WARN("%d out of range.\n", iPageIndex
);
2605 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2608 /******************************************************************************
2609 * PROPSHEET_IdToIndex
2611 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2614 LPCPROPSHEETPAGEW psp
;
2615 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2617 TRACE("(%p, %d)\n", hwndDlg
, iPageId
);
2618 for (index
= 0; index
< psInfo
->nPages
; index
++) {
2619 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2620 if (psp
->u
.pszTemplate
== MAKEINTRESOURCEW(iPageId
))
2627 /******************************************************************************
2628 * PROPSHEET_IndexToId
2630 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2632 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2634 LPCPROPSHEETPAGEW psp
;
2635 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2636 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2637 WARN("%d out of range.\n", iPageIndex
);
2640 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2641 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| HIWORD(psp
->u
.pszTemplate
)) {
2644 return (LRESULT
)psp
->u
.pszTemplate
;
2647 /******************************************************************************
2648 * PROPSHEET_GetResult
2650 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2652 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2654 return psInfo
->result
;
2657 /******************************************************************************
2658 * PROPSHEET_RecalcPageSizes
2660 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2662 FIXME("(%p): stub\n", hwndDlg
);
2666 /******************************************************************************
2667 * PROPSHEET_GetPageIndex
2669 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2670 * the array of PropPageInfo.
2672 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, const PropSheetInfo
* psInfo
)
2677 TRACE("hpage %p\n", hpage
);
2678 while ((index
< psInfo
->nPages
) && (found
== FALSE
))
2680 if (psInfo
->proppage
[index
].hpage
== hpage
)
2692 /******************************************************************************
2695 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2698 PropSheetInfo
* psInfo
= (PropSheetInfo
*) RemovePropW(hwndDlg
,
2702 if (!psInfo
) return;
2703 if (HIWORD(psInfo
->ppshheader
.pszCaption
))
2704 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2706 for (i
= 0; i
< psInfo
->nPages
; i
++)
2708 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2710 /* Unsubclass the page dialog window */
2711 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2712 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2713 (psp
->dwFlags
& PSP_HIDEHEADER
))
2715 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2716 PROPSHEET_WizardSubclassProc
, 1);
2719 if(psInfo
->proppage
[i
].hwndPage
)
2720 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2724 if (psp
->dwFlags
& PSP_USETITLE
)
2725 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2727 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2731 DeleteObject(psInfo
->hFont
);
2732 DeleteObject(psInfo
->hFontBold
);
2733 /* If we created the bitmaps, destroy them */
2734 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2735 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2736 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2737 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2738 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2739 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2741 Free(psInfo
->proppage
);
2742 Free(psInfo
->strPropertiesFor
);
2743 ImageList_Destroy(psInfo
->hImageList
);
2745 GlobalFree((HGLOBAL
)psInfo
);
2748 static INT
do_loop(const PropSheetInfo
*psInfo
)
2752 HWND hwnd
= psInfo
->hwnd
;
2754 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2759 if(!IsDialogMessageW(hwnd
, &msg
))
2761 TranslateMessage(&msg
);
2762 DispatchMessageW(&msg
);
2768 PostQuitMessage(msg
.wParam
);
2773 ret
= psInfo
->result
;
2775 DestroyWindow(hwnd
);
2779 /******************************************************************************
2780 * PROPSHEET_PropertySheet
2782 * Common code between PropertySheetA/W
2784 static INT_PTR
PROPSHEET_PropertySheet(PropSheetInfo
* psInfo
, BOOL unicode
)
2787 if (psInfo
->active_page
>= psInfo
->nPages
) psInfo
->active_page
= 0;
2788 TRACE("startpage: %d of %d pages\n", psInfo
->active_page
, psInfo
->nPages
);
2790 psInfo
->unicode
= unicode
;
2791 psInfo
->ended
= FALSE
;
2793 bRet
= PROPSHEET_CreateDialog(psInfo
);
2794 if(!psInfo
->isModeless
)
2796 HWND parent
= GetParent(psInfo
->hwnd
);
2797 if (parent
) EnableWindow(parent
, FALSE
);
2798 bRet
= do_loop(psInfo
);
2799 if (parent
) EnableWindow(parent
, TRUE
);
2804 /******************************************************************************
2805 * PropertySheet (COMCTL32.@)
2806 * PropertySheetA (COMCTL32.@)
2808 * Creates a property sheet in the specified property sheet header.
2811 * Modal property sheets: Positive if successful or -1 otherwise.
2812 * Modeless property sheets: Property sheet handle.
2814 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2815 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2817 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2819 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2820 sizeof(PropSheetInfo
));
2824 TRACE("(%p)\n", lppsh
);
2826 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2828 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2830 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2832 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2834 if (!psInfo
->usePropPage
)
2835 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2838 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2839 pByte
+= ((LPCPROPSHEETPAGEA
)pByte
)->dwSize
;
2842 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2845 if (psInfo
->usePropPage
)
2846 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2852 return PROPSHEET_PropertySheet(psInfo
, FALSE
);
2855 /******************************************************************************
2856 * PropertySheetW (COMCTL32.@)
2858 * See PropertySheetA.
2860 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2862 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2863 sizeof(PropSheetInfo
));
2867 TRACE("(%p)\n", lppsh
);
2869 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2871 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2873 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2875 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2877 if (!psInfo
->usePropPage
)
2878 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2881 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2882 pByte
+= ((LPCPROPSHEETPAGEW
)pByte
)->dwSize
;
2885 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2888 if (psInfo
->usePropPage
)
2889 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2895 return PROPSHEET_PropertySheet(psInfo
, TRUE
);
2898 static LPWSTR
load_string( HINSTANCE instance
, LPCWSTR str
)
2903 if (IS_INTRESOURCE(str
))
2908 WORD i
, id
= LOWORD(str
);
2910 if (!(hrsrc
= FindResourceW( instance
, MAKEINTRESOURCEW((id
>> 4) + 1), (LPWSTR
)RT_STRING
)))
2912 if (!(hmem
= LoadResource( instance
, hrsrc
))) return NULL
;
2913 if (!(ptr
= LockResource( hmem
))) return NULL
;
2914 for (i
= id
& 0x0f; i
> 0; i
--) ptr
+= *ptr
+ 1;
2916 if (!len
) return NULL
;
2917 ret
= Alloc( (len
+ 1) * sizeof(WCHAR
) );
2920 memcpy( ret
, ptr
+ 1, len
* sizeof(WCHAR
) );
2926 int len
= (strlenW(str
) + 1) * sizeof(WCHAR
);
2928 if (ret
) memcpy( ret
, str
, len
);
2934 /******************************************************************************
2935 * CreatePropertySheetPage (COMCTL32.@)
2936 * CreatePropertySheetPageA (COMCTL32.@)
2938 * Creates a new property sheet page.
2941 * Success: Handle to new property sheet page.
2945 * An application must use the PSM_ADDPAGE message to add the new page to
2946 * an existing property sheet.
2948 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2949 LPCPROPSHEETPAGEA lpPropSheetPage
)
2951 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2953 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEA
)));
2955 ppsp
->dwFlags
&= ~ PSP_INTERNAL_UNICODE
;
2957 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2959 if (HIWORD( ppsp
->u
.pszTemplate
))
2961 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
) + 1;
2962 char *template = Alloc( len
);
2964 ppsp
->u
.pszTemplate
= (LPWSTR
)strcpy( template, lpPropSheetPage
->u
.pszTemplate
);
2968 if (ppsp
->dwFlags
& PSP_USEICONID
)
2970 if (HIWORD( ppsp
->u2
.pszIcon
))
2971 PROPSHEET_AtoW(&ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2974 if (ppsp
->dwFlags
& PSP_USETITLE
)
2976 if (HIWORD( ppsp
->pszTitle
))
2977 PROPSHEET_AtoW( &ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2979 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
2982 ppsp
->pszTitle
= NULL
;
2984 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
2985 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
2987 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
2989 if (HIWORD( ppsp
->pszHeaderTitle
))
2990 PROPSHEET_AtoW(&ppsp
->pszHeaderTitle
, lpPropSheetPage
->pszHeaderTitle
);
2992 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
2995 ppsp
->pszHeaderTitle
= NULL
;
2997 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
2999 if (HIWORD( ppsp
->pszHeaderSubTitle
))
3000 PROPSHEET_AtoW(&ppsp
->pszHeaderSubTitle
, lpPropSheetPage
->pszHeaderSubTitle
);
3002 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3005 ppsp
->pszHeaderSubTitle
= NULL
;
3007 return (HPROPSHEETPAGE
)ppsp
;
3010 /******************************************************************************
3011 * CreatePropertySheetPageW (COMCTL32.@)
3013 * See CreatePropertySheetA.
3015 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
3017 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
3019 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEW
)));
3021 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
3023 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
3025 if (HIWORD( ppsp
->u
.pszTemplate
))
3027 int len
= strlenW(lpPropSheetPage
->u
.pszTemplate
) + 1;
3028 WCHAR
*template = Alloc( len
* sizeof (WCHAR
) );
3030 ppsp
->u
.pszTemplate
= strcpyW( template, lpPropSheetPage
->u
.pszTemplate
);
3034 if ( ppsp
->dwFlags
& PSP_USEICONID
)
3036 if (HIWORD( ppsp
->u2
.pszIcon
))
3038 int len
= strlenW(lpPropSheetPage
->u2
.pszIcon
) + 1;
3039 WCHAR
*icon
= Alloc( len
* sizeof (WCHAR
) );
3041 ppsp
->u2
.pszIcon
= strcpyW( icon
, lpPropSheetPage
->u2
.pszIcon
);
3045 if (ppsp
->dwFlags
& PSP_USETITLE
)
3046 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3048 ppsp
->pszTitle
= NULL
;
3050 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3051 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3053 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3054 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3056 ppsp
->pszHeaderTitle
= NULL
;
3058 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3059 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3061 ppsp
->pszHeaderSubTitle
= NULL
;
3063 return (HPROPSHEETPAGE
)ppsp
;
3066 /******************************************************************************
3067 * DestroyPropertySheetPage (COMCTL32.@)
3069 * Destroys a property sheet page previously created with
3070 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
3077 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
3079 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3084 if ( !(psp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( psp
->u
.pszTemplate
) )
3085 Free ((LPVOID
)psp
->u
.pszTemplate
);
3087 if ( (psp
->dwFlags
& PSP_USEICONID
) && HIWORD( psp
->u2
.pszIcon
) )
3088 Free ((LPVOID
)psp
->u2
.pszIcon
);
3090 if ((psp
->dwFlags
& PSP_USETITLE
) && HIWORD( psp
->pszTitle
))
3091 Free ((LPVOID
)psp
->pszTitle
);
3098 /******************************************************************************
3099 * PROPSHEET_IsDialogMessage
3101 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3103 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3106 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3109 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3112 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3114 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3116 switch (lpMsg
->wParam
)
3119 if (GetKeyState(VK_SHIFT
) & 0x8000)
3125 case VK_NEXT
: new_page
= 1; break;
3126 case VK_PRIOR
: new_page
= -1; break;
3132 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3134 new_page
+= psInfo
->active_page
;
3137 new_page
= psInfo
->nPages
- 1;
3138 else if (new_page
>= psInfo
->nPages
)
3141 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3148 return IsDialogMessageW(hwnd
, lpMsg
);
3151 /******************************************************************************
3152 * PROPSHEET_DoCommand
3154 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3160 case IDC_APPLY_BUTTON
:
3162 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3164 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3169 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3172 /* don't overwrite ID_PSRESTARTWINDOWS or ID_PSREBOOTSYSTEM */
3173 if (psInfo
->result
== 0)
3174 psInfo
->result
= IDOK
;
3176 if (psInfo
->isModeless
)
3177 psInfo
->activeValid
= FALSE
;
3179 psInfo
->ended
= TRUE
;
3182 EnableWindow(hwndApplyBtn
, FALSE
);
3187 case IDC_BACK_BUTTON
:
3188 PROPSHEET_Back(hwnd
);
3191 case IDC_NEXT_BUTTON
:
3192 PROPSHEET_Next(hwnd
);
3195 case IDC_FINISH_BUTTON
:
3196 PROPSHEET_Finish(hwnd
);
3200 PROPSHEET_Cancel(hwnd
, 0);
3204 PROPSHEET_Help(hwnd
);
3214 /******************************************************************************
3217 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3219 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3224 HPALETTE hOldPal
= 0;
3228 LPCPROPSHEETPAGEW ppshpage
;
3229 WCHAR szBuffer
[256];
3232 if (psInfo
->active_page
< 0) return 1;
3233 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3236 hdcSrc
= CreateCompatibleDC(0);
3237 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3239 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3240 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3242 if ( (!(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3243 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3244 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3246 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3248 COLORREF clrOld
= 0;
3251 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3252 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3254 GetClientRect(hwndLineHeader
, &r
);
3255 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3256 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3258 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), (LPVOID
)&bm
);
3260 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3262 /* Fill the unoccupied part of the header with color of the
3263 * left-top pixel, but do it only when needed.
3265 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3267 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3268 CopyRect(&r
, &rzone
);
3269 if (bm
.bmWidth
< r
.right
)
3271 r
.left
= bm
.bmWidth
;
3272 FillRect(hdc
, &r
, hbr
);
3274 if (bm
.bmHeight
< r
.bottom
)
3277 r
.top
= bm
.bmHeight
;
3278 FillRect(hdc
, &r
, hbr
);
3283 /* Draw the header itself. */
3285 bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3286 hdcSrc
, 0, 0, SRCCOPY
);
3291 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3292 FillRect(hdc
, &rzone
, hbr
);
3294 /* Draw the header bitmap. It's always centered like a
3295 * common 49 x 49 bitmap. */
3296 margin
= (rzone
.bottom
- 49) / 2;
3297 BitBlt(hdc
, rzone
.right
- 49 - margin
, margin
,
3298 min(bm
.bmWidth
, 49), min(bm
.bmHeight
, 49),
3299 hdcSrc
, 0, 0, SRCCOPY
);
3301 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3302 * if its height is smaller than 49 pixels. Because the reason
3303 * for this bug is unknown the current code doesn't try to
3307 clrOld
= SetTextColor (hdc
, 0x00000000);
3308 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3310 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3311 SetRect(&r
, 20, 10, 0, 0);
3312 if (HIWORD(ppshpage
->pszHeaderTitle
))
3313 DrawTextW(hdc
, ppshpage
->pszHeaderTitle
, -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3316 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderTitle
,
3320 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3325 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3326 SelectObject(hdc
, psInfo
->hFont
);
3327 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3328 if (HIWORD(ppshpage
->pszHeaderTitle
))
3329 DrawTextW(hdc
, ppshpage
->pszHeaderSubTitle
, -1, &r
, DT_LEFT
| DT_WORDBREAK
);
3332 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderSubTitle
,
3336 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_WORDBREAK
);
3341 offsety
= rzone
.bottom
+ 2;
3343 SetTextColor(hdc
, clrOld
);
3344 SetBkMode(hdc
, oldBkMode
);
3345 SelectObject(hdc
, hOldFont
);
3346 SelectObject(hdcSrc
, hbmp
);
3349 if ( (ppshpage
->dwFlags
& PSP_HIDEHEADER
) &&
3350 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3351 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3353 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3355 GetClientRect(hwndLine
, &r
);
3356 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3360 rzone
.right
= r
.right
;
3361 rzone
.bottom
= r
.top
- 1;
3363 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3364 FillRect(hdc
, &rzone
, hbr
);
3366 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), (LPVOID
)&bm
);
3367 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3369 /* The watermark is truncated to a width of 164 pixels */
3370 r
.right
= min(r
.right
, 164);
3371 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3372 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3374 /* If the bitmap is not big enough, fill the remaining area
3375 with the color of pixel (0,0) of bitmap - see MSDN */
3376 if (r
.top
> bm
.bmHeight
) {
3377 r
.bottom
= r
.top
- 1;
3378 r
.top
= bm
.bmHeight
;
3380 r
.right
= bm
.bmWidth
;
3381 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3382 FillRect(hdc
, &r
, hbr
);
3386 SelectObject(hdcSrc
, hbmp
);
3389 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3390 SelectPalette(hdc
, hOldPal
, FALSE
);
3394 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3399 /******************************************************************************
3400 * PROPSHEET_DialogProc
3402 static INT_PTR CALLBACK
3403 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3405 TRACE("hwnd=%p msg=0x%04x wparam=%lx lparam=%lx\n",
3406 hwnd
, uMsg
, wParam
, lParam
);
3412 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3413 WCHAR
* strCaption
= (WCHAR
*)Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3414 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3415 LPCPROPSHEETPAGEW ppshpage
;
3419 /* Using PropSheetInfoStr to store extra data doesn't match the native
3420 * common control: native uses TCM_[GS]ETITEM
3422 SetPropW(hwnd
, PropSheetInfoStr
, (HANDLE
)psInfo
);
3425 * psInfo->hwnd is not being used by WINE code - it exists
3426 * for compatibility with "real" Windoze. The same about
3427 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3430 psInfo
->hwnd
= hwnd
;
3431 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3433 /* set up the Next and Back buttons by default */
3434 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3437 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3438 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3439 logFont
.lfWeight
= FW_BOLD
;
3440 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3443 * Small icon in the title bar.
3445 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3446 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3449 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3450 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3452 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3453 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3454 psInfo
->ppshheader
.u
.pszIcon
,
3459 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3461 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3464 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3465 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3467 psInfo
->strPropertiesFor
= strCaption
;
3469 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3471 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3473 PROPSHEET_LoadWizardBitmaps(psInfo
);
3475 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3477 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3478 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3479 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3483 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3485 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3486 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3490 if (!HIWORD(psInfo
->ppshheader
.pszCaption
) &&
3491 psInfo
->ppshheader
.hInstance
)
3495 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3496 (UINT_PTR
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3497 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3501 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3502 psInfo
->ppshheader
.pszCaption
);
3506 if (psInfo
->useCallback
)
3507 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
,
3508 PSCB_INITIALIZED
, (LPARAM
)0);
3510 idx
= psInfo
->active_page
;
3511 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[idx
].hpage
;
3512 psInfo
->active_page
= -1;
3514 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3516 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3517 * as some programs call TCM_GETCURSEL to get the current selection
3518 * from which to switch to the next page */
3519 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3524 case WM_PRINTCLIENT
:
3526 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3530 PROPSHEET_CleanUp(hwnd
);
3534 PROPSHEET_Cancel(hwnd
, 1);
3535 return FALSE
; /* let DefDlgProc post us WM_COMMAND/IDCANCEL */
3538 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3540 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3545 /* No default handler, forward notification to active page */
3546 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3548 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3549 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3556 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3558 if (pnmh
->code
== TCN_SELCHANGE
)
3560 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3561 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3564 if(pnmh
->code
== TCN_SELCHANGING
)
3566 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3567 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3574 case WM_SYSCOLORCHANGE
:
3575 COMCTL32_RefreshSysColors();
3578 case PSM_GETCURRENTPAGEHWND
:
3580 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3587 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3588 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3590 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3596 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3600 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3603 case PSM_GETTABCONTROL
:
3605 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3607 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3616 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3617 if(msgResult
!= FALSE
)
3619 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3622 (HPROPSHEETPAGE
)lParam
);
3625 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3630 case PSM_CANCELTOCLOSE
:
3632 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3633 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3634 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3636 EnableWindow(hwndCancel
, FALSE
);
3637 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, sizeof(buf
)))
3638 SetWindowTextW(hwndOK
, buf
);
3643 case PSM_RESTARTWINDOWS
:
3645 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3651 /* reboot system takes precedence over restart windows */
3652 if (psInfo
->result
!= ID_PSREBOOTSYSTEM
)
3653 psInfo
->result
= ID_PSRESTARTWINDOWS
;
3658 case PSM_REBOOTSYSTEM
:
3660 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3666 psInfo
->result
= ID_PSREBOOTSYSTEM
;
3672 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3676 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3681 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3683 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3688 case PSM_QUERYSIBLINGS
:
3690 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3692 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3700 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3701 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3702 * on success or FALSE otherwise, as specified on MSDN Online.
3703 * Also see the MFC code for
3704 * CPropertySheet::AddPage(CPropertyPage* pPage).
3707 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3709 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3714 case PSM_REMOVEPAGE
:
3715 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3718 case PSM_ISDIALOGMESSAGE
:
3720 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3721 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3725 case PSM_PRESSBUTTON
:
3726 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3729 case PSM_SETFINISHTEXTA
:
3730 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3733 case PSM_SETWIZBUTTONS
:
3734 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3737 case PSM_SETCURSELID
:
3738 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3741 case PSM_SETFINISHTEXTW
:
3742 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3745 case PSM_INSERTPAGE
:
3747 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3748 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3752 case PSM_SETHEADERTITLEW
:
3753 PROPSHEET_SetHeaderTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3756 case PSM_SETHEADERTITLEA
:
3757 PROPSHEET_SetHeaderTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3760 case PSM_SETHEADERSUBTITLEW
:
3761 PROPSHEET_SetHeaderSubTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3764 case PSM_SETHEADERSUBTITLEA
:
3765 PROPSHEET_SetHeaderSubTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3768 case PSM_HWNDTOINDEX
:
3770 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3771 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3775 case PSM_INDEXTOHWND
:
3777 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3778 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3782 case PSM_PAGETOINDEX
:
3784 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3785 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3789 case PSM_INDEXTOPAGE
:
3791 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3792 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3798 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3799 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3805 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3806 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3812 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3813 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3817 case PSM_RECALCPAGESIZES
:
3819 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3820 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);