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
57 /******************************************************************************
81 } MyDLGITEMTEMPLATEEX
;
84 typedef struct tagPropPageInfo
86 HPROPSHEETPAGE hpage
; /* to keep track of pages not passed to PropertySheet */
95 typedef struct tagPropSheetInfo
98 PROPSHEETHEADERW ppshheader
;
100 LPWSTR strPropertiesFor
;
110 PropPageInfo
* proppage
;
115 HIMAGELIST hImageList
;
126 /******************************************************************************
127 * Defines and global variables
130 static const WCHAR PropSheetInfoStr
[] =
131 {'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0 };
133 #define PSP_INTERNAL_UNICODE 0x80000000
135 #define MAX_CAPTION_LENGTH 255
136 #define MAX_TABTEXT_LENGTH 255
137 #define MAX_BUTTONTEXT_LENGTH 64
139 #define INTRNL_ANY_WIZARD (PSH_WIZARD | PSH_WIZARD97_OLD | PSH_WIZARD97_NEW | PSH_WIZARD_LITE)
141 /* Wizard metrics specified in DLUs */
142 #define WIZARD_PADDING 7
143 #define WIZARD_HEADER_HEIGHT 36
145 /******************************************************************************
148 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
);
149 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
);
150 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
);
151 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
154 HPROPSHEETPAGE hpage
);
155 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, const PropSheetInfo
* psInfo
, int original_index
);
156 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
);
157 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
);
158 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
, int index
, HPROPSHEETPAGE hpage
);
160 static INT_PTR CALLBACK
161 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
163 WINE_DEFAULT_DEBUG_CHANNEL(propsheet
);
165 #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");}
166 /******************************************************************************
167 * PROPSHEET_UnImplementedFlags
169 * Document use of flags we don't implement yet.
171 static VOID
PROPSHEET_UnImplementedFlags(DWORD dwFlags
)
178 * unhandled header flags:
179 * PSH_RTLREADING 0x00000800
180 * PSH_STRETCHWATERMARK 0x00040000
181 * PSH_USEPAGELANG 0x00200000
184 add_flag(PSH_RTLREADING
);
185 add_flag(PSH_STRETCHWATERMARK
);
186 add_flag(PSH_USEPAGELANG
);
187 if (string
[0] != '\0')
188 FIXME("%s\n", string
);
192 /******************************************************************************
193 * PROPSHEET_GetPageRect
195 * Retrieve rect from tab control and map into the dialog for SetWindowPos
197 static void PROPSHEET_GetPageRect(const PropSheetInfo
* psInfo
, HWND hwndDlg
,
198 RECT
*rc
, LPCPROPSHEETPAGEW ppshpage
)
200 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) {
204 if (((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
205 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
206 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) ||
207 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
))
209 rc
->left
= rc
->top
= WIZARD_PADDING
;
213 rc
->left
= rc
->top
= 0;
215 rc
->right
= psInfo
->width
- rc
->left
;
216 rc
->bottom
= psInfo
->height
- rc
->top
;
217 MapDialogRect(hwndDlg
, rc
);
219 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
220 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
221 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
))
223 hwndChild
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
224 GetClientRect(hwndChild
, &r
);
225 MapWindowPoints(hwndChild
, hwndDlg
, (LPPOINT
) &r
, 2);
226 rc
->top
+= r
.bottom
+ 1;
229 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
230 GetClientRect(hwndTabCtrl
, rc
);
231 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)rc
);
232 MapWindowPoints(hwndTabCtrl
, hwndDlg
, (LPPOINT
)rc
, 2);
236 /******************************************************************************
237 * PROPSHEET_FindPageByResId
239 * Find page index corresponding to page resource id.
241 static INT
PROPSHEET_FindPageByResId(const PropSheetInfo
* psInfo
, LRESULT resId
)
245 for (i
= 0; i
< psInfo
->nPages
; i
++)
247 LPCPROPSHEETPAGEA lppsp
= (LPCPROPSHEETPAGEA
)psInfo
->proppage
[i
].hpage
;
249 /* Fixme: if resource ID is a string shall we use strcmp ??? */
250 if (lppsp
->u
.pszTemplate
== (LPVOID
)resId
)
257 /******************************************************************************
260 * Convert ASCII to Unicode since all data is saved as Unicode.
262 static void PROPSHEET_AtoW(LPCWSTR
*tostr
, LPCSTR frstr
)
267 TRACE("<%s>\n", frstr
);
268 len
= MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, 0, 0);
269 to
= Alloc(len
* sizeof(WCHAR
));
270 MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, to
, len
);
274 /******************************************************************************
275 * PROPSHEET_CollectSheetInfoCommon
277 * Common code for PROPSHEET_CollectSheetInfoA/W
279 static void PROPSHEET_CollectSheetInfoCommon(PropSheetInfo
* psInfo
, DWORD dwFlags
)
281 PROPSHEET_UnImplementedFlags(dwFlags
);
283 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
284 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
285 psInfo
->hasFinish
= dwFlags
& PSH_WIZARDHASFINISH
;
286 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
287 psInfo
->usePropPage
= dwFlags
& PSH_PROPSHEETPAGE
;
288 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
289 psInfo
->active_page
= 0;
292 psInfo
->hImageList
= 0;
293 psInfo
->activeValid
= FALSE
;
296 /******************************************************************************
297 * PROPSHEET_CollectSheetInfoA
299 * Collect relevant data.
301 static void PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh
,
302 PropSheetInfo
* psInfo
)
304 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERA
));
305 DWORD dwFlags
= lppsh
->dwFlags
;
307 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
)&& (lppsh
->pfnCallback
);
309 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
310 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",
311 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
,
312 debugstr_a(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
314 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
315 psInfo
->ppshheader
.pszCaption
= NULL
;
318 if (!IS_INTRESOURCE(lppsh
->pszCaption
))
320 int len
= MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, NULL
, 0);
321 WCHAR
*caption
= Alloc( len
*sizeof (WCHAR
) );
323 MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, caption
, len
);
324 psInfo
->ppshheader
.pszCaption
= caption
;
327 psInfo
->nPages
= lppsh
->nPages
;
329 if (dwFlags
& PSH_USEPSTARTPAGE
)
331 TRACE("PSH_USEPSTARTPAGE is on\n");
332 psInfo
->active_page
= 0;
335 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
337 PROPSHEET_CollectSheetInfoCommon(psInfo
, dwFlags
);
340 /******************************************************************************
341 * PROPSHEET_CollectSheetInfoW
343 * Collect relevant data.
345 static void PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
346 PropSheetInfo
* psInfo
)
348 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERW
));
349 DWORD dwFlags
= lppsh
->dwFlags
;
351 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
) && (lppsh
->pfnCallback
);
353 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
354 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",
355 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
, debugstr_w(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
357 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
358 psInfo
->ppshheader
.pszCaption
= NULL
;
361 if (!IS_INTRESOURCE(lppsh
->pszCaption
))
363 int len
= strlenW(lppsh
->pszCaption
);
364 WCHAR
*caption
= Alloc( (len
+1)*sizeof(WCHAR
) );
366 psInfo
->ppshheader
.pszCaption
= strcpyW( caption
, lppsh
->pszCaption
);
369 psInfo
->nPages
= lppsh
->nPages
;
371 if (dwFlags
& PSH_USEPSTARTPAGE
)
373 TRACE("PSH_USEPSTARTPAGE is on\n");
374 psInfo
->active_page
= 0;
377 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
379 PROPSHEET_CollectSheetInfoCommon(psInfo
, dwFlags
);
382 /******************************************************************************
383 * PROPSHEET_CollectPageInfo
385 * Collect property sheet data.
386 * With code taken from DIALOG_ParseTemplate32.
388 static BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
389 PropSheetInfo
* psInfo
,
390 int index
, BOOL resize
)
392 const DLGTEMPLATE
* pTemplate
;
401 psInfo
->proppage
[index
].hpage
= (HPROPSHEETPAGE
)lppsp
;
402 psInfo
->proppage
[index
].hwndPage
= 0;
403 psInfo
->proppage
[index
].isDirty
= FALSE
;
406 * Process property page flags.
408 dwFlags
= lppsp
->dwFlags
;
409 psInfo
->proppage
[index
].useCallback
= (dwFlags
& PSP_USECALLBACK
) && (lppsp
->pfnCallback
);
410 psInfo
->proppage
[index
].hasHelp
= dwFlags
& PSP_HASHELP
;
411 psInfo
->proppage
[index
].hasIcon
= dwFlags
& (PSP_USEHICON
| PSP_USEICONID
);
413 /* as soon as we have a page with the help flag, set the sheet flag on */
414 if (psInfo
->proppage
[index
].hasHelp
)
415 psInfo
->hasHelp
= TRUE
;
418 * Process page template.
420 if (dwFlags
& PSP_DLGINDIRECT
)
421 pTemplate
= lppsp
->u
.pResource
;
422 else if(dwFlags
& PSP_INTERNAL_UNICODE
)
424 HRSRC hResource
= FindResourceW(lppsp
->hInstance
,
425 lppsp
->u
.pszTemplate
,
427 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
429 pTemplate
= LockResource(hTemplate
);
433 HRSRC hResource
= FindResourceA(lppsp
->hInstance
,
434 (LPCSTR
)lppsp
->u
.pszTemplate
,
436 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
438 pTemplate
= LockResource(hTemplate
);
442 * Extract the size of the page and the caption.
447 p
= (const WORD
*)pTemplate
;
449 if (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
451 /* DLGTEMPLATEEX (not defined in any std. header file) */
455 p
+= 2; /* help ID */
456 p
+= 2; /* ext style */
464 p
+= 2; /* ext style */
470 width
= (WORD
)*p
; p
++;
471 height
= (WORD
)*p
; p
++;
473 /* Special calculation for interior wizard pages so the largest page is
474 * calculated correctly. We need to add all the padding and space occupied
475 * by the header so the width and height sums up to the whole wizard client
477 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
478 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
479 !(dwFlags
& PSP_HIDEHEADER
))
481 height
+= 2 * WIZARD_PADDING
+ WIZARD_HEADER_HEIGHT
;
482 width
+= 2 * WIZARD_PADDING
;
484 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
)
486 height
+= 2 * WIZARD_PADDING
;
487 width
+= 2 * WIZARD_PADDING
;
490 /* remember the largest width and height */
493 if (width
> psInfo
->width
)
494 psInfo
->width
= width
;
496 if (height
> psInfo
->height
)
497 psInfo
->height
= height
;
510 p
+= lstrlenW( p
) + 1;
524 p
+= lstrlenW( p
) + 1;
528 /* Extract the caption */
529 psInfo
->proppage
[index
].pszText
= p
;
530 TRACE("Tab %d %s\n",index
,debugstr_w( p
));
532 if (dwFlags
& PSP_USETITLE
)
536 static const WCHAR pszNull
[] = { '(','n','u','l','l',')',0 };
540 if (IS_INTRESOURCE( lppsp
->pszTitle
))
542 if (LoadStringW( lppsp
->hInstance
, (DWORD_PTR
)lppsp
->pszTitle
, szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0]) ))
550 pTitle
= lppsp
->pszTitle
;
552 len
= strlenW(pTitle
);
553 text
= Alloc( (len
+1)*sizeof (WCHAR
) );
554 psInfo
->proppage
[index
].pszText
= strcpyW( text
, pTitle
);
558 * Build the image list for icons
560 if ((dwFlags
& PSP_USEHICON
) || (dwFlags
& PSP_USEICONID
))
563 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
564 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
566 if (dwFlags
& PSP_USEICONID
)
567 hIcon
= LoadImageW(lppsp
->hInstance
, lppsp
->u2
.pszIcon
, IMAGE_ICON
,
568 icon_cx
, icon_cy
, LR_DEFAULTCOLOR
);
570 hIcon
= lppsp
->u2
.hIcon
;
574 if (psInfo
->hImageList
== 0 )
575 psInfo
->hImageList
= ImageList_Create(icon_cx
, icon_cy
, ILC_COLOR
, 1, 1);
577 ImageList_AddIcon(psInfo
->hImageList
, hIcon
);
585 /******************************************************************************
586 * PROPSHEET_CreateDialog
588 * Creates the actual property sheet.
590 static INT_PTR
PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
)
597 WORD resID
= IDD_PROPSHEET
;
599 TRACE("(%p)\n", psInfo
);
600 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
603 if( psInfo
->unicode
)
605 if(!(hRes
= FindResourceW(COMCTL32_hModule
,
606 MAKEINTRESOURCEW(resID
),
612 if(!(hRes
= FindResourceA(COMCTL32_hModule
,
613 MAKEINTRESOURCEA(resID
),
618 if(!(template = LoadResource(COMCTL32_hModule
, hRes
)))
622 * Make a copy of the dialog template.
624 resSize
= SizeofResource(COMCTL32_hModule
, hRes
);
626 temp
= Alloc(resSize
);
631 memcpy(temp
, template, resSize
);
633 if (psInfo
->ppshheader
.dwFlags
& PSH_NOCONTEXTHELP
)
635 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
636 ((MyDLGTEMPLATEEX
*)temp
)->style
&= ~DS_CONTEXTHELP
;
638 ((DLGTEMPLATE
*)temp
)->style
&= ~DS_CONTEXTHELP
;
640 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
641 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARDCONTEXTHELP
))
643 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
644 ((MyDLGTEMPLATEEX
*)temp
)->style
|= DS_CONTEXTHELP
;
646 ((DLGTEMPLATE
*)temp
)->style
|= DS_CONTEXTHELP
;
649 if (psInfo
->useCallback
)
650 (*(psInfo
->ppshheader
.pfnCallback
))(0, PSCB_PRECREATE
, (LPARAM
)temp
);
652 /* NOTE: MSDN states "Returns a positive value if successful, or -1
653 * otherwise for modal property sheets.", but this is wrong. The
654 * actual return value is either TRUE (success), FALSE (cancel) or
656 if( psInfo
->unicode
)
658 ret
= (INT_PTR
)CreateDialogIndirectParamW(psInfo
->ppshheader
.hInstance
,
659 temp
, psInfo
->ppshheader
.hwndParent
,
660 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
661 if ( !ret
) ret
= -1;
665 ret
= (INT_PTR
)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
666 temp
, psInfo
->ppshheader
.hwndParent
,
667 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
668 if ( !ret
) ret
= -1;
676 /******************************************************************************
677 * PROPSHEET_SizeMismatch
679 * Verify that the tab control and the "largest" property sheet page dlg. template
682 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
684 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
685 RECT rcOrigTab
, rcPage
;
690 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
691 TRACE("orig tab %s\n", wine_dbgstr_rect(&rcOrigTab
));
698 rcPage
.right
= psInfo
->width
;
699 rcPage
.bottom
= psInfo
->height
;
701 MapDialogRect(hwndDlg
, &rcPage
);
702 TRACE("biggest page %s\n", wine_dbgstr_rect(&rcPage
));
704 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
706 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
712 /******************************************************************************
713 * PROPSHEET_AdjustSize
715 * Resizes the property sheet and the tab control to fit the largest page.
717 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
719 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
720 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
723 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
727 /* Get the height of buttons */
728 GetClientRect(hwndButton
, &rc
);
729 buttonHeight
= rc
.bottom
;
736 rc
.right
= psInfo
->width
;
737 rc
.bottom
= psInfo
->height
;
739 MapDialogRect(hwndDlg
, &rc
);
741 /* retrieve the dialog units */
742 units
.left
= units
.right
= 4;
743 units
.top
= units
.bottom
= 8;
744 MapDialogRect(hwndDlg
, &units
);
747 * Resize the tab control.
749 GetClientRect(hwndTabCtrl
,&tabRect
);
751 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
753 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
755 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
756 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
759 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
761 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
762 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
765 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
769 TRACE("setting tab %p, rc (0,0)-(%d,%d)\n",
770 hwndTabCtrl
, rc
.right
, rc
.bottom
);
771 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
772 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
774 GetClientRect(hwndTabCtrl
, &rc
);
776 TRACE("tab client rc %s\n", wine_dbgstr_rect(&rc
));
778 rc
.right
+= (padding
.x
* 2);
779 rc
.bottom
+= buttonHeight
+ (3 * padding
.y
);
781 style
= GetWindowLongW(hwndDlg
, GWL_STYLE
);
782 if (!(style
& WS_CHILD
))
783 AdjustWindowRect(&rc
, style
, FALSE
);
789 * Resize the property sheet.
791 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
792 hwndDlg
, rc
.right
, rc
.bottom
);
793 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
794 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
798 /******************************************************************************
799 * PROPSHEET_AdjustSizeWizard
801 * Resizes the property sheet to fit the largest page.
803 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
805 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
806 RECT rc
, lineRect
, dialogRect
;
808 /* Biggest page size */
811 rc
.right
= psInfo
->width
;
812 rc
.bottom
= psInfo
->height
;
813 MapDialogRect(hwndDlg
, &rc
);
815 TRACE("Biggest page %s\n", wine_dbgstr_rect(&rc
));
817 /* Add space for the buttons row */
818 GetWindowRect(hwndLine
, &lineRect
);
819 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
820 GetClientRect(hwndDlg
, &dialogRect
);
821 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
823 /* Convert the client coordinates to window coordinates */
824 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
826 /* Resize the property sheet */
827 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
828 hwndDlg
, rc
.right
, rc
.bottom
);
829 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
830 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
835 /******************************************************************************
836 * PROPSHEET_AdjustButtons
838 * Adjusts the buttons' positions.
840 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, const PropSheetInfo
* psInfo
)
842 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
846 int buttonWidth
, buttonHeight
;
847 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
849 if (psInfo
->hasApply
)
856 * Obtain the size of the buttons.
858 GetClientRect(hwndButton
, &rcSheet
);
859 buttonWidth
= rcSheet
.right
;
860 buttonHeight
= rcSheet
.bottom
;
863 * Get the size of the property sheet.
865 GetClientRect(hwndParent
, &rcSheet
);
868 * All buttons will be at this y coordinate.
870 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
873 * Position OK button and make it default.
875 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
877 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
879 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
880 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
882 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
886 * Position Cancel button.
888 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
890 x
+= padding
.x
+ buttonWidth
;
892 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
893 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
896 * Position Apply button.
898 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
901 x
+= padding
.x
+ buttonWidth
;
903 ShowWindow(hwndButton
, SW_HIDE
);
905 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
906 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
907 EnableWindow(hwndButton
, FALSE
);
910 * Position Help button.
912 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
914 x
+= padding
.x
+ buttonWidth
;
915 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
916 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
919 ShowWindow(hwndButton
, SW_HIDE
);
924 /******************************************************************************
925 * PROPSHEET_AdjustButtonsWizard
927 * Adjusts the buttons' positions.
929 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
930 const PropSheetInfo
* psInfo
)
932 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
933 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
934 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
938 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
939 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
943 if (psInfo
->hasFinish
)
947 * Obtain the size of the buttons.
949 GetClientRect(hwndButton
, &rcSheet
);
950 buttonWidth
= rcSheet
.right
;
951 buttonHeight
= rcSheet
.bottom
;
953 GetClientRect(hwndLine
, &rcSheet
);
954 lineHeight
= rcSheet
.bottom
;
957 * Get the size of the property sheet.
959 GetClientRect(hwndParent
, &rcSheet
);
962 * All buttons will be at this y coordinate.
964 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
967 * Position the Back button.
969 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
971 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1)) - buttonWidth
;
973 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
974 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
977 * Position the Next button.
979 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
983 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
984 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
987 * Position the Finish button.
989 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
991 if (psInfo
->hasFinish
)
992 x
+= padding
.x
+ buttonWidth
;
994 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
995 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
997 if (!psInfo
->hasFinish
)
998 ShowWindow(hwndButton
, SW_HIDE
);
1001 * Position the Cancel button.
1003 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1005 x
+= padding
.x
+ buttonWidth
;
1007 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1008 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1011 * Position Help button.
1013 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1015 if (psInfo
->hasHelp
)
1017 x
+= padding
.x
+ buttonWidth
;
1019 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1020 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1023 ShowWindow(hwndButton
, SW_HIDE
);
1025 if (psInfo
->ppshheader
.dwFlags
&
1026 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1030 * Position and resize the sunken line.
1033 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1035 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1036 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1037 SWP_NOZORDER
| SWP_NOACTIVATE
);
1040 * Position and resize the header sunken line.
1043 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1044 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1045 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1046 ShowWindow(hwndLineHeader
, SW_HIDE
);
1051 /******************************************************************************
1052 * PROPSHEET_GetPaddingInfo
1054 * Returns the layout information.
1056 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1058 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1060 PADDING_INFO padding
;
1062 GetWindowRect(hwndTab
, &rcTab
);
1063 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rcTab
, 2 );
1065 padding
.x
= rcTab
.left
;
1066 padding
.y
= rcTab
.top
;
1071 /******************************************************************************
1072 * PROPSHEET_GetPaddingInfoWizard
1074 * Returns the layout information.
1075 * Vertical spacing is the distance between the line and the buttons.
1076 * Do NOT use the Help button to gather padding information when it isn't mapped
1077 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1078 * for it in this case !
1079 * FIXME: I'm not sure about any other coordinate problems with these evil
1080 * buttons. Fix it in case additional problems appear or maybe calculate
1081 * a padding in a completely different way, as this is somewhat messy.
1083 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1086 PADDING_INFO padding
;
1090 POINT ptButton
, ptLine
;
1093 if (psInfo
->hasHelp
)
1099 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1101 idButton
= IDC_NEXT_BUTTON
;
1105 /* hopefully this is ok */
1106 idButton
= IDCANCEL
;
1110 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1111 GetWindowRect(hwndControl
, &rc
);
1112 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1113 ptButton
.x
= rc
.left
;
1114 ptButton
.y
= rc
.top
;
1117 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1118 GetWindowRect(hwndControl
, &rc
);
1119 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1121 ptLine
.y
= rc
.bottom
;
1123 padding
.y
= ptButton
.y
- ptLine
.y
;
1126 ERR("padding negative ! Please report this !\n");
1128 /* this is most probably not correct, but the best we have now */
1129 padding
.x
= padding
.y
;
1133 /******************************************************************************
1134 * PROPSHEET_CreateTabControl
1136 * Insert the tabs in the tab control.
1138 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1139 const PropSheetInfo
* psInfo
)
1141 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1147 item
.mask
= TCIF_TEXT
;
1148 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1150 nTabs
= psInfo
->nPages
;
1153 * Set the image list for icons.
1155 if (psInfo
->hImageList
)
1157 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1160 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 0, 0);
1161 for (i
= 0; i
< nTabs
; i
++)
1163 if ( psInfo
->proppage
[i
].hasIcon
)
1165 item
.mask
|= TCIF_IMAGE
;
1166 item
.iImage
= iImage
++;
1170 item
.mask
&= ~TCIF_IMAGE
;
1173 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1174 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, i
, (LPARAM
)&item
);
1176 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 1, 0);
1181 /******************************************************************************
1182 * PROPSHEET_WizardSubclassProc
1184 * Subclassing window procedure for wizard exterior pages to prevent drawing
1185 * background and so drawing above the watermark.
1187 static LRESULT CALLBACK
1188 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1195 case WM_CTLCOLORSTATIC
:
1196 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1197 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1200 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1204 * Get the size of an in-memory Template
1206 *( Based on the code of PROPSHEET_CollectPageInfo)
1207 * See also dialog.c/DIALOG_ParseTemplate32().
1210 static UINT
GetTemplateSize(const DLGTEMPLATE
* pTemplate
)
1213 const WORD
* p
= (const WORD
*)pTemplate
;
1214 BOOL istemplateex
= (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1220 /* DLGTEMPLATEEX (not defined in any std. header file) */
1222 TRACE("is DLGTEMPLATEEX\n");
1224 p
++; /* signature */
1225 p
+= 2; /* help ID */
1226 p
+= 2; /* ext style */
1233 TRACE("is DLGTEMPLATE\n");
1235 p
+= 2; /* ext style */
1238 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1254 TRACE("menu %s\n",debugstr_w( p
));
1255 p
+= lstrlenW( p
) + 1;
1266 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1269 TRACE("class %s\n",debugstr_w( p
));
1270 p
+= lstrlenW( p
) + 1;
1275 TRACE("title %s\n",debugstr_w( p
));
1276 p
+= lstrlenW( p
) + 1;
1278 /* font, if DS_SETFONT set */
1279 if ((DS_SETFONT
& ((istemplateex
)? ((const MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1282 p
+=(istemplateex
)?3:1;
1283 TRACE("font %s\n",debugstr_w( p
));
1284 p
+= lstrlenW( p
) + 1; /* the font name */
1287 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1288 * that are following the DLGTEMPLATE(EX) data */
1289 TRACE("%d items\n",nrofitems
);
1290 while (nrofitems
> 0)
1292 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1295 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1304 TRACE("class ordinal 0x%08x\n",*(const DWORD
*)p
);
1308 TRACE("class %s\n",debugstr_w( p
));
1309 p
+= lstrlenW( p
) + 1;
1313 /* check title text */
1320 TRACE("text ordinal 0x%08x\n",*(const DWORD
*)p
);
1324 TRACE("text %s\n",debugstr_w( p
));
1325 p
+= lstrlenW( p
) + 1;
1328 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1332 ret
= (p
- (const WORD
*)pTemplate
) * sizeof(WORD
);
1333 TRACE("%p %p size 0x%08x\n", p
, pTemplate
, ret
);
1337 /******************************************************************************
1338 * PROPSHEET_CreatePage
1342 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1344 const PropSheetInfo
* psInfo
,
1345 LPCPROPSHEETPAGEW ppshpage
)
1347 const DLGTEMPLATE
* pTemplate
;
1350 DLGTEMPLATE
* pTemplateCopy
= NULL
;
1352 TRACE("index %d\n", index
);
1354 if (ppshpage
== NULL
)
1359 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1361 pTemplate
= ppshpage
->u
.pResource
;
1362 resSize
= GetTemplateSize(pTemplate
);
1364 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1369 hResource
= FindResourceW(ppshpage
->hInstance
,
1370 ppshpage
->u
.pszTemplate
,
1375 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1377 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1381 pTemplate
= LockResource(hTemplate
);
1383 * Make a copy of the dialog template to make it writable
1391 hResource
= FindResourceA(ppshpage
->hInstance
,
1392 (LPCSTR
)ppshpage
->u
.pszTemplate
,
1397 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1399 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1403 pTemplate
= LockResource(hTemplate
);
1405 * Make a copy of the dialog template to make it writable
1408 pTemplateCopy
= Alloc(resSize
);
1412 TRACE("copying pTemplate %p into pTemplateCopy %p (%d)\n", pTemplate
, pTemplateCopy
, resSize
);
1413 memcpy(pTemplateCopy
, pTemplate
, resSize
);
1415 if (((MyDLGTEMPLATEEX
*)pTemplateCopy
)->signature
== 0xFFFF)
1417 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1418 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~DS_MODALFRAME
;
1419 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_CAPTION
;
1420 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_SYSMENU
;
1421 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_POPUP
;
1422 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_DISABLED
;
1423 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_VISIBLE
;
1424 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_THICKFRAME
;
1426 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->exStyle
|= WS_EX_CONTROLPARENT
;
1430 pTemplateCopy
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1431 pTemplateCopy
->style
&= ~DS_MODALFRAME
;
1432 pTemplateCopy
->style
&= ~WS_CAPTION
;
1433 pTemplateCopy
->style
&= ~WS_SYSMENU
;
1434 pTemplateCopy
->style
&= ~WS_POPUP
;
1435 pTemplateCopy
->style
&= ~WS_DISABLED
;
1436 pTemplateCopy
->style
&= ~WS_VISIBLE
;
1437 pTemplateCopy
->style
&= ~WS_THICKFRAME
;
1439 pTemplateCopy
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1442 if (psInfo
->proppage
[index
].useCallback
)
1443 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1444 (LPPROPSHEETPAGEW
)ppshpage
);
1446 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1447 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1450 ppshpage
->pfnDlgProc
,
1453 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1456 ppshpage
->pfnDlgProc
,
1458 /* Free a no more needed copy */
1459 Free(pTemplateCopy
);
1464 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1466 /* Subclass exterior wizard pages */
1467 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1468 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1469 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1471 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1472 (DWORD_PTR
)ppshpage
);
1474 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1475 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1480 /******************************************************************************
1481 * PROPSHEET_LoadWizardBitmaps
1483 * Loads the watermark and header bitmaps for a wizard.
1485 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1487 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1489 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1490 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1491 considers hbmWatermark as valid. */
1492 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1493 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1495 psInfo
->ppshheader
.u4
.hbmWatermark
=
1496 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1499 /* Same behavior as for watermarks */
1500 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1501 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1503 psInfo
->ppshheader
.u5
.hbmHeader
=
1504 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1510 /******************************************************************************
1511 * PROPSHEET_ShowPage
1513 * Displays or creates the specified page.
1515 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1518 HWND hwndLineHeader
;
1520 LPCPROPSHEETPAGEW ppshpage
;
1522 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1523 if (index
== psInfo
->active_page
)
1525 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1526 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1530 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1531 if (psInfo
->proppage
[index
].hwndPage
== 0)
1533 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1536 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1538 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1539 psInfo
->proppage
[index
].pszText
);
1541 control
= GetNextDlgTabItem(psInfo
->proppage
[index
].hwndPage
, NULL
, FALSE
);
1546 if (psInfo
->active_page
!= -1)
1547 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1549 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1551 /* Synchronize current selection with tab control
1552 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1553 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1554 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1556 psInfo
->active_page
= index
;
1557 psInfo
->activeValid
= TRUE
;
1559 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1561 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1562 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1564 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1565 ShowWindow(hwndLineHeader
, SW_HIDE
);
1567 ShowWindow(hwndLineHeader
, SW_SHOW
);
1573 /******************************************************************************
1576 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1580 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1584 TRACE("active_page %d\n", psInfo
->active_page
);
1585 if (psInfo
->active_page
< 0)
1588 psn
.hdr
.code
= PSN_WIZBACK
;
1589 psn
.hdr
.hwndFrom
= hwndDlg
;
1593 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1595 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1598 else if (result
== 0)
1599 idx
= psInfo
->active_page
- 1;
1601 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1603 if (idx
>= 0 && idx
< psInfo
->nPages
)
1605 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1607 SetFocus(GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
));
1608 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
1609 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1615 /******************************************************************************
1618 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1622 LRESULT msgResult
= 0;
1623 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1626 TRACE("active_page %d\n", psInfo
->active_page
);
1627 if (psInfo
->active_page
< 0)
1630 psn
.hdr
.code
= PSN_WIZNEXT
;
1631 psn
.hdr
.hwndFrom
= hwndDlg
;
1635 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1637 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1638 if (msgResult
== -1)
1640 else if (msgResult
== 0)
1641 idx
= psInfo
->active_page
+ 1;
1643 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1645 if (idx
< psInfo
->nPages
)
1647 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1649 SetFocus(GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
));
1650 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
1651 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1658 /******************************************************************************
1661 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1665 LRESULT msgResult
= 0;
1666 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1668 TRACE("active_page %d\n", psInfo
->active_page
);
1669 if (psInfo
->active_page
< 0)
1672 psn
.hdr
.code
= PSN_WIZFINISH
;
1673 psn
.hdr
.hwndFrom
= hwndDlg
;
1677 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1679 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1681 TRACE("msg result %ld\n", msgResult
);
1686 if (psInfo
->result
== 0)
1687 psInfo
->result
= IDOK
;
1688 if (psInfo
->isModeless
)
1689 psInfo
->activeValid
= FALSE
;
1691 psInfo
->ended
= TRUE
;
1696 /******************************************************************************
1699 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1704 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1706 TRACE("active_page %d\n", psInfo
->active_page
);
1707 if (psInfo
->active_page
< 0)
1710 psn
.hdr
.hwndFrom
= hwndDlg
;
1716 * Send PSN_KILLACTIVE to the current page.
1718 psn
.hdr
.code
= PSN_KILLACTIVE
;
1720 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1722 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1726 * Send PSN_APPLY to all pages.
1728 psn
.hdr
.code
= PSN_APPLY
;
1729 psn
.lParam
= lParam
;
1731 for (i
= 0; i
< psInfo
->nPages
; i
++)
1733 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1736 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1738 case PSNRET_INVALID
:
1739 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1741 case PSNRET_INVALID_NOCHANGEPAGE
:
1749 psInfo
->activeValid
= FALSE
;
1751 else if(psInfo
->active_page
>= 0)
1753 psn
.hdr
.code
= PSN_SETACTIVE
;
1755 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1756 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1762 /******************************************************************************
1765 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1767 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1772 TRACE("active_page %d\n", psInfo
->active_page
);
1773 if (psInfo
->active_page
< 0)
1776 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1777 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1778 psn
.hdr
.hwndFrom
= hwndDlg
;
1782 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1785 psn
.hdr
.code
= PSN_RESET
;
1786 psn
.lParam
= lParam
;
1788 for (i
= 0; i
< psInfo
->nPages
; i
++)
1790 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1793 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1796 if (psInfo
->isModeless
)
1798 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1799 psInfo
->activeValid
= FALSE
;
1802 psInfo
->ended
= TRUE
;
1805 /******************************************************************************
1808 static void PROPSHEET_Help(HWND hwndDlg
)
1810 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1814 TRACE("active_page %d\n", psInfo
->active_page
);
1815 if (psInfo
->active_page
< 0)
1818 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1819 psn
.hdr
.code
= PSN_HELP
;
1820 psn
.hdr
.hwndFrom
= hwndDlg
;
1824 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1827 /******************************************************************************
1830 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1833 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1836 if (!psInfo
) return;
1838 * Set the dirty flag of this page.
1840 for (i
= 0; i
< psInfo
->nPages
; i
++)
1842 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1843 psInfo
->proppage
[i
].isDirty
= TRUE
;
1847 * Enable the Apply button.
1849 if (psInfo
->hasApply
)
1851 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1853 EnableWindow(hwndApplyBtn
, TRUE
);
1857 /******************************************************************************
1858 * PROPSHEET_UnChanged
1860 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1863 BOOL noPageDirty
= TRUE
;
1864 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1865 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1868 if ( !psInfo
) return;
1869 for (i
= 0; i
< psInfo
->nPages
; i
++)
1871 /* set the specified page as clean */
1872 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1873 psInfo
->proppage
[i
].isDirty
= FALSE
;
1875 /* look to see if there are any dirty pages */
1876 if (psInfo
->proppage
[i
].isDirty
)
1877 noPageDirty
= FALSE
;
1881 * Disable Apply button.
1884 EnableWindow(hwndApplyBtn
, FALSE
);
1887 /******************************************************************************
1888 * PROPSHEET_PressButton
1890 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1892 TRACE("buttonID %d\n", buttonID
);
1895 case PSBTN_APPLYNOW
:
1896 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1899 PROPSHEET_Back(hwndDlg
);
1902 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1905 PROPSHEET_Finish(hwndDlg
);
1908 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1911 PROPSHEET_Next(hwndDlg
);
1914 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1917 FIXME("Invalid button index %d\n", buttonID
);
1922 /*************************************************************************
1923 * BOOL PROPSHEET_CanSetCurSel [Internal]
1925 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1928 * hwndDlg [I] handle to a Dialog hWnd
1931 * TRUE if Current Selection can change
1935 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
1937 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1948 TRACE("active_page %d\n", psInfo
->active_page
);
1949 if (psInfo
->active_page
< 0)
1956 * Notify the current page.
1958 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1959 psn
.hdr
.code
= PSN_KILLACTIVE
;
1960 psn
.hdr
.hwndFrom
= hwndDlg
;
1964 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1967 TRACE("<-- %d\n", res
);
1971 /******************************************************************************
1972 * PROPSHEET_SetCurSel
1974 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
1977 HPROPSHEETPAGE hpage
1980 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1981 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
1982 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1984 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
1986 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
1988 if (index
< 0 || index
>= psInfo
->nPages
)
1990 TRACE("Could not find page to select!\n");
1994 /* unset active page while doing this transition. */
1995 if (psInfo
->active_page
!= -1)
1996 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1997 psInfo
->active_page
= -1;
2003 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2006 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
2008 psn
.hdr
.code
= PSN_SETACTIVE
;
2009 psn
.hdr
.hwndFrom
= hwndDlg
;
2013 if (!psInfo
->proppage
[index
].hwndPage
) {
2014 if(!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
)) {
2015 PROPSHEET_RemovePage(hwndDlg
, index
, NULL
);
2016 if(index
>= psInfo
->nPages
)
2024 /* Resize the property sheet page to the fit in the Tab control
2025 * (for regular property sheets) or to fit in the client area (for
2027 * NOTE: The resizing happens every time the page is selected and
2028 * not only when it's created (some applications depend on it). */
2029 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2030 TRACE("setting page %p, rc (%s) w=%d, h=%d\n",
2031 psInfo
->proppage
[index
].hwndPage
, wine_dbgstr_rect(&rc
),
2032 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2033 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2035 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2037 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2044 WARN("Tried to skip before first property sheet page!\n");
2047 if (index
>= psInfo
->nPages
) {
2048 WARN("Tried to skip after last property sheet page!\n");
2049 index
= psInfo
->nPages
-1;
2053 else if (result
!= 0)
2055 int old_index
= index
;
2056 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2057 if(index
>= psInfo
->nPages
) {
2059 WARN("Tried to skip to nonexistent page by res id\n");
2066 /* Invalidate the header area */
2067 if ( (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
2068 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
2070 HWND hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
2073 GetClientRect(hwndLineHeader
, &r
);
2074 MapWindowPoints(hwndLineHeader
, hwndDlg
, (LPPOINT
) &r
, 2);
2075 SetRect(&r
, 0, 0, r
.right
+ 1, r
.top
- 1);
2077 InvalidateRect(hwndDlg
, &r
, TRUE
);
2081 * Display the new page.
2083 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2085 if (psInfo
->proppage
[index
].hasHelp
)
2086 EnableWindow(hwndHelp
, TRUE
);
2088 EnableWindow(hwndHelp
, FALSE
);
2093 /******************************************************************************
2094 * PROPSHEET_SetCurSelId
2096 * Selects the page, specified by resource id.
2098 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2101 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2103 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2104 if (idx
< psInfo
->nPages
)
2106 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2107 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2111 /******************************************************************************
2112 * PROPSHEET_SetTitleA
2114 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2116 if(!IS_INTRESOURCE(lpszText
))
2119 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2120 szTitle
, sizeof(szTitle
)/sizeof(WCHAR
));
2121 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2125 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2129 /******************************************************************************
2130 * PROPSHEET_SetTitleW
2132 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2134 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2137 TRACE("%s (style %08x)\n", debugstr_w(lpszText
), dwStyle
);
2138 if (IS_INTRESOURCE(lpszText
)) {
2139 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2140 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0])))
2144 if (dwStyle
& PSH_PROPTITLE
)
2147 int lentitle
= strlenW(lpszText
);
2148 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2150 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2151 wsprintfW(dest
, psInfo
->strPropertiesFor
, lpszText
);
2153 SetWindowTextW(hwndDlg
, dest
);
2157 SetWindowTextW(hwndDlg
, lpszText
);
2160 /******************************************************************************
2161 * PROPSHEET_SetFinishTextA
2163 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2165 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2166 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2168 TRACE("'%s'\n", lpszText
);
2169 /* Set text, show and enable the Finish button */
2170 SetWindowTextA(hwndButton
, lpszText
);
2171 ShowWindow(hwndButton
, SW_SHOW
);
2172 EnableWindow(hwndButton
, TRUE
);
2174 /* Make it default pushbutton */
2175 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2177 /* Hide Back button */
2178 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2179 ShowWindow(hwndButton
, SW_HIDE
);
2181 if (!psInfo
->hasFinish
)
2183 /* Hide Next button */
2184 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2185 ShowWindow(hwndButton
, SW_HIDE
);
2189 /******************************************************************************
2190 * PROPSHEET_SetFinishTextW
2192 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2194 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2195 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2197 TRACE("%s\n", debugstr_w(lpszText
));
2198 /* Set text, show and enable the Finish button */
2199 SetWindowTextW(hwndButton
, lpszText
);
2200 ShowWindow(hwndButton
, SW_SHOW
);
2201 EnableWindow(hwndButton
, TRUE
);
2203 /* Make it default pushbutton */
2204 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2206 /* Hide Back button */
2207 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2208 ShowWindow(hwndButton
, SW_HIDE
);
2210 if (!psInfo
->hasFinish
)
2212 /* Hide Next button */
2213 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2214 ShowWindow(hwndButton
, SW_HIDE
);
2218 /******************************************************************************
2219 * PROPSHEET_QuerySiblings
2221 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2222 WPARAM wParam
, LPARAM lParam
)
2226 LRESULT msgResult
= 0;
2227 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2229 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2231 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2232 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2240 /******************************************************************************
2243 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
2244 HPROPSHEETPAGE hpage
)
2247 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2248 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2250 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2252 TRACE("hpage %p\n", hpage
);
2254 * Allocate and fill in a new PropPageInfo entry.
2256 ppi
= ReAlloc(psInfo
->proppage
, sizeof(PropPageInfo
) * (psInfo
->nPages
+ 1));
2260 psInfo
->proppage
= ppi
;
2261 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, psInfo
->nPages
, FALSE
))
2264 psInfo
->proppage
[psInfo
->nPages
].hpage
= hpage
;
2266 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2268 /* Create the page but don't show it */
2269 if(!PROPSHEET_CreatePage(hwndDlg
, psInfo
->nPages
, psInfo
, ppsp
))
2274 * Add a new tab to the tab control.
2276 item
.mask
= TCIF_TEXT
;
2277 item
.pszText
= (LPWSTR
) psInfo
->proppage
[psInfo
->nPages
].pszText
;
2278 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2280 if (psInfo
->hImageList
)
2282 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2285 if ( psInfo
->proppage
[psInfo
->nPages
].hasIcon
)
2287 item
.mask
|= TCIF_IMAGE
;
2288 item
.iImage
= psInfo
->nPages
;
2291 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, psInfo
->nPages
+ 1,
2296 /* If it is the only page - show it */
2297 if(psInfo
->nPages
== 1)
2298 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2302 /******************************************************************************
2303 * PROPSHEET_RemovePage
2305 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2307 HPROPSHEETPAGE hpage
)
2309 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2310 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2311 PropPageInfo
* oldPages
;
2313 TRACE("index %d, hpage %p\n", index
, hpage
);
2318 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
2320 /* Make sure that index is within range */
2321 if (index
< 0 || index
>= psInfo
->nPages
)
2323 TRACE("Could not find page to remove!\n");
2327 TRACE("total pages %d removing page %d active page %d\n",
2328 psInfo
->nPages
, index
, psInfo
->active_page
);
2330 * Check if we're removing the active page.
2332 if (index
== psInfo
->active_page
)
2334 if (psInfo
->nPages
> 1)
2338 /* activate previous page */
2339 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2343 /* activate the next page */
2344 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2345 psInfo
->active_page
= index
;
2350 psInfo
->active_page
= -1;
2351 if (!psInfo
->isModeless
)
2353 psInfo
->ended
= TRUE
;
2358 else if (index
< psInfo
->active_page
)
2359 psInfo
->active_page
--;
2361 /* Unsubclass the page dialog window */
2362 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2363 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2364 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2366 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2367 PROPSHEET_WizardSubclassProc
, 1);
2370 /* Destroy page dialog window */
2371 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2373 /* Free page resources */
2374 if(psInfo
->proppage
[index
].hpage
)
2376 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2378 if (psp
->dwFlags
& PSP_USETITLE
)
2379 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2381 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2384 /* Remove the tab */
2385 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2387 oldPages
= psInfo
->proppage
;
2389 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2392 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2394 if (index
< psInfo
->nPages
)
2395 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2396 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2403 /******************************************************************************
2404 * PROPSHEET_SetWizButtons
2406 * This code will work if (and assumes that) the Next button is on top of the
2407 * Finish button. ie. Finish comes after Next in the Z order.
2408 * This means make sure the dialog template reflects this.
2411 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2413 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2414 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2415 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2416 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2418 HWND hwndCancel
= GetDlgItem(hwndDlg
, IDCANCEL
);
2423 TRACE("%d\n", dwFlags
);
2425 EnableWindow(hwndBack
, FALSE
);
2426 EnableWindow(hwndNext
, FALSE
);
2427 EnableWindow(hwndFinish
, FALSE
);
2430 /* set the default pushbutton to an enabled button */
2431 if (((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
))
2432 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2433 else if (dwFlags
& PSWIZB_NEXT
)
2434 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2435 else if (dwFlags
& PSWIZB_BACK
)
2436 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
2438 SendMessageW(hwndDlg
, DM_SETDEFID
, IDCANCEL
, 0);
2442 if (dwFlags
& PSWIZB_BACK
)
2443 EnableWindow(hwndBack
, TRUE
);
2445 if (dwFlags
& PSWIZB_NEXT
)
2446 EnableWindow(hwndNext
, TRUE
);
2448 if (!psInfo
->hasFinish
)
2450 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2452 /* Hide the Next button */
2453 ShowWindow(hwndNext
, SW_HIDE
);
2455 /* Show the Finish button */
2456 ShowWindow(hwndFinish
, SW_SHOW
);
2458 if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2459 EnableWindow(hwndFinish
, TRUE
);
2463 /* Hide the Finish button */
2464 ShowWindow(hwndFinish
, SW_HIDE
);
2465 /* Show the Next button */
2466 ShowWindow(hwndNext
, SW_SHOW
);
2469 else if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2470 EnableWindow(hwndFinish
, TRUE
);
2473 /* set the default pushbutton to an enabled button */
2474 if (((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
))
2475 iDefItem
= IDC_FINISH_BUTTON
;
2476 else if (dwFlags
& PSWIZB_NEXT
)
2477 iDefItem
= IDC_NEXT_BUTTON
;
2478 else if (dwFlags
& PSWIZB_BACK
)
2479 iDefItem
= IDC_BACK_BUTTON
;
2481 iDefItem
= IDCANCEL
;
2482 SendMessageW(hwndDlg
, DM_SETDEFID
, iDefItem
, 0);
2484 /* Set focus if no control has it */
2485 hwndFocus
= GetFocus();
2486 if (!hwndFocus
|| hwndFocus
== hwndCancel
)
2487 SetFocus(GetDlgItem(hwndDlg
, iDefItem
));
2492 /******************************************************************************
2493 * PROPSHEET_InsertPage
2495 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2497 if (IS_INTRESOURCE(hpageInsertAfter
))
2498 FIXME("(%p, %d, %p): stub\n", hwndDlg
, LOWORD(hpageInsertAfter
), hpage
);
2500 FIXME("(%p, %p, %p): stub\n", hwndDlg
, hpageInsertAfter
, hpage
);
2504 /******************************************************************************
2505 * PROPSHEET_SetHeaderTitleW
2507 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderTitle
)
2509 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderTitle
));
2512 /******************************************************************************
2513 * PROPSHEET_SetHeaderTitleA
2515 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderTitle
)
2517 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderTitle
));
2520 /******************************************************************************
2521 * PROPSHEET_SetHeaderSubTitleW
2523 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderSubTitle
)
2525 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderSubTitle
));
2528 /******************************************************************************
2529 * PROPSHEET_SetHeaderSubTitleA
2531 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderSubTitle
)
2533 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderSubTitle
));
2536 /******************************************************************************
2537 * PROPSHEET_HwndToIndex
2539 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2542 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2544 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2546 for (index
= 0; index
< psInfo
->nPages
; index
++)
2547 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2549 WARN("%p not found\n", hPageDlg
);
2553 /******************************************************************************
2554 * PROPSHEET_IndexToHwnd
2556 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2558 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2559 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2562 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2563 WARN("%d out of range.\n", iPageIndex
);
2566 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2569 /******************************************************************************
2570 * PROPSHEET_PageToIndex
2572 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2574 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2576 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2578 return PROPSHEET_GetPageIndex(hPage
, psInfo
, -1);
2581 /******************************************************************************
2582 * PROPSHEET_IndexToPage
2584 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2586 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2587 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2588 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2589 WARN("%d out of range.\n", iPageIndex
);
2592 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2595 /******************************************************************************
2596 * PROPSHEET_IdToIndex
2598 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2601 LPCPROPSHEETPAGEW psp
;
2602 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2603 TRACE("(%p, %d)\n", hwndDlg
, iPageId
);
2604 for (index
= 0; index
< psInfo
->nPages
; index
++) {
2605 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2606 if (psp
->u
.pszTemplate
== MAKEINTRESOURCEW(iPageId
))
2613 /******************************************************************************
2614 * PROPSHEET_IndexToId
2616 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2618 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2619 LPCPROPSHEETPAGEW psp
;
2620 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2621 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2622 WARN("%d out of range.\n", iPageIndex
);
2625 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2626 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| !IS_INTRESOURCE(psp
->u
.pszTemplate
)) {
2629 return (LRESULT
)psp
->u
.pszTemplate
;
2632 /******************************************************************************
2633 * PROPSHEET_GetResult
2635 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2637 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2638 return psInfo
->result
;
2641 /******************************************************************************
2642 * PROPSHEET_RecalcPageSizes
2644 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2646 FIXME("(%p): stub\n", hwndDlg
);
2650 /******************************************************************************
2651 * PROPSHEET_GetPageIndex
2653 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2654 * the array of PropPageInfo. If page is not found original index is used
2655 * (page takes precedence over index).
2657 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE page
, const PropSheetInfo
* psInfo
, int original_index
)
2661 TRACE("page %p index %d\n", page
, original_index
);
2663 for (index
= 0; index
< psInfo
->nPages
; index
++)
2664 if (psInfo
->proppage
[index
].hpage
== page
)
2667 return original_index
;
2670 /******************************************************************************
2673 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2676 PropSheetInfo
* psInfo
= RemovePropW(hwndDlg
, PropSheetInfoStr
);
2679 if (!psInfo
) return;
2680 if (!IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
))
2681 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2683 for (i
= 0; i
< psInfo
->nPages
; i
++)
2685 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2687 /* Unsubclass the page dialog window */
2688 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2689 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2690 (psp
->dwFlags
& PSP_HIDEHEADER
))
2692 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2693 PROPSHEET_WizardSubclassProc
, 1);
2696 if(psInfo
->proppage
[i
].hwndPage
)
2697 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2701 if (psp
->dwFlags
& PSP_USETITLE
)
2702 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2704 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2708 DeleteObject(psInfo
->hFont
);
2709 DeleteObject(psInfo
->hFontBold
);
2710 /* If we created the bitmaps, destroy them */
2711 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2712 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2713 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2714 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2715 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2716 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2718 Free(psInfo
->proppage
);
2719 Free(psInfo
->strPropertiesFor
);
2720 ImageList_Destroy(psInfo
->hImageList
);
2725 static INT
do_loop(const PropSheetInfo
*psInfo
)
2729 HWND hwnd
= psInfo
->hwnd
;
2731 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2736 if(!IsDialogMessageW(hwnd
, &msg
))
2738 TranslateMessage(&msg
);
2739 DispatchMessageW(&msg
);
2745 PostQuitMessage(msg
.wParam
);
2750 ret
= psInfo
->result
;
2752 DestroyWindow(hwnd
);
2756 /******************************************************************************
2757 * PROPSHEET_PropertySheet
2759 * Common code between PropertySheetA/W
2761 static INT_PTR
PROPSHEET_PropertySheet(PropSheetInfo
* psInfo
, BOOL unicode
)
2765 if (psInfo
->active_page
>= psInfo
->nPages
) psInfo
->active_page
= 0;
2766 TRACE("startpage: %d of %d pages\n", psInfo
->active_page
, psInfo
->nPages
);
2768 psInfo
->unicode
= unicode
;
2769 psInfo
->ended
= FALSE
;
2771 if(!psInfo
->isModeless
)
2773 parent
= psInfo
->ppshheader
.hwndParent
;
2774 if (parent
) EnableWindow(parent
, FALSE
);
2776 bRet
= PROPSHEET_CreateDialog(psInfo
);
2777 if(!psInfo
->isModeless
)
2779 bRet
= do_loop(psInfo
);
2780 if (parent
) EnableWindow(parent
, TRUE
);
2785 /******************************************************************************
2786 * PropertySheet (COMCTL32.@)
2787 * PropertySheetA (COMCTL32.@)
2789 * Creates a property sheet in the specified property sheet header.
2792 * Modal property sheets: Positive if successful or -1 otherwise.
2793 * Modeless property sheets: Property sheet handle.
2795 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2796 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2798 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2800 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2804 TRACE("(%p)\n", lppsh
);
2806 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2808 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2809 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2811 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2813 if (!psInfo
->usePropPage
)
2814 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2817 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2818 pByte
+= ((LPCPROPSHEETPAGEA
)pByte
)->dwSize
;
2821 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2824 if (psInfo
->usePropPage
)
2825 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2831 return PROPSHEET_PropertySheet(psInfo
, FALSE
);
2834 /******************************************************************************
2835 * PropertySheetW (COMCTL32.@)
2837 * See PropertySheetA.
2839 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2841 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2845 TRACE("(%p)\n", lppsh
);
2847 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2849 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2850 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2852 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2854 if (!psInfo
->usePropPage
)
2855 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2858 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2859 pByte
+= ((LPCPROPSHEETPAGEW
)pByte
)->dwSize
;
2862 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2865 if (psInfo
->usePropPage
)
2866 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2872 return PROPSHEET_PropertySheet(psInfo
, TRUE
);
2875 static LPWSTR
load_string( HINSTANCE instance
, LPCWSTR str
)
2879 if (IS_INTRESOURCE(str
))
2884 WORD i
, id
= LOWORD(str
);
2887 if (!(hrsrc
= FindResourceW( instance
, MAKEINTRESOURCEW((id
>> 4) + 1), (LPWSTR
)RT_STRING
)))
2889 if (!(hmem
= LoadResource( instance
, hrsrc
))) return NULL
;
2890 if (!(ptr
= LockResource( hmem
))) return NULL
;
2891 for (i
= id
& 0x0f; i
> 0; i
--) ptr
+= *ptr
+ 1;
2893 if (!len
) return NULL
;
2894 ret
= Alloc( (len
+ 1) * sizeof(WCHAR
) );
2897 memcpy( ret
, ptr
+ 1, len
* sizeof(WCHAR
) );
2903 int len
= (strlenW(str
) + 1) * sizeof(WCHAR
);
2905 if (ret
) memcpy( ret
, str
, len
);
2911 /******************************************************************************
2912 * CreatePropertySheetPage (COMCTL32.@)
2913 * CreatePropertySheetPageA (COMCTL32.@)
2915 * Creates a new property sheet page.
2918 * Success: Handle to new property sheet page.
2922 * An application must use the PSM_ADDPAGE message to add the new page to
2923 * an existing property sheet.
2925 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2926 LPCPROPSHEETPAGEA lpPropSheetPage
)
2928 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2930 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEA
)));
2932 ppsp
->dwFlags
&= ~ PSP_INTERNAL_UNICODE
;
2934 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2936 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
2938 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
) + 1;
2939 char *template = Alloc( len
);
2941 ppsp
->u
.pszTemplate
= (LPWSTR
)strcpy( template, lpPropSheetPage
->u
.pszTemplate
);
2945 if (ppsp
->dwFlags
& PSP_USEICONID
)
2947 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
2948 PROPSHEET_AtoW(&ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2951 if (ppsp
->dwFlags
& PSP_USETITLE
)
2953 if (!IS_INTRESOURCE( ppsp
->pszTitle
))
2954 PROPSHEET_AtoW( &ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2956 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
2959 ppsp
->pszTitle
= NULL
;
2961 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
2962 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
2964 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
2966 if (!IS_INTRESOURCE( ppsp
->pszHeaderTitle
))
2967 PROPSHEET_AtoW(&ppsp
->pszHeaderTitle
, lpPropSheetPage
->pszHeaderTitle
);
2969 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
2972 ppsp
->pszHeaderTitle
= NULL
;
2974 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
2976 if (!IS_INTRESOURCE( ppsp
->pszHeaderSubTitle
))
2977 PROPSHEET_AtoW(&ppsp
->pszHeaderSubTitle
, lpPropSheetPage
->pszHeaderSubTitle
);
2979 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
2982 ppsp
->pszHeaderSubTitle
= NULL
;
2984 return (HPROPSHEETPAGE
)ppsp
;
2987 /******************************************************************************
2988 * CreatePropertySheetPageW (COMCTL32.@)
2990 * See CreatePropertySheetA.
2992 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
2994 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2996 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEW
)));
2998 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
3000 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
3002 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
3004 int len
= strlenW(lpPropSheetPage
->u
.pszTemplate
) + 1;
3005 WCHAR
*template = Alloc( len
* sizeof (WCHAR
) );
3007 ppsp
->u
.pszTemplate
= strcpyW( template, lpPropSheetPage
->u
.pszTemplate
);
3011 if ( ppsp
->dwFlags
& PSP_USEICONID
)
3013 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
3015 int len
= strlenW(lpPropSheetPage
->u2
.pszIcon
) + 1;
3016 WCHAR
*icon
= Alloc( len
* sizeof (WCHAR
) );
3018 ppsp
->u2
.pszIcon
= strcpyW( icon
, lpPropSheetPage
->u2
.pszIcon
);
3022 if (ppsp
->dwFlags
& PSP_USETITLE
)
3023 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3025 ppsp
->pszTitle
= NULL
;
3027 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3028 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3030 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3031 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3033 ppsp
->pszHeaderTitle
= NULL
;
3035 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3036 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3038 ppsp
->pszHeaderSubTitle
= NULL
;
3040 return (HPROPSHEETPAGE
)ppsp
;
3043 /******************************************************************************
3044 * DestroyPropertySheetPage (COMCTL32.@)
3046 * Destroys a property sheet page previously created with
3047 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
3054 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
3056 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3061 if (!(psp
->dwFlags
& PSP_DLGINDIRECT
) && !IS_INTRESOURCE( psp
->u
.pszTemplate
))
3062 Free ((LPVOID
)psp
->u
.pszTemplate
);
3064 if ((psp
->dwFlags
& PSP_USEICONID
) && !IS_INTRESOURCE( psp
->u2
.pszIcon
))
3065 Free ((LPVOID
)psp
->u2
.pszIcon
);
3067 if ((psp
->dwFlags
& PSP_USETITLE
) && !IS_INTRESOURCE( psp
->pszTitle
))
3068 Free ((LPVOID
)psp
->pszTitle
);
3070 if ((psp
->dwFlags
& PSP_USEHEADERTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderTitle
))
3071 Free ((LPVOID
)psp
->pszHeaderTitle
);
3073 if ((psp
->dwFlags
& PSP_USEHEADERSUBTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderSubTitle
))
3074 Free ((LPVOID
)psp
->pszHeaderSubTitle
);
3081 /******************************************************************************
3082 * PROPSHEET_IsDialogMessage
3084 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3086 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3089 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3092 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3095 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3097 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3099 switch (lpMsg
->wParam
)
3102 if (GetKeyState(VK_SHIFT
) & 0x8000)
3108 case VK_NEXT
: new_page
= 1; break;
3109 case VK_PRIOR
: new_page
= -1; break;
3115 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3117 new_page
+= psInfo
->active_page
;
3120 new_page
= psInfo
->nPages
- 1;
3121 else if (new_page
>= psInfo
->nPages
)
3124 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3131 return IsDialogMessageW(hwnd
, lpMsg
);
3134 /******************************************************************************
3135 * PROPSHEET_DoCommand
3137 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3143 case IDC_APPLY_BUTTON
:
3145 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3147 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3152 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3154 /* don't overwrite ID_PSRESTARTWINDOWS or ID_PSREBOOTSYSTEM */
3155 if (psInfo
->result
== 0)
3156 psInfo
->result
= IDOK
;
3158 if (psInfo
->isModeless
)
3159 psInfo
->activeValid
= FALSE
;
3161 psInfo
->ended
= TRUE
;
3164 EnableWindow(hwndApplyBtn
, FALSE
);
3169 case IDC_BACK_BUTTON
:
3170 PROPSHEET_Back(hwnd
);
3173 case IDC_NEXT_BUTTON
:
3174 PROPSHEET_Next(hwnd
);
3177 case IDC_FINISH_BUTTON
:
3178 PROPSHEET_Finish(hwnd
);
3182 PROPSHEET_Cancel(hwnd
, 0);
3186 PROPSHEET_Help(hwnd
);
3196 /******************************************************************************
3199 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3201 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3206 HPALETTE hOldPal
= 0;
3210 LPCPROPSHEETPAGEW ppshpage
;
3211 WCHAR szBuffer
[256];
3214 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3217 hdcSrc
= CreateCompatibleDC(0);
3219 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3220 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3222 if (psInfo
->active_page
< 0)
3225 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3227 if ( (ppshpage
&& !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3228 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3229 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3231 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3233 COLORREF clrOld
= 0;
3236 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3237 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3239 GetClientRect(hwndLineHeader
, &r
);
3240 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3241 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3243 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), &bm
);
3245 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3247 /* Fill the unoccupied part of the header with color of the
3248 * left-top pixel, but do it only when needed.
3250 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3252 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3253 CopyRect(&r
, &rzone
);
3254 if (bm
.bmWidth
< r
.right
)
3256 r
.left
= bm
.bmWidth
;
3257 FillRect(hdc
, &r
, hbr
);
3259 if (bm
.bmHeight
< r
.bottom
)
3262 r
.top
= bm
.bmHeight
;
3263 FillRect(hdc
, &r
, hbr
);
3268 /* Draw the header itself. */
3270 bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3271 hdcSrc
, 0, 0, SRCCOPY
);
3276 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3277 FillRect(hdc
, &rzone
, hbr
);
3279 /* Draw the header bitmap. It's always centered like a
3280 * common 49 x 49 bitmap. */
3281 margin
= (rzone
.bottom
- 49) / 2;
3282 BitBlt(hdc
, rzone
.right
- 49 - margin
, margin
,
3283 min(bm
.bmWidth
, 49), min(bm
.bmHeight
, 49),
3284 hdcSrc
, 0, 0, SRCCOPY
);
3286 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3287 * if its height is smaller than 49 pixels. Because the reason
3288 * for this bug is unknown the current code doesn't try to
3292 clrOld
= SetTextColor (hdc
, 0x00000000);
3293 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3295 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3296 SetRect(&r
, 20, 10, 0, 0);
3297 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3298 DrawTextW(hdc
, ppshpage
->pszHeaderTitle
, -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3301 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderTitle
,
3305 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3310 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3311 SelectObject(hdc
, psInfo
->hFont
);
3312 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3313 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3314 DrawTextW(hdc
, ppshpage
->pszHeaderSubTitle
, -1, &r
, DT_LEFT
| DT_WORDBREAK
);
3317 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderSubTitle
,
3321 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_WORDBREAK
);
3326 offsety
= rzone
.bottom
+ 2;
3328 SetTextColor(hdc
, clrOld
);
3329 SetBkMode(hdc
, oldBkMode
);
3330 SelectObject(hdc
, hOldFont
);
3331 SelectObject(hdcSrc
, hbmp
);
3334 if ( (ppshpage
&& (ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3335 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3336 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3338 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3340 GetClientRect(hwndLine
, &r
);
3341 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3345 rzone
.right
= r
.right
;
3346 rzone
.bottom
= r
.top
- 1;
3348 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3349 FillRect(hdc
, &rzone
, hbr
);
3351 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), &bm
);
3352 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3354 /* The watermark is truncated to a width of 164 pixels */
3355 r
.right
= min(r
.right
, 164);
3356 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3357 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3359 /* If the bitmap is not big enough, fill the remaining area
3360 with the color of pixel (0,0) of bitmap - see MSDN */
3361 if (r
.top
> bm
.bmHeight
) {
3362 r
.bottom
= r
.top
- 1;
3363 r
.top
= bm
.bmHeight
;
3365 r
.right
= bm
.bmWidth
;
3366 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3367 FillRect(hdc
, &r
, hbr
);
3371 SelectObject(hdcSrc
, hbmp
);
3374 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3375 SelectPalette(hdc
, hOldPal
, FALSE
);
3379 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3384 /******************************************************************************
3385 * PROPSHEET_DialogProc
3387 static INT_PTR CALLBACK
3388 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3390 TRACE("hwnd=%p msg=0x%04x wparam=%lx lparam=%lx\n",
3391 hwnd
, uMsg
, wParam
, lParam
);
3397 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3398 WCHAR
* strCaption
= Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3399 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3403 /* Using PropSheetInfoStr to store extra data doesn't match the native
3404 * common control: native uses TCM_[GS]ETITEM
3406 SetPropW(hwnd
, PropSheetInfoStr
, psInfo
);
3409 * psInfo->hwnd is not being used by WINE code - it exists
3410 * for compatibility with "real" Windoze. The same about
3411 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3414 psInfo
->hwnd
= hwnd
;
3415 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3417 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3419 /* set up the Next and Back buttons by default */
3420 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3424 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3425 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3426 logFont
.lfWeight
= FW_BOLD
;
3427 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3430 * Small icon in the title bar.
3432 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3433 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3436 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3437 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3439 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3440 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3441 psInfo
->ppshheader
.u
.pszIcon
,
3446 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3448 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3451 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3452 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3454 psInfo
->strPropertiesFor
= strCaption
;
3456 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3458 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3460 PROPSHEET_LoadWizardBitmaps(psInfo
);
3462 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3464 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3465 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3466 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3467 SetFocus(GetDlgItem(hwnd
, IDC_NEXT_BUTTON
));
3471 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3473 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3474 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3476 SetFocus(GetDlgItem(hwnd
, IDOK
));
3479 if (IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
) &&
3480 psInfo
->ppshheader
.hInstance
)
3484 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3485 (UINT_PTR
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3486 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3490 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3491 psInfo
->ppshheader
.pszCaption
);
3495 if (psInfo
->useCallback
)
3496 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
, PSCB_INITIALIZED
, 0);
3498 idx
= psInfo
->active_page
;
3499 psInfo
->active_page
= -1;
3501 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3503 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3504 * as some programs call TCM_GETCURSEL to get the current selection
3505 * from which to switch to the next page */
3506 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3508 PROPSHEET_UnChanged(hwnd
, NULL
);
3510 /* wizards set their focus during init */
3511 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3517 case WM_PRINTCLIENT
:
3519 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3523 PROPSHEET_CleanUp(hwnd
);
3527 PROPSHEET_Cancel(hwnd
, 1);
3528 return FALSE
; /* let DefDlgProc post us WM_COMMAND/IDCANCEL */
3531 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3533 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3538 /* No default handler, forward notification to active page */
3539 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3541 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3542 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3549 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3551 if (pnmh
->code
== TCN_SELCHANGE
)
3553 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3554 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3557 if(pnmh
->code
== TCN_SELCHANGING
)
3559 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3560 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3567 case WM_SYSCOLORCHANGE
:
3568 COMCTL32_RefreshSysColors();
3571 case PSM_GETCURRENTPAGEHWND
:
3573 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3579 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3580 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3582 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3588 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3592 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3595 case PSM_GETTABCONTROL
:
3597 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3599 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3608 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3609 if(msgResult
!= FALSE
)
3611 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3614 (HPROPSHEETPAGE
)lParam
);
3617 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3622 case PSM_CANCELTOCLOSE
:
3624 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3625 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3626 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3628 EnableWindow(hwndCancel
, FALSE
);
3629 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, sizeof(buf
)/sizeof(buf
[0])))
3630 SetWindowTextW(hwndOK
, buf
);
3635 case PSM_RESTARTWINDOWS
:
3637 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3642 /* reboot system takes precedence over restart windows */
3643 if (psInfo
->result
!= ID_PSREBOOTSYSTEM
)
3644 psInfo
->result
= ID_PSRESTARTWINDOWS
;
3649 case PSM_REBOOTSYSTEM
:
3651 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3656 psInfo
->result
= ID_PSREBOOTSYSTEM
;
3662 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3666 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3671 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3673 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3678 case PSM_QUERYSIBLINGS
:
3680 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3682 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3690 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3691 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3692 * on success or FALSE otherwise, as specified on MSDN Online.
3693 * Also see the MFC code for
3694 * CPropertySheet::AddPage(CPropertyPage* pPage).
3697 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3699 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3704 case PSM_REMOVEPAGE
:
3705 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3708 case PSM_ISDIALOGMESSAGE
:
3710 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3711 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3715 case PSM_PRESSBUTTON
:
3716 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3719 case PSM_SETFINISHTEXTA
:
3720 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3723 case PSM_SETWIZBUTTONS
:
3724 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3727 case PSM_SETCURSELID
:
3728 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3731 case PSM_SETFINISHTEXTW
:
3732 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3735 case PSM_INSERTPAGE
:
3737 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3738 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3742 case PSM_SETHEADERTITLEW
:
3743 PROPSHEET_SetHeaderTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3746 case PSM_SETHEADERTITLEA
:
3747 PROPSHEET_SetHeaderTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3750 case PSM_SETHEADERSUBTITLEW
:
3751 PROPSHEET_SetHeaderSubTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3754 case PSM_SETHEADERSUBTITLEA
:
3755 PROPSHEET_SetHeaderSubTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3758 case PSM_HWNDTOINDEX
:
3760 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3761 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3765 case PSM_INDEXTOHWND
:
3767 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3768 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3772 case PSM_PAGETOINDEX
:
3774 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3775 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3779 case PSM_INDEXTOPAGE
:
3781 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3782 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3788 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3789 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3795 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3796 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3802 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3803 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3807 case PSM_RECALCPAGESIZES
:
3809 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3810 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);