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
35 * o PSM_RECALCPAGESIZES
40 * o PSN_QUERYINITIALFOCUS
41 * o PSN_TRANSLATEACCELERATOR
44 * o PSH_STRETCHWATERMARK
48 * o PSP_USEFUSIONCONTEXT
55 #define NONAMELESSUNION
67 #include "wine/debug.h"
69 /******************************************************************************
93 } MyDLGITEMTEMPLATEEX
;
96 typedef struct tagPropPageInfo
98 HPROPSHEETPAGE hpage
; /* to keep track of pages not passed to PropertySheet */
107 typedef struct tagPropSheetInfo
110 PROPSHEETHEADERW ppshheader
;
112 LPWSTR strPropertiesFor
;
122 PropPageInfo
* proppage
;
127 HIMAGELIST hImageList
;
138 /******************************************************************************
139 * Defines and global variables
142 static const WCHAR PropSheetInfoStr
[] =
143 {'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0 };
145 #define PSP_INTERNAL_UNICODE 0x80000000
147 #define MAX_CAPTION_LENGTH 255
148 #define MAX_TABTEXT_LENGTH 255
149 #define MAX_BUTTONTEXT_LENGTH 64
151 #define INTRNL_ANY_WIZARD (PSH_WIZARD | PSH_WIZARD97_OLD | PSH_WIZARD97_NEW | PSH_WIZARD_LITE)
153 /* Wizard metrics specified in DLUs */
154 #define WIZARD_PADDING 7
155 #define WIZARD_HEADER_HEIGHT 36
157 /******************************************************************************
160 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
);
161 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
);
162 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
);
163 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
166 HPROPSHEETPAGE hpage
);
167 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, const PropSheetInfo
* psInfo
, int original_index
);
168 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
);
169 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
);
170 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
, int index
, HPROPSHEETPAGE hpage
);
172 static INT_PTR CALLBACK
173 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
175 WINE_DEFAULT_DEBUG_CHANNEL(propsheet
);
177 static WCHAR
*heap_strdupW(const WCHAR
*str
)
179 int len
= lstrlenW(str
) + 1;
180 WCHAR
*ret
= Alloc(len
* sizeof(WCHAR
));
185 static WCHAR
*heap_strdupAtoW(const char *str
)
190 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, 0, 0);
191 ret
= Alloc(len
* sizeof(WCHAR
));
192 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
197 #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");}
198 /******************************************************************************
199 * PROPSHEET_UnImplementedFlags
201 * Document use of flags we don't implement yet.
203 static VOID
PROPSHEET_UnImplementedFlags(DWORD dwFlags
)
210 * unhandled header flags:
211 * PSH_RTLREADING 0x00000800
212 * PSH_STRETCHWATERMARK 0x00040000
213 * PSH_USEPAGELANG 0x00200000
216 add_flag(PSH_RTLREADING
);
217 add_flag(PSH_STRETCHWATERMARK
);
218 add_flag(PSH_USEPAGELANG
);
219 if (string
[0] != '\0')
220 FIXME("%s\n", string
);
224 /******************************************************************************
225 * PROPSHEET_GetPageRect
227 * Retrieve rect from tab control and map into the dialog for SetWindowPos
229 static void PROPSHEET_GetPageRect(const PropSheetInfo
* psInfo
, HWND hwndDlg
,
230 RECT
*rc
, LPCPROPSHEETPAGEW ppshpage
)
232 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) {
236 if (((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
237 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
238 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) ||
239 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
))
241 rc
->left
= rc
->top
= WIZARD_PADDING
;
245 rc
->left
= rc
->top
= 0;
247 rc
->right
= psInfo
->width
- rc
->left
;
248 rc
->bottom
= psInfo
->height
- rc
->top
;
249 MapDialogRect(hwndDlg
, rc
);
251 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
252 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
253 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
))
255 hwndChild
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
256 GetClientRect(hwndChild
, &r
);
257 MapWindowPoints(hwndChild
, hwndDlg
, (LPPOINT
) &r
, 2);
258 rc
->top
+= r
.bottom
+ 1;
261 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
262 GetClientRect(hwndTabCtrl
, rc
);
263 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)rc
);
264 MapWindowPoints(hwndTabCtrl
, hwndDlg
, (LPPOINT
)rc
, 2);
268 /******************************************************************************
269 * PROPSHEET_FindPageByResId
271 * Find page index corresponding to page resource id.
273 static INT
PROPSHEET_FindPageByResId(const PropSheetInfo
* psInfo
, LRESULT resId
)
277 for (i
= 0; i
< psInfo
->nPages
; i
++)
279 LPCPROPSHEETPAGEA lppsp
= (LPCPROPSHEETPAGEA
)psInfo
->proppage
[i
].hpage
;
281 /* Fixme: if resource ID is a string shall we use strcmp ??? */
282 if (lppsp
->u
.pszTemplate
== (LPVOID
)resId
)
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 (!IS_INTRESOURCE(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 (!IS_INTRESOURCE(lppsh
->pszCaption
))
377 psInfo
->ppshheader
.pszCaption
= heap_strdupW( lppsh
->pszCaption
);
379 psInfo
->nPages
= lppsh
->nPages
;
381 if (dwFlags
& PSH_USEPSTARTPAGE
)
383 TRACE("PSH_USEPSTARTPAGE is on\n");
384 psInfo
->active_page
= 0;
387 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
389 PROPSHEET_CollectSheetInfoCommon(psInfo
, dwFlags
);
392 /******************************************************************************
393 * PROPSHEET_CollectPageInfo
395 * Collect property sheet data.
396 * With code taken from DIALOG_ParseTemplate32.
398 static BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
399 PropSheetInfo
* psInfo
,
400 int index
, BOOL resize
)
402 const DLGTEMPLATE
* pTemplate
;
411 psInfo
->proppage
[index
].hpage
= (HPROPSHEETPAGE
)lppsp
;
412 psInfo
->proppage
[index
].hwndPage
= 0;
413 psInfo
->proppage
[index
].isDirty
= FALSE
;
416 * Process property page flags.
418 dwFlags
= lppsp
->dwFlags
;
419 psInfo
->proppage
[index
].useCallback
= (dwFlags
& PSP_USECALLBACK
) && (lppsp
->pfnCallback
);
420 psInfo
->proppage
[index
].hasHelp
= dwFlags
& PSP_HASHELP
;
421 psInfo
->proppage
[index
].hasIcon
= dwFlags
& (PSP_USEHICON
| PSP_USEICONID
);
423 /* as soon as we have a page with the help flag, set the sheet flag on */
424 if (psInfo
->proppage
[index
].hasHelp
)
425 psInfo
->hasHelp
= TRUE
;
428 * Process page template.
430 if (dwFlags
& PSP_DLGINDIRECT
)
431 pTemplate
= lppsp
->u
.pResource
;
432 else if(dwFlags
& PSP_INTERNAL_UNICODE
)
434 HRSRC hResource
= FindResourceW(lppsp
->hInstance
,
435 lppsp
->u
.pszTemplate
,
437 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
439 pTemplate
= LockResource(hTemplate
);
443 HRSRC hResource
= FindResourceA(lppsp
->hInstance
,
444 (LPCSTR
)lppsp
->u
.pszTemplate
,
446 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
448 pTemplate
= LockResource(hTemplate
);
452 * Extract the size of the page and the caption.
457 p
= (const WORD
*)pTemplate
;
459 if (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
461 /* DLGTEMPLATEEX (not defined in any std. header file) */
465 p
+= 2; /* help ID */
466 p
+= 2; /* ext style */
474 p
+= 2; /* ext style */
480 width
= (WORD
)*p
; p
++;
481 height
= (WORD
)*p
; p
++;
483 if (lppsp
->dwFlags
& (PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
))
484 psInfo
->ppshheader
.dwFlags
|= PSH_HEADER
;
486 /* Special calculation for interior wizard pages so the largest page is
487 * calculated correctly. We need to add all the padding and space occupied
488 * by the header so the width and height sums up to the whole wizard client
490 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
491 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
492 !(dwFlags
& PSP_HIDEHEADER
))
494 height
+= 2 * WIZARD_PADDING
+ WIZARD_HEADER_HEIGHT
;
495 width
+= 2 * WIZARD_PADDING
;
497 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
)
499 height
+= 2 * WIZARD_PADDING
;
500 width
+= 2 * WIZARD_PADDING
;
503 /* remember the largest width and height */
506 if (width
> psInfo
->width
)
507 psInfo
->width
= width
;
509 if (height
> psInfo
->height
)
510 psInfo
->height
= height
;
523 p
+= lstrlenW( p
) + 1;
537 p
+= lstrlenW( p
) + 1;
541 /* Extract the caption */
542 psInfo
->proppage
[index
].pszText
= p
;
543 TRACE("Tab %d %s\n",index
,debugstr_w( p
));
545 if (dwFlags
& PSP_USETITLE
)
549 static const WCHAR pszNull
[] = { '(','n','u','l','l',')',0 };
551 if (IS_INTRESOURCE( lppsp
->pszTitle
))
553 if (LoadStringW( lppsp
->hInstance
, (DWORD_PTR
)lppsp
->pszTitle
, szTitle
, ARRAY_SIZE(szTitle
)))
561 pTitle
= lppsp
->pszTitle
;
563 psInfo
->proppage
[index
].pszText
= heap_strdupW( pTitle
);
567 * Build the image list for icons
569 if ((dwFlags
& PSP_USEHICON
) || (dwFlags
& PSP_USEICONID
))
572 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
573 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
575 if (dwFlags
& PSP_USEICONID
)
576 hIcon
= LoadImageW(lppsp
->hInstance
, lppsp
->u2
.pszIcon
, IMAGE_ICON
,
577 icon_cx
, icon_cy
, LR_DEFAULTCOLOR
);
579 hIcon
= lppsp
->u2
.hIcon
;
583 if (psInfo
->hImageList
== 0 )
584 psInfo
->hImageList
= ImageList_Create(icon_cx
, icon_cy
, ILC_COLOR
, 1, 1);
586 ImageList_AddIcon(psInfo
->hImageList
, hIcon
);
594 /******************************************************************************
595 * PROPSHEET_CreateDialog
597 * Creates the actual property sheet.
599 static INT_PTR
PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
)
606 WORD resID
= IDD_PROPSHEET
;
608 TRACE("(%p)\n", psInfo
);
609 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
612 if( psInfo
->unicode
)
614 if(!(hRes
= FindResourceW(COMCTL32_hModule
,
615 MAKEINTRESOURCEW(resID
),
621 if(!(hRes
= FindResourceA(COMCTL32_hModule
,
622 MAKEINTRESOURCEA(resID
),
627 if(!(template = LoadResource(COMCTL32_hModule
, hRes
)))
631 * Make a copy of the dialog template.
633 resSize
= SizeofResource(COMCTL32_hModule
, hRes
);
635 temp
= Alloc(2 * resSize
);
640 memcpy(temp
, template, resSize
);
642 if (psInfo
->ppshheader
.dwFlags
& PSH_NOCONTEXTHELP
)
644 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
645 ((MyDLGTEMPLATEEX
*)temp
)->style
&= ~DS_CONTEXTHELP
;
647 ((DLGTEMPLATE
*)temp
)->style
&= ~DS_CONTEXTHELP
;
649 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
650 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARDCONTEXTHELP
))
652 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
653 ((MyDLGTEMPLATEEX
*)temp
)->style
|= DS_CONTEXTHELP
;
655 ((DLGTEMPLATE
*)temp
)->style
|= DS_CONTEXTHELP
;
658 if (psInfo
->useCallback
)
659 (*(psInfo
->ppshheader
.pfnCallback
))(0, PSCB_PRECREATE
, (LPARAM
)temp
);
661 /* NOTE: MSDN states "Returns a positive value if successful, or -1
662 * otherwise for modal property sheets.", but this is wrong. The
663 * actual return value is either TRUE (success), FALSE (cancel) or
665 if( psInfo
->unicode
)
667 ret
= (INT_PTR
)CreateDialogIndirectParamW(psInfo
->ppshheader
.hInstance
,
668 temp
, psInfo
->ppshheader
.hwndParent
,
669 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
670 if ( !ret
) ret
= -1;
674 ret
= (INT_PTR
)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
675 temp
, psInfo
->ppshheader
.hwndParent
,
676 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
677 if ( !ret
) ret
= -1;
685 /******************************************************************************
686 * PROPSHEET_SizeMismatch
688 * Verify that the tab control and the "largest" property sheet page dlg. template
691 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
693 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
694 RECT rcOrigTab
, rcPage
;
699 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
700 TRACE("orig tab %s\n", wine_dbgstr_rect(&rcOrigTab
));
705 SetRect(&rcPage
, 0, 0, psInfo
->width
, psInfo
->height
);
706 MapDialogRect(hwndDlg
, &rcPage
);
707 TRACE("biggest page %s\n", wine_dbgstr_rect(&rcPage
));
709 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
711 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
717 /******************************************************************************
718 * PROPSHEET_AdjustSize
720 * Resizes the property sheet and the tab control to fit the largest page.
722 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
724 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
725 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
728 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
732 /* Get the height of buttons */
733 GetClientRect(hwndButton
, &rc
);
734 buttonHeight
= rc
.bottom
;
739 SetRect(&rc
, 0, 0, psInfo
->width
, psInfo
->height
);
740 MapDialogRect(hwndDlg
, &rc
);
742 /* retrieve the dialog units */
743 units
.left
= units
.right
= 4;
744 units
.top
= units
.bottom
= 8;
745 MapDialogRect(hwndDlg
, &units
);
748 * Resize the tab control.
750 GetClientRect(hwndTabCtrl
,&tabRect
);
752 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
754 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
756 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
757 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
760 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
762 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
763 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
766 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
770 TRACE("setting tab %p, rc (0,0)-(%d,%d)\n",
771 hwndTabCtrl
, rc
.right
, rc
.bottom
);
772 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
773 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
775 GetClientRect(hwndTabCtrl
, &rc
);
777 TRACE("tab client rc %s\n", wine_dbgstr_rect(&rc
));
779 rc
.right
+= (padding
.x
* 2);
780 rc
.bottom
+= buttonHeight
+ (3 * padding
.y
);
782 style
= GetWindowLongW(hwndDlg
, GWL_STYLE
);
783 if (!(style
& WS_CHILD
))
784 AdjustWindowRect(&rc
, style
, FALSE
);
790 * Resize the property sheet.
792 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
793 hwndDlg
, rc
.right
, rc
.bottom
);
794 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
795 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
799 /******************************************************************************
800 * PROPSHEET_AdjustSizeWizard
802 * Resizes the property sheet to fit the largest page.
804 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
806 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
807 RECT rc
, lineRect
, dialogRect
;
809 /* Biggest page size */
810 SetRect(&rc
, 0, 0, psInfo
->width
, psInfo
->height
);
811 MapDialogRect(hwndDlg
, &rc
);
813 TRACE("Biggest page %s\n", wine_dbgstr_rect(&rc
));
815 /* Add space for the buttons row */
816 GetWindowRect(hwndLine
, &lineRect
);
817 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
818 GetClientRect(hwndDlg
, &dialogRect
);
819 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
821 /* Convert the client coordinates to window coordinates */
822 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
824 /* Resize the property sheet */
825 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
826 hwndDlg
, rc
.right
, rc
.bottom
);
827 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
828 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
833 /******************************************************************************
834 * PROPSHEET_AdjustButtons
836 * Adjusts the buttons' positions.
838 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, const PropSheetInfo
* psInfo
)
840 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
844 int buttonWidth
, buttonHeight
;
845 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
847 if (psInfo
->hasApply
)
854 * Obtain the size of the buttons.
856 GetClientRect(hwndButton
, &rcSheet
);
857 buttonWidth
= rcSheet
.right
;
858 buttonHeight
= rcSheet
.bottom
;
861 * Get the size of the property sheet.
863 GetClientRect(hwndParent
, &rcSheet
);
866 * All buttons will be at this y coordinate.
868 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
871 * Position OK button and make it default.
873 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
875 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
877 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
878 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
880 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
884 * Position Cancel button.
886 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
888 x
+= padding
.x
+ buttonWidth
;
890 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
891 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
894 * Position Apply button.
896 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
899 x
+= padding
.x
+ buttonWidth
;
901 ShowWindow(hwndButton
, SW_HIDE
);
903 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
904 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
905 EnableWindow(hwndButton
, FALSE
);
908 * Position Help button.
910 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
912 x
+= padding
.x
+ buttonWidth
;
913 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
914 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
917 ShowWindow(hwndButton
, SW_HIDE
);
922 /******************************************************************************
923 * PROPSHEET_AdjustButtonsWizard
925 * Adjusts the buttons' positions.
927 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
928 const PropSheetInfo
* psInfo
)
930 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
931 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
932 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
936 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
937 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
941 if (psInfo
->hasFinish
)
945 * Obtain the size of the buttons.
947 GetClientRect(hwndButton
, &rcSheet
);
948 buttonWidth
= rcSheet
.right
;
949 buttonHeight
= rcSheet
.bottom
;
951 GetClientRect(hwndLine
, &rcSheet
);
952 lineHeight
= rcSheet
.bottom
;
955 * Get the size of the property sheet.
957 GetClientRect(hwndParent
, &rcSheet
);
960 * All buttons will be at this y coordinate.
962 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
965 * Position the Back button.
967 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
969 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1)) - buttonWidth
;
971 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
972 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
975 * Position the Next button.
977 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
981 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
982 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
985 * Position the Finish button.
987 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
989 if (psInfo
->hasFinish
)
990 x
+= padding
.x
+ buttonWidth
;
992 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
993 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
995 if (!psInfo
->hasFinish
)
996 ShowWindow(hwndButton
, SW_HIDE
);
999 * Position the Cancel button.
1001 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1003 x
+= padding
.x
+ buttonWidth
;
1005 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1006 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1009 * Position Help button.
1011 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1013 if (psInfo
->hasHelp
)
1015 x
+= padding
.x
+ buttonWidth
;
1017 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1018 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1021 ShowWindow(hwndButton
, SW_HIDE
);
1023 if (psInfo
->ppshheader
.dwFlags
&
1024 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1028 * Position and resize the sunken line.
1031 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1033 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1034 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1035 SWP_NOZORDER
| SWP_NOACTIVATE
);
1038 * Position and resize the header sunken line.
1041 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1042 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1043 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1044 ShowWindow(hwndLineHeader
, SW_HIDE
);
1049 /******************************************************************************
1050 * PROPSHEET_GetPaddingInfo
1052 * Returns the layout information.
1054 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1056 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1058 PADDING_INFO padding
;
1060 GetWindowRect(hwndTab
, &rcTab
);
1061 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rcTab
, 2 );
1063 padding
.x
= rcTab
.left
;
1064 padding
.y
= rcTab
.top
;
1069 /******************************************************************************
1070 * PROPSHEET_GetPaddingInfoWizard
1072 * Returns the layout information.
1073 * Vertical spacing is the distance between the line and the buttons.
1074 * Do NOT use the Help button to gather padding information when it isn't mapped
1075 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1076 * for it in this case !
1077 * FIXME: I'm not sure about any other coordinate problems with these evil
1078 * buttons. Fix it in case additional problems appear or maybe calculate
1079 * a padding in a completely different way, as this is somewhat messy.
1081 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1084 PADDING_INFO padding
;
1088 POINT ptButton
, ptLine
;
1091 if (psInfo
->hasHelp
)
1097 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1099 idButton
= IDC_NEXT_BUTTON
;
1103 /* hopefully this is ok */
1104 idButton
= IDCANCEL
;
1108 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1109 GetWindowRect(hwndControl
, &rc
);
1110 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1111 ptButton
.x
= rc
.left
;
1112 ptButton
.y
= rc
.top
;
1115 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1116 GetWindowRect(hwndControl
, &rc
);
1117 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1119 ptLine
.y
= rc
.bottom
;
1121 padding
.y
= ptButton
.y
- ptLine
.y
;
1124 ERR("padding negative ! Please report this !\n");
1126 /* this is most probably not correct, but the best we have now */
1127 padding
.x
= padding
.y
;
1131 /******************************************************************************
1132 * PROPSHEET_CreateTabControl
1134 * Insert the tabs in the tab control.
1136 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1137 const PropSheetInfo
* psInfo
)
1139 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1145 item
.mask
= TCIF_TEXT
;
1146 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1148 nTabs
= psInfo
->nPages
;
1151 * Set the image list for icons.
1153 if (psInfo
->hImageList
)
1155 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1158 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 0, 0);
1159 for (i
= 0; i
< nTabs
; i
++)
1161 if ( psInfo
->proppage
[i
].hasIcon
)
1163 item
.mask
|= TCIF_IMAGE
;
1164 item
.iImage
= iImage
++;
1168 item
.mask
&= ~TCIF_IMAGE
;
1171 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1172 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, i
, (LPARAM
)&item
);
1174 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 1, 0);
1179 /******************************************************************************
1180 * PROPSHEET_WizardSubclassProc
1182 * Subclassing window procedure for wizard exterior pages to prevent drawing
1183 * background and so drawing above the watermark.
1185 static LRESULT CALLBACK
1186 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1193 case WM_CTLCOLORSTATIC
:
1194 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1195 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1198 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1202 * Get the size of an in-memory Template
1204 *( Based on the code of PROPSHEET_CollectPageInfo)
1205 * See also dialog.c/DIALOG_ParseTemplate32().
1208 static UINT
GetTemplateSize(const DLGTEMPLATE
* pTemplate
)
1211 const WORD
* p
= (const WORD
*)pTemplate
;
1212 BOOL istemplateex
= (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1218 /* DLGTEMPLATEEX (not defined in any std. header file) */
1220 TRACE("is DLGTEMPLATEEX\n");
1222 p
++; /* signature */
1223 p
+= 2; /* help ID */
1224 p
+= 2; /* ext style */
1231 TRACE("is DLGTEMPLATE\n");
1233 p
+= 2; /* ext style */
1236 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1252 TRACE("menu %s\n",debugstr_w( p
));
1253 p
+= lstrlenW( p
) + 1;
1264 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1267 TRACE("class %s\n",debugstr_w( p
));
1268 p
+= lstrlenW( p
) + 1;
1273 TRACE("title %s\n",debugstr_w( p
));
1274 p
+= lstrlenW( p
) + 1;
1276 /* font, if DS_SETFONT set */
1277 if ((DS_SETFONT
& ((istemplateex
)? ((const MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1280 p
+=(istemplateex
)?3:1;
1281 TRACE("font %s\n",debugstr_w( p
));
1282 p
+= lstrlenW( p
) + 1; /* the font name */
1285 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1286 * that are following the DLGTEMPLATE(EX) data */
1287 TRACE("%d items\n",nrofitems
);
1288 while (nrofitems
> 0)
1290 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1293 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1302 TRACE("class ordinal 0x%08x\n",*(const DWORD
*)p
);
1306 TRACE("class %s\n",debugstr_w( p
));
1307 p
+= lstrlenW( p
) + 1;
1311 /* check title text */
1318 TRACE("text ordinal 0x%08x\n",*(const DWORD
*)p
);
1322 TRACE("text %s\n",debugstr_w( p
));
1323 p
+= lstrlenW( p
) + 1;
1326 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1330 ret
= (p
- (const WORD
*)pTemplate
) * sizeof(WORD
);
1331 TRACE("%p %p size 0x%08x\n", p
, pTemplate
, ret
);
1335 /******************************************************************************
1336 * PROPSHEET_CreatePage
1340 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1342 const PropSheetInfo
* psInfo
,
1343 LPCPROPSHEETPAGEW ppshpage
)
1345 const DLGTEMPLATE
* pTemplate
;
1348 DLGTEMPLATE
* pTemplateCopy
= NULL
;
1350 TRACE("index %d\n", index
);
1352 if (ppshpage
== NULL
)
1357 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1359 pTemplate
= ppshpage
->u
.pResource
;
1360 resSize
= GetTemplateSize(pTemplate
);
1362 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1367 hResource
= FindResourceW(ppshpage
->hInstance
,
1368 ppshpage
->u
.pszTemplate
,
1373 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1375 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1379 pTemplate
= LockResource(hTemplate
);
1381 * Make a copy of the dialog template to make it writable
1389 hResource
= FindResourceA(ppshpage
->hInstance
,
1390 (LPCSTR
)ppshpage
->u
.pszTemplate
,
1395 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1397 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1401 pTemplate
= LockResource(hTemplate
);
1403 * Make a copy of the dialog template to make it writable
1406 pTemplateCopy
= Alloc(resSize
);
1410 TRACE("copying pTemplate %p into pTemplateCopy %p (%d)\n", pTemplate
, pTemplateCopy
, resSize
);
1411 memcpy(pTemplateCopy
, pTemplate
, resSize
);
1413 if (((MyDLGTEMPLATEEX
*)pTemplateCopy
)->signature
== 0xFFFF)
1415 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1416 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~DS_MODALFRAME
;
1417 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_CAPTION
;
1418 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_SYSMENU
;
1419 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_POPUP
;
1420 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_DISABLED
;
1421 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_VISIBLE
;
1422 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_THICKFRAME
;
1424 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->exStyle
|= WS_EX_CONTROLPARENT
;
1428 pTemplateCopy
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1429 pTemplateCopy
->style
&= ~DS_MODALFRAME
;
1430 pTemplateCopy
->style
&= ~WS_CAPTION
;
1431 pTemplateCopy
->style
&= ~WS_SYSMENU
;
1432 pTemplateCopy
->style
&= ~WS_POPUP
;
1433 pTemplateCopy
->style
&= ~WS_DISABLED
;
1434 pTemplateCopy
->style
&= ~WS_VISIBLE
;
1435 pTemplateCopy
->style
&= ~WS_THICKFRAME
;
1437 pTemplateCopy
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1440 if (psInfo
->proppage
[index
].useCallback
)
1441 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1442 (LPPROPSHEETPAGEW
)ppshpage
);
1444 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1445 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1448 ppshpage
->pfnDlgProc
,
1451 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1454 ppshpage
->pfnDlgProc
,
1456 /* Free a no more needed copy */
1457 Free(pTemplateCopy
);
1462 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1464 /* Subclass exterior wizard pages */
1465 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1466 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1467 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1469 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1470 (DWORD_PTR
)ppshpage
);
1472 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1473 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1478 /******************************************************************************
1479 * PROPSHEET_LoadWizardBitmaps
1481 * Loads the watermark and header bitmaps for a wizard.
1483 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1485 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1487 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1488 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1489 considers hbmWatermark as valid. */
1490 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1491 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1493 psInfo
->ppshheader
.u4
.hbmWatermark
=
1494 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1497 /* Same behavior as for watermarks */
1498 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1499 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1501 psInfo
->ppshheader
.u5
.hbmHeader
=
1502 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1508 /******************************************************************************
1509 * PROPSHEET_ShowPage
1511 * Displays or creates the specified page.
1513 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1516 HWND hwndLineHeader
;
1518 LPCPROPSHEETPAGEW ppshpage
;
1520 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1521 if (index
== psInfo
->active_page
)
1523 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1524 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1528 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1529 if (psInfo
->proppage
[index
].hwndPage
== 0)
1531 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1534 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1536 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1537 psInfo
->proppage
[index
].pszText
);
1539 control
= GetNextDlgTabItem(psInfo
->proppage
[index
].hwndPage
, NULL
, FALSE
);
1544 if (psInfo
->active_page
!= -1)
1545 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1547 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1549 /* Synchronize current selection with tab control
1550 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1551 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1552 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1554 psInfo
->active_page
= index
;
1555 psInfo
->activeValid
= TRUE
;
1557 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1559 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1560 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1562 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1563 ShowWindow(hwndLineHeader
, SW_HIDE
);
1565 ShowWindow(hwndLineHeader
, SW_SHOW
);
1571 /******************************************************************************
1574 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1578 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1582 TRACE("active_page %d\n", psInfo
->active_page
);
1583 if (psInfo
->active_page
< 0)
1586 psn
.hdr
.code
= PSN_WIZBACK
;
1587 psn
.hdr
.hwndFrom
= hwndDlg
;
1591 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1593 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1596 else if (result
== 0)
1597 idx
= psInfo
->active_page
- 1;
1599 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1601 if (idx
>= 0 && idx
< psInfo
->nPages
)
1603 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1605 SetFocus(GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
));
1606 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
1607 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1613 /******************************************************************************
1616 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1620 LRESULT msgResult
= 0;
1621 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1624 TRACE("active_page %d\n", psInfo
->active_page
);
1625 if (psInfo
->active_page
< 0)
1628 psn
.hdr
.code
= PSN_WIZNEXT
;
1629 psn
.hdr
.hwndFrom
= hwndDlg
;
1633 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1635 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1636 if (msgResult
== -1)
1638 else if (msgResult
== 0)
1639 idx
= psInfo
->active_page
+ 1;
1641 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1643 if (idx
< psInfo
->nPages
)
1645 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1647 SetFocus(GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
));
1648 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
1649 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1656 /******************************************************************************
1659 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1663 LRESULT msgResult
= 0;
1664 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1666 TRACE("active_page %d\n", psInfo
->active_page
);
1667 if (psInfo
->active_page
< 0)
1670 psn
.hdr
.code
= PSN_WIZFINISH
;
1671 psn
.hdr
.hwndFrom
= hwndDlg
;
1675 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1677 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1679 TRACE("msg result %ld\n", msgResult
);
1684 if (psInfo
->result
== 0)
1685 psInfo
->result
= IDOK
;
1686 if (psInfo
->isModeless
)
1687 psInfo
->activeValid
= FALSE
;
1689 psInfo
->ended
= TRUE
;
1694 /******************************************************************************
1697 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1702 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1704 TRACE("active_page %d\n", psInfo
->active_page
);
1705 if (psInfo
->active_page
< 0)
1708 psn
.hdr
.hwndFrom
= hwndDlg
;
1714 * Send PSN_KILLACTIVE to the current page.
1716 psn
.hdr
.code
= PSN_KILLACTIVE
;
1718 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1720 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1724 * Send PSN_APPLY to all pages.
1726 psn
.hdr
.code
= PSN_APPLY
;
1727 psn
.lParam
= lParam
;
1729 for (i
= 0; i
< psInfo
->nPages
; i
++)
1731 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1734 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1736 case PSNRET_INVALID
:
1737 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1739 case PSNRET_INVALID_NOCHANGEPAGE
:
1747 psInfo
->activeValid
= FALSE
;
1749 else if(psInfo
->active_page
>= 0)
1751 psn
.hdr
.code
= PSN_SETACTIVE
;
1753 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1754 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1760 /******************************************************************************
1763 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1765 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1770 TRACE("active_page %d\n", psInfo
->active_page
);
1771 if (psInfo
->active_page
< 0)
1774 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1775 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1776 psn
.hdr
.hwndFrom
= hwndDlg
;
1780 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1783 psn
.hdr
.code
= PSN_RESET
;
1784 psn
.lParam
= lParam
;
1786 for (i
= 0; i
< psInfo
->nPages
; i
++)
1788 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1791 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1794 if (psInfo
->isModeless
)
1796 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1797 psInfo
->activeValid
= FALSE
;
1800 psInfo
->ended
= TRUE
;
1803 /******************************************************************************
1806 static void PROPSHEET_Help(HWND hwndDlg
)
1808 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1812 TRACE("active_page %d\n", psInfo
->active_page
);
1813 if (psInfo
->active_page
< 0)
1816 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1817 psn
.hdr
.code
= PSN_HELP
;
1818 psn
.hdr
.hwndFrom
= hwndDlg
;
1822 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1825 /******************************************************************************
1828 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1831 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1834 if (!psInfo
) return;
1836 * Set the dirty flag of this page.
1838 for (i
= 0; i
< psInfo
->nPages
; i
++)
1840 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1841 psInfo
->proppage
[i
].isDirty
= TRUE
;
1845 * Enable the Apply button.
1847 if (psInfo
->hasApply
)
1849 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1851 EnableWindow(hwndApplyBtn
, TRUE
);
1855 /******************************************************************************
1856 * PROPSHEET_UnChanged
1858 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1861 BOOL noPageDirty
= TRUE
;
1862 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1863 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1866 if ( !psInfo
) return;
1867 for (i
= 0; i
< psInfo
->nPages
; i
++)
1869 /* set the specified page as clean */
1870 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1871 psInfo
->proppage
[i
].isDirty
= FALSE
;
1873 /* look to see if there are any dirty pages */
1874 if (psInfo
->proppage
[i
].isDirty
)
1875 noPageDirty
= FALSE
;
1879 * Disable Apply button.
1882 EnableWindow(hwndApplyBtn
, FALSE
);
1885 /******************************************************************************
1886 * PROPSHEET_PressButton
1888 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1890 TRACE("buttonID %d\n", buttonID
);
1893 case PSBTN_APPLYNOW
:
1894 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1897 PROPSHEET_Back(hwndDlg
);
1900 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1903 PROPSHEET_Finish(hwndDlg
);
1906 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1909 PROPSHEET_Next(hwndDlg
);
1912 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1915 FIXME("Invalid button index %d\n", buttonID
);
1920 /*************************************************************************
1921 * BOOL PROPSHEET_CanSetCurSel [Internal]
1923 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1926 * hwndDlg [I] handle to a Dialog hWnd
1929 * TRUE if Current Selection can change
1933 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
1935 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1946 TRACE("active_page %d\n", psInfo
->active_page
);
1947 if (psInfo
->active_page
< 0)
1954 * Notify the current page.
1956 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1957 psn
.hdr
.code
= PSN_KILLACTIVE
;
1958 psn
.hdr
.hwndFrom
= hwndDlg
;
1962 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1965 TRACE("<-- %d\n", res
);
1969 /******************************************************************************
1970 * PROPSHEET_SetCurSel
1972 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
1975 HPROPSHEETPAGE hpage
1978 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1979 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
1980 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1982 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
1984 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
1986 if (index
< 0 || index
>= psInfo
->nPages
)
1988 TRACE("Could not find page to select!\n");
1992 /* unset active page while doing this transition. */
1993 if (psInfo
->active_page
!= -1)
1994 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1995 psInfo
->active_page
= -1;
2001 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2004 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
2006 psn
.hdr
.code
= PSN_SETACTIVE
;
2007 psn
.hdr
.hwndFrom
= hwndDlg
;
2011 if (!psInfo
->proppage
[index
].hwndPage
) {
2012 if(!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
)) {
2013 PROPSHEET_RemovePage(hwndDlg
, index
, NULL
);
2015 if (!psInfo
->isModeless
)
2017 DestroyWindow(hwndDlg
);
2021 if(index
>= psInfo
->nPages
)
2029 /* Resize the property sheet page to the fit in the Tab control
2030 * (for regular property sheets) or to fit in the client area (for
2032 * NOTE: The resizing happens every time the page is selected and
2033 * not only when it's created (some applications depend on it). */
2034 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2035 TRACE("setting page %p, rc (%s) w=%d, h=%d\n",
2036 psInfo
->proppage
[index
].hwndPage
, wine_dbgstr_rect(&rc
),
2037 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2038 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2040 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2042 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2049 WARN("Tried to skip before first property sheet page!\n");
2052 if (index
>= psInfo
->nPages
) {
2053 WARN("Tried to skip after last property sheet page!\n");
2054 index
= psInfo
->nPages
-1;
2058 else if (result
!= 0)
2060 int old_index
= index
;
2061 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2062 if(index
>= psInfo
->nPages
) {
2064 WARN("Tried to skip to nonexistent page by res id\n");
2071 /* Invalidate the header area */
2072 if ( (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
2073 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
2075 HWND hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
2078 GetClientRect(hwndLineHeader
, &r
);
2079 MapWindowPoints(hwndLineHeader
, hwndDlg
, (LPPOINT
) &r
, 2);
2080 SetRect(&r
, 0, 0, r
.right
+ 1, r
.top
- 1);
2082 InvalidateRect(hwndDlg
, &r
, TRUE
);
2086 * Display the new page.
2088 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2090 if (psInfo
->proppage
[index
].hasHelp
)
2091 EnableWindow(hwndHelp
, TRUE
);
2093 EnableWindow(hwndHelp
, FALSE
);
2098 /******************************************************************************
2099 * PROPSHEET_SetCurSelId
2101 * Selects the page, specified by resource id.
2103 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2106 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2108 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2109 if (idx
< psInfo
->nPages
)
2111 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2112 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2116 /******************************************************************************
2117 * PROPSHEET_SetTitleA
2119 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2121 if(!IS_INTRESOURCE(lpszText
))
2124 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1, szTitle
, ARRAY_SIZE(szTitle
));
2125 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2129 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2133 /******************************************************************************
2134 * PROPSHEET_SetTitleW
2136 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2138 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2141 TRACE("%s (style %08x)\n", debugstr_w(lpszText
), dwStyle
);
2142 if (IS_INTRESOURCE(lpszText
)) {
2143 if (!LoadStringW(psInfo
->ppshheader
.hInstance
, LOWORD(lpszText
), szTitle
, ARRAY_SIZE(szTitle
)))
2147 if (dwStyle
& PSH_PROPTITLE
)
2150 int lentitle
= lstrlenW(lpszText
);
2151 int lenprop
= lstrlenW(psInfo
->strPropertiesFor
);
2153 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2154 wsprintfW(dest
, psInfo
->strPropertiesFor
, lpszText
);
2156 SetWindowTextW(hwndDlg
, dest
);
2160 SetWindowTextW(hwndDlg
, lpszText
);
2163 /******************************************************************************
2164 * PROPSHEET_SetFinishTextA
2166 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2168 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2169 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2171 TRACE("'%s'\n", lpszText
);
2172 /* Set text, show and enable the Finish button */
2173 SetWindowTextA(hwndButton
, lpszText
);
2174 ShowWindow(hwndButton
, SW_SHOW
);
2175 EnableWindow(hwndButton
, TRUE
);
2177 /* Make it default pushbutton */
2178 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2180 /* Hide Back button */
2181 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2182 ShowWindow(hwndButton
, SW_HIDE
);
2184 if (!psInfo
->hasFinish
)
2186 /* Hide Next button */
2187 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2188 ShowWindow(hwndButton
, SW_HIDE
);
2192 /******************************************************************************
2193 * PROPSHEET_SetFinishTextW
2195 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2197 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2198 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2200 TRACE("%s\n", debugstr_w(lpszText
));
2201 /* Set text, show and enable the Finish button */
2202 SetWindowTextW(hwndButton
, lpszText
);
2203 ShowWindow(hwndButton
, SW_SHOW
);
2204 EnableWindow(hwndButton
, TRUE
);
2206 /* Make it default pushbutton */
2207 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2209 /* Hide Back button */
2210 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2211 ShowWindow(hwndButton
, SW_HIDE
);
2213 if (!psInfo
->hasFinish
)
2215 /* Hide Next button */
2216 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2217 ShowWindow(hwndButton
, SW_HIDE
);
2221 /******************************************************************************
2222 * PROPSHEET_QuerySiblings
2224 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2225 WPARAM wParam
, LPARAM lParam
)
2229 LRESULT msgResult
= 0;
2230 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2232 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2234 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2235 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2242 /******************************************************************************
2243 * PROPSHEET_InsertPage
2245 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2247 PropSheetInfo
*psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2248 PropPageInfo
*ppi
, *prev_ppi
= psInfo
->proppage
;
2249 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2250 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2254 TRACE("hwndDlg %p, hpageInsertAfter %p, hpage %p\n", hwndDlg
, hpageInsertAfter
, hpage
);
2256 if (IS_INTRESOURCE(hpageInsertAfter
))
2257 index
= LOWORD(hpageInsertAfter
);
2260 index
= PROPSHEET_GetPageIndex(hpageInsertAfter
, psInfo
, -1);
2263 TRACE("Could not find page to insert after!\n");
2269 if (index
> psInfo
->nPages
)
2270 index
= psInfo
->nPages
;
2272 ppi
= Alloc(sizeof(PropPageInfo
) * (psInfo
->nPages
+ 1));
2277 * Fill in a new PropPageInfo entry.
2280 memcpy(ppi
, prev_ppi
, index
* sizeof(PropPageInfo
));
2281 memset(&ppi
[index
], 0, sizeof(PropPageInfo
));
2282 if (index
< psInfo
->nPages
)
2283 memcpy(&ppi
[index
+ 1], &prev_ppi
[index
], (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2284 psInfo
->proppage
= ppi
;
2286 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, index
, FALSE
))
2288 psInfo
->proppage
= prev_ppi
;
2293 psInfo
->proppage
[index
].hpage
= hpage
;
2295 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2297 /* Create the page but don't show it */
2298 if (!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppsp
))
2300 psInfo
->proppage
= prev_ppi
;
2308 if (index
<= psInfo
->active_page
)
2309 psInfo
->active_page
++;
2312 * Add a new tab to the tab control.
2314 item
.mask
= TCIF_TEXT
;
2315 item
.pszText
= (LPWSTR
) psInfo
->proppage
[index
].pszText
;
2316 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2318 if (psInfo
->hImageList
)
2319 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2321 if (psInfo
->proppage
[index
].hasIcon
)
2323 item
.mask
|= TCIF_IMAGE
;
2324 item
.iImage
= index
;
2327 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, index
, (LPARAM
)&item
);
2329 /* If it is the only page - show it */
2330 if (psInfo
->nPages
== 1)
2331 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2336 /******************************************************************************
2339 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
, HPROPSHEETPAGE hpage
)
2341 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2342 TRACE("hwndDlg %p, hpage %p\n", hwndDlg
, hpage
);
2343 return PROPSHEET_InsertPage(hwndDlg
, UlongToPtr(psInfo
->nPages
), hpage
);
2346 /******************************************************************************
2347 * PROPSHEET_RemovePage
2349 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2351 HPROPSHEETPAGE hpage
)
2353 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2354 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2355 PropPageInfo
* oldPages
;
2357 TRACE("index %d, hpage %p\n", index
, hpage
);
2362 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
2364 /* Make sure that index is within range */
2365 if (index
< 0 || index
>= psInfo
->nPages
)
2367 TRACE("Could not find page to remove!\n");
2371 TRACE("total pages %d removing page %d active page %d\n",
2372 psInfo
->nPages
, index
, psInfo
->active_page
);
2374 * Check if we're removing the active page.
2376 if (index
== psInfo
->active_page
)
2378 if (psInfo
->nPages
> 1)
2382 /* activate previous page */
2383 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2387 /* activate the next page */
2388 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2389 psInfo
->active_page
= index
;
2394 psInfo
->active_page
= -1;
2395 if (!psInfo
->isModeless
)
2397 psInfo
->ended
= TRUE
;
2402 else if (index
< psInfo
->active_page
)
2403 psInfo
->active_page
--;
2405 /* Unsubclass the page dialog window */
2406 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2407 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2408 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2410 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2411 PROPSHEET_WizardSubclassProc
, 1);
2414 /* Destroy page dialog window */
2415 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2417 /* Free page resources */
2418 if(psInfo
->proppage
[index
].hpage
)
2420 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2422 if (psp
->dwFlags
& PSP_USETITLE
)
2423 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2425 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2428 /* Remove the tab */
2429 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2431 oldPages
= psInfo
->proppage
;
2433 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2436 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2438 if (index
< psInfo
->nPages
)
2439 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2440 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2447 /******************************************************************************
2448 * PROPSHEET_SetWizButtons
2450 * This code will work if (and assumes that) the Next button is on top of the
2451 * Finish button. ie. Finish comes after Next in the Z order.
2452 * This means make sure the dialog template reflects this.
2455 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2457 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2458 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2459 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2460 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2461 BOOL enable_finish
= ((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
);
2463 TRACE("%d\n", dwFlags
);
2465 EnableWindow(hwndBack
, dwFlags
& PSWIZB_BACK
);
2466 EnableWindow(hwndNext
, dwFlags
& PSWIZB_NEXT
);
2467 EnableWindow(hwndFinish
, enable_finish
);
2469 /* set the default pushbutton to an enabled button */
2471 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2472 else if (dwFlags
& PSWIZB_NEXT
)
2473 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2474 else if (dwFlags
& PSWIZB_BACK
)
2475 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
2477 SendMessageW(hwndDlg
, DM_SETDEFID
, IDCANCEL
, 0);
2479 if (!psInfo
->hasFinish
)
2481 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2483 /* Hide the Next button */
2484 ShowWindow(hwndNext
, SW_HIDE
);
2486 /* Show the Finish button */
2487 ShowWindow(hwndFinish
, SW_SHOW
);
2491 /* Hide the Finish button */
2492 ShowWindow(hwndFinish
, SW_HIDE
);
2493 /* Show the Next button */
2494 ShowWindow(hwndNext
, SW_SHOW
);
2499 /******************************************************************************
2500 * PROPSHEET_SetHeaderTitleW
2502 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, UINT page_index
, const WCHAR
*title
)
2504 PropSheetInfo
*psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2505 PROPSHEETPAGEW
*page
;
2507 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_w(title
));
2509 if (page_index
>= psInfo
->nPages
)
2512 page
= (PROPSHEETPAGEW
*)psInfo
->proppage
[page_index
].hpage
;
2514 if (!IS_INTRESOURCE(page
->pszHeaderTitle
))
2515 Free((void *)page
->pszHeaderTitle
);
2517 page
->pszHeaderTitle
= heap_strdupW(title
);
2518 page
->dwFlags
|= PSP_USEHEADERTITLE
;
2521 /******************************************************************************
2522 * PROPSHEET_SetHeaderTitleA
2524 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, UINT page_index
, const char *title
)
2528 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_a(title
));
2530 titleW
= heap_strdupAtoW(title
);
2531 PROPSHEET_SetHeaderTitleW(hwndDlg
, page_index
, titleW
);
2535 /******************************************************************************
2536 * PROPSHEET_SetHeaderSubTitleW
2538 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, UINT page_index
, const WCHAR
*subtitle
)
2540 PropSheetInfo
*psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2541 PROPSHEETPAGEW
*page
;
2543 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_w(subtitle
));
2545 if (page_index
>= psInfo
->nPages
)
2548 page
= (PROPSHEETPAGEW
*)psInfo
->proppage
[page_index
].hpage
;
2550 if (!IS_INTRESOURCE(page
->pszHeaderSubTitle
))
2551 Free((void *)page
->pszHeaderSubTitle
);
2553 page
->pszHeaderSubTitle
= heap_strdupW(subtitle
);
2554 page
->dwFlags
|= PSP_USEHEADERSUBTITLE
;
2557 /******************************************************************************
2558 * PROPSHEET_SetHeaderSubTitleA
2560 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, UINT page_index
, const char *subtitle
)
2564 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_a(subtitle
));
2566 subtitleW
= heap_strdupAtoW(subtitle
);
2567 PROPSHEET_SetHeaderSubTitleW(hwndDlg
, page_index
, subtitleW
);
2571 /******************************************************************************
2572 * PROPSHEET_HwndToIndex
2574 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2577 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2579 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2581 for (index
= 0; index
< psInfo
->nPages
; index
++)
2582 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2584 WARN("%p not found\n", hPageDlg
);
2588 /******************************************************************************
2589 * PROPSHEET_IndexToHwnd
2591 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2593 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2594 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2597 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2598 WARN("%d out of range.\n", iPageIndex
);
2601 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2604 /******************************************************************************
2605 * PROPSHEET_PageToIndex
2607 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2609 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2611 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2613 return PROPSHEET_GetPageIndex(hPage
, psInfo
, -1);
2616 /******************************************************************************
2617 * PROPSHEET_IndexToPage
2619 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2621 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2622 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2623 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2624 WARN("%d out of range.\n", iPageIndex
);
2627 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2630 /******************************************************************************
2631 * PROPSHEET_IdToIndex
2633 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2636 LPCPROPSHEETPAGEW psp
;
2637 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2638 TRACE("(%p, %d)\n", hwndDlg
, iPageId
);
2639 for (index
= 0; index
< psInfo
->nPages
; index
++) {
2640 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2641 if (psp
->u
.pszTemplate
== MAKEINTRESOURCEW(iPageId
))
2648 /******************************************************************************
2649 * PROPSHEET_IndexToId
2651 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2653 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2654 LPCPROPSHEETPAGEW psp
;
2655 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2656 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2657 WARN("%d out of range.\n", iPageIndex
);
2660 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2661 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| !IS_INTRESOURCE(psp
->u
.pszTemplate
)) {
2664 return (LRESULT
)psp
->u
.pszTemplate
;
2667 /******************************************************************************
2668 * PROPSHEET_GetResult
2670 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2672 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2673 return psInfo
->result
;
2676 /******************************************************************************
2677 * PROPSHEET_RecalcPageSizes
2679 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2681 FIXME("(%p): stub\n", hwndDlg
);
2685 /******************************************************************************
2686 * PROPSHEET_GetPageIndex
2688 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2689 * the array of PropPageInfo. If page is not found original index is used
2690 * (page takes precedence over index).
2692 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE page
, const PropSheetInfo
* psInfo
, int original_index
)
2696 TRACE("page %p index %d\n", page
, original_index
);
2698 for (index
= 0; index
< psInfo
->nPages
; index
++)
2699 if (psInfo
->proppage
[index
].hpage
== page
)
2702 return original_index
;
2705 /******************************************************************************
2708 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2711 PropSheetInfo
* psInfo
= RemovePropW(hwndDlg
, PropSheetInfoStr
);
2714 if (!psInfo
) return;
2715 if (!IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
))
2716 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2718 for (i
= 0; i
< psInfo
->nPages
; i
++)
2720 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2722 /* Unsubclass the page dialog window */
2723 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2724 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2725 (psp
->dwFlags
& PSP_HIDEHEADER
))
2727 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2728 PROPSHEET_WizardSubclassProc
, 1);
2731 if(psInfo
->proppage
[i
].hwndPage
)
2732 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2736 if (psp
->dwFlags
& PSP_USETITLE
)
2737 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2739 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2743 DeleteObject(psInfo
->hFont
);
2744 DeleteObject(psInfo
->hFontBold
);
2745 /* If we created the bitmaps, destroy them */
2746 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2747 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2748 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2749 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2750 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2751 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2753 Free(psInfo
->proppage
);
2754 Free(psInfo
->strPropertiesFor
);
2755 ImageList_Destroy(psInfo
->hImageList
);
2760 static INT
do_loop(const PropSheetInfo
*psInfo
)
2764 HWND hwnd
= psInfo
->hwnd
;
2765 HWND parent
= psInfo
->ppshheader
.hwndParent
;
2767 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2772 if(!IsDialogMessageW(hwnd
, &msg
))
2774 TranslateMessage(&msg
);
2775 DispatchMessageW(&msg
);
2779 if(ret
== 0 && msg
.message
)
2780 PostQuitMessage(msg
.wParam
);
2783 ret
= psInfo
->result
;
2786 EnableWindow(parent
, TRUE
);
2788 DestroyWindow(hwnd
);
2792 /******************************************************************************
2793 * PROPSHEET_PropertySheet
2795 * Common code between PropertySheetA/W
2797 static INT_PTR
PROPSHEET_PropertySheet(PropSheetInfo
* psInfo
, BOOL unicode
)
2801 if (psInfo
->active_page
>= psInfo
->nPages
) psInfo
->active_page
= 0;
2802 TRACE("startpage: %d of %d pages\n", psInfo
->active_page
, psInfo
->nPages
);
2804 psInfo
->unicode
= unicode
;
2805 psInfo
->ended
= FALSE
;
2807 if(!psInfo
->isModeless
)
2809 parent
= psInfo
->ppshheader
.hwndParent
;
2810 if (parent
) EnableWindow(parent
, FALSE
);
2812 bRet
= PROPSHEET_CreateDialog(psInfo
);
2813 if(!psInfo
->isModeless
)
2814 bRet
= do_loop(psInfo
);
2818 /******************************************************************************
2819 * PropertySheet (COMCTL32.@)
2820 * PropertySheetA (COMCTL32.@)
2822 * Creates a property sheet in the specified property sheet header.
2825 * Modal property sheets: Positive if successful or -1 otherwise.
2826 * Modeless property sheets: Property sheet handle.
2828 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2829 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2831 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2833 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2837 TRACE("(%p)\n", lppsh
);
2839 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2841 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2842 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2844 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2846 if (!psInfo
->usePropPage
)
2847 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2850 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2851 pByte
+= ((LPCPROPSHEETPAGEA
)pByte
)->dwSize
;
2854 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2857 if (psInfo
->usePropPage
)
2858 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2864 return PROPSHEET_PropertySheet(psInfo
, FALSE
);
2867 /******************************************************************************
2868 * PropertySheetW (COMCTL32.@)
2870 * See PropertySheetA.
2872 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2874 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2878 TRACE("(%p)\n", lppsh
);
2880 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2882 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2883 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2885 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2887 if (!psInfo
->usePropPage
)
2888 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2891 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2892 pByte
+= ((LPCPROPSHEETPAGEW
)pByte
)->dwSize
;
2895 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2898 if (psInfo
->usePropPage
)
2899 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2905 return PROPSHEET_PropertySheet(psInfo
, TRUE
);
2908 static LPWSTR
load_string( HINSTANCE instance
, LPCWSTR str
)
2912 if (IS_INTRESOURCE(str
))
2917 WORD i
, id
= LOWORD(str
);
2920 if (!(hrsrc
= FindResourceW( instance
, MAKEINTRESOURCEW((id
>> 4) + 1), (LPWSTR
)RT_STRING
)))
2922 if (!(hmem
= LoadResource( instance
, hrsrc
))) return NULL
;
2923 if (!(ptr
= LockResource( hmem
))) return NULL
;
2924 for (i
= id
& 0x0f; i
> 0; i
--) ptr
+= *ptr
+ 1;
2926 if (!len
) return NULL
;
2927 ret
= Alloc( (len
+ 1) * sizeof(WCHAR
) );
2930 memcpy( ret
, ptr
+ 1, len
* sizeof(WCHAR
) );
2936 int len
= (lstrlenW(str
) + 1) * sizeof(WCHAR
);
2938 if (ret
) memcpy( ret
, str
, len
);
2944 /******************************************************************************
2945 * CreatePropertySheetPage (COMCTL32.@)
2946 * CreatePropertySheetPageA (COMCTL32.@)
2948 * Creates a new property sheet page.
2951 * Success: Handle to new property sheet page.
2955 * An application must use the PSM_ADDPAGE message to add the new page to
2956 * an existing property sheet.
2958 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2959 LPCPROPSHEETPAGEA lpPropSheetPage
)
2961 PROPSHEETPAGEW
*ppsp
;
2963 if (lpPropSheetPage
->dwSize
< PROPSHEETPAGEA_V1_SIZE
)
2966 /* original data is used for callback notifications */
2967 if ((lpPropSheetPage
->dwFlags
& PSP_USECALLBACK
) && lpPropSheetPage
->pfnCallback
)
2969 ppsp
= Alloc(2 * sizeof(*ppsp
));
2970 memcpy(ppsp
, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEA
)));
2971 memcpy(ppsp
+ 1, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEA
)));
2975 ppsp
= Alloc(sizeof(*ppsp
));
2976 memcpy(ppsp
, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEA
)));
2979 ppsp
->dwFlags
&= ~PSP_INTERNAL_UNICODE
;
2981 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2983 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
2985 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
) + 1;
2986 char *template = Alloc( len
);
2988 ppsp
->u
.pszTemplate
= (LPWSTR
)strcpy( template, lpPropSheetPage
->u
.pszTemplate
);
2992 if (ppsp
->dwFlags
& PSP_USEICONID
)
2994 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
2995 ppsp
->u2
.pszIcon
= heap_strdupAtoW( lpPropSheetPage
->u2
.pszIcon
);
2998 if (ppsp
->dwFlags
& PSP_USETITLE
)
3000 if (IS_INTRESOURCE( ppsp
->pszTitle
))
3001 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3003 ppsp
->pszTitle
= heap_strdupAtoW( lpPropSheetPage
->pszTitle
);
3006 ppsp
->pszTitle
= NULL
;
3008 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3009 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3011 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3013 if (IS_INTRESOURCE( ppsp
->pszHeaderTitle
))
3014 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3016 ppsp
->pszHeaderTitle
= heap_strdupAtoW( lpPropSheetPage
->pszHeaderTitle
);
3019 ppsp
->pszHeaderTitle
= NULL
;
3021 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3023 if (IS_INTRESOURCE( ppsp
->pszHeaderSubTitle
))
3024 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3026 ppsp
->pszHeaderSubTitle
= heap_strdupAtoW( lpPropSheetPage
->pszHeaderSubTitle
);
3029 ppsp
->pszHeaderSubTitle
= NULL
;
3031 if ((ppsp
->dwFlags
& PSP_USECALLBACK
) && ppsp
->dwSize
> PROPSHEETPAGEA_V1_SIZE
&& ppsp
->pfnCallback
)
3032 ppsp
->pfnCallback(0, PSPCB_ADDREF
, ppsp
+ 1);
3034 return (HPROPSHEETPAGE
)ppsp
;
3037 /******************************************************************************
3038 * CreatePropertySheetPageW (COMCTL32.@)
3040 * See CreatePropertySheetA.
3042 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
3044 PROPSHEETPAGEW
*ppsp
;
3046 if (lpPropSheetPage
->dwSize
< PROPSHEETPAGEW_V1_SIZE
)
3049 /* original data is used for callback notifications */
3050 if ((lpPropSheetPage
->dwFlags
& PSP_USECALLBACK
) && lpPropSheetPage
->pfnCallback
)
3052 ppsp
= Alloc(2 * sizeof(*ppsp
));
3053 memcpy(ppsp
, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEW
)));
3054 memcpy(ppsp
+ 1, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEW
)));
3058 ppsp
= Alloc(sizeof(*ppsp
));
3059 memcpy(ppsp
, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEW
)));
3062 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
3064 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
3066 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
3067 ppsp
->u
.pszTemplate
= heap_strdupW( lpPropSheetPage
->u
.pszTemplate
);
3070 if ( ppsp
->dwFlags
& PSP_USEICONID
)
3072 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
3073 ppsp
->u2
.pszIcon
= heap_strdupW( lpPropSheetPage
->u2
.pszIcon
);
3076 if (ppsp
->dwFlags
& PSP_USETITLE
)
3077 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3079 ppsp
->pszTitle
= NULL
;
3081 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3082 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3084 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3085 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3087 ppsp
->pszHeaderTitle
= NULL
;
3089 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3090 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3092 ppsp
->pszHeaderSubTitle
= NULL
;
3094 if ((ppsp
->dwFlags
& PSP_USECALLBACK
) && ppsp
->dwSize
> PROPSHEETPAGEW_V1_SIZE
&& ppsp
->pfnCallback
)
3095 ppsp
->pfnCallback(0, PSPCB_ADDREF
, ppsp
+ 1);
3097 return (HPROPSHEETPAGE
)ppsp
;
3100 /******************************************************************************
3101 * DestroyPropertySheetPage (COMCTL32.@)
3103 * Destroys a property sheet page previously created with
3104 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
3111 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
3113 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3118 if ((psp
->dwFlags
& PSP_USECALLBACK
) && psp
->pfnCallback
)
3119 psp
->pfnCallback(0, PSPCB_RELEASE
, psp
+ 1);
3121 if (!(psp
->dwFlags
& PSP_DLGINDIRECT
) && !IS_INTRESOURCE( psp
->u
.pszTemplate
))
3122 Free ((LPVOID
)psp
->u
.pszTemplate
);
3124 if ((psp
->dwFlags
& PSP_USEICONID
) && !IS_INTRESOURCE( psp
->u2
.pszIcon
))
3125 Free ((LPVOID
)psp
->u2
.pszIcon
);
3127 if ((psp
->dwFlags
& PSP_USETITLE
) && !IS_INTRESOURCE( psp
->pszTitle
))
3128 Free ((LPVOID
)psp
->pszTitle
);
3130 if ((psp
->dwFlags
& PSP_USEHEADERTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderTitle
))
3131 Free ((LPVOID
)psp
->pszHeaderTitle
);
3133 if ((psp
->dwFlags
& PSP_USEHEADERSUBTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderSubTitle
))
3134 Free ((LPVOID
)psp
->pszHeaderSubTitle
);
3141 /******************************************************************************
3142 * PROPSHEET_IsDialogMessage
3144 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3146 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3149 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3152 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3155 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3157 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3159 switch (lpMsg
->wParam
)
3162 if (GetKeyState(VK_SHIFT
) & 0x8000)
3168 case VK_NEXT
: new_page
= 1; break;
3169 case VK_PRIOR
: new_page
= -1; break;
3175 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3177 new_page
+= psInfo
->active_page
;
3180 new_page
= psInfo
->nPages
- 1;
3181 else if (new_page
>= psInfo
->nPages
)
3184 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3191 return IsDialogMessageW(hwnd
, lpMsg
);
3194 /******************************************************************************
3195 * PROPSHEET_DoCommand
3197 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3203 case IDC_APPLY_BUTTON
:
3205 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3207 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3212 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3214 /* don't overwrite ID_PSRESTARTWINDOWS or ID_PSREBOOTSYSTEM */
3215 if (psInfo
->result
== 0)
3216 psInfo
->result
= IDOK
;
3218 if (psInfo
->isModeless
)
3219 psInfo
->activeValid
= FALSE
;
3221 psInfo
->ended
= TRUE
;
3224 EnableWindow(hwndApplyBtn
, FALSE
);
3229 case IDC_BACK_BUTTON
:
3230 PROPSHEET_Back(hwnd
);
3233 case IDC_NEXT_BUTTON
:
3234 PROPSHEET_Next(hwnd
);
3237 case IDC_FINISH_BUTTON
:
3238 PROPSHEET_Finish(hwnd
);
3242 PROPSHEET_Cancel(hwnd
, 0);
3246 PROPSHEET_Help(hwnd
);
3256 /******************************************************************************
3259 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3261 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3266 HPALETTE hOldPal
= 0;
3270 LPCPROPSHEETPAGEW ppshpage
;
3271 WCHAR szBuffer
[256];
3274 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3277 hdcSrc
= CreateCompatibleDC(0);
3279 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3280 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3282 if (psInfo
->active_page
< 0)
3285 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3287 if ( (ppshpage
&& !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3288 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3289 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3291 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3293 COLORREF clrOld
= 0;
3296 GetClientRect(hwndLineHeader
, &r
);
3297 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3298 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3300 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3302 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)
3304 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3306 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), &bm
);
3307 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3309 /* Fill the unoccupied part of the header with color of the
3310 * left-top pixel, but do it only when needed.
3312 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3314 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3316 if (bm
.bmWidth
< r
.right
)
3318 r
.left
= bm
.bmWidth
;
3319 FillRect(hdc
, &r
, hbr
);
3321 if (bm
.bmHeight
< r
.bottom
)
3324 r
.top
= bm
.bmHeight
;
3325 FillRect(hdc
, &r
, hbr
);
3330 /* Draw the header itself. */
3331 BitBlt(hdc
, 0, 0, bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3332 hdcSrc
, 0, 0, SRCCOPY
);
3337 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3338 FillRect(hdc
, &rzone
, hbr
);
3340 /* Draw the header bitmap. It's always centered like a
3341 * common 49 x 49 bitmap. */
3342 margin
= (rzone
.bottom
- 49) / 2;
3343 BitBlt(hdc
, rzone
.right
- 49 - margin
, margin
,
3344 min(bm
.bmWidth
, 49), min(bm
.bmHeight
, 49),
3345 hdcSrc
, 0, 0, SRCCOPY
);
3347 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3348 * if its height is smaller than 49 pixels. Because the reason
3349 * for this bug is unknown the current code doesn't try to
3353 SelectObject(hdcSrc
, hbmp
);
3356 clrOld
= SetTextColor (hdc
, 0x00000000);
3357 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3359 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3360 SetRect(&r
, 20, 10, 0, 0);
3361 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3362 DrawTextW(hdc
, ppshpage
->pszHeaderTitle
, -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3365 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderTitle
,
3369 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3374 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3375 SelectObject(hdc
, psInfo
->hFont
);
3376 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3377 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3378 DrawTextW(hdc
, ppshpage
->pszHeaderSubTitle
, -1, &r
, DT_LEFT
| DT_WORDBREAK
);
3381 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderSubTitle
,
3385 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_WORDBREAK
);
3390 offsety
= rzone
.bottom
+ 2;
3392 SetTextColor(hdc
, clrOld
);
3393 SetBkMode(hdc
, oldBkMode
);
3394 SelectObject(hdc
, hOldFont
);
3397 if ( (ppshpage
&& (ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3398 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3399 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3401 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3403 GetClientRect(hwndLine
, &r
);
3404 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3405 SetRect(&rzone
, 0, 0, r
.right
, r
.top
- 1);
3407 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3408 FillRect(hdc
, &rzone
, hbr
);
3410 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), &bm
);
3411 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3413 /* The watermark is truncated to a width of 164 pixels */
3414 r
.right
= min(r
.right
, 164);
3415 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3416 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3418 /* If the bitmap is not big enough, fill the remaining area
3419 with the color of pixel (0,0) of bitmap - see MSDN */
3420 if (r
.top
> bm
.bmHeight
) {
3421 r
.bottom
= r
.top
- 1;
3422 r
.top
= bm
.bmHeight
;
3424 r
.right
= bm
.bmWidth
;
3425 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3426 FillRect(hdc
, &r
, hbr
);
3430 SelectObject(hdcSrc
, hbmp
);
3433 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3434 SelectPalette(hdc
, hOldPal
, FALSE
);
3438 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3443 /******************************************************************************
3444 * PROPSHEET_DialogProc
3446 static INT_PTR CALLBACK
3447 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3449 TRACE("hwnd=%p msg=0x%04x wparam=%lx lparam=%lx\n",
3450 hwnd
, uMsg
, wParam
, lParam
);
3456 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3457 WCHAR
* strCaption
= Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3458 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3462 /* Using PropSheetInfoStr to store extra data doesn't match the native
3463 * common control: native uses TCM_[GS]ETITEM
3465 SetPropW(hwnd
, PropSheetInfoStr
, psInfo
);
3468 * psInfo->hwnd is not being used by WINE code - it exists
3469 * for compatibility with "real" Windoze. The same about
3470 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3473 psInfo
->hwnd
= hwnd
;
3474 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3476 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3478 /* set up the Next and Back buttons by default */
3479 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3483 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3484 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3485 logFont
.lfWeight
= FW_BOLD
;
3486 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3489 * Small icon in the title bar.
3491 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3492 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3495 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3496 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3498 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3499 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3500 psInfo
->ppshheader
.u
.pszIcon
,
3505 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3507 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3510 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3511 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3513 psInfo
->strPropertiesFor
= strCaption
;
3515 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3517 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3519 PROPSHEET_LoadWizardBitmaps(psInfo
);
3521 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3523 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3524 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3525 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3526 SetFocus(GetDlgItem(hwnd
, IDC_NEXT_BUTTON
));
3530 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3532 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3533 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3535 SetFocus(GetDlgItem(hwnd
, IDOK
));
3538 if (IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
) &&
3539 psInfo
->ppshheader
.hInstance
)
3543 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3544 (UINT_PTR
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3545 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3549 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3550 psInfo
->ppshheader
.pszCaption
);
3554 if (psInfo
->useCallback
)
3555 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
, PSCB_INITIALIZED
, 0);
3557 idx
= psInfo
->active_page
;
3558 psInfo
->active_page
= -1;
3560 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3562 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3563 * as some programs call TCM_GETCURSEL to get the current selection
3564 * from which to switch to the next page */
3565 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3567 PROPSHEET_UnChanged(hwnd
, NULL
);
3569 /* wizards set their focus during init */
3570 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3576 case WM_PRINTCLIENT
:
3578 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3582 PROPSHEET_CleanUp(hwnd
);
3586 PROPSHEET_Cancel(hwnd
, 1);
3587 return FALSE
; /* let DefDlgProc post us WM_COMMAND/IDCANCEL */
3590 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3592 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3597 /* No default handler, forward notification to active page */
3598 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3600 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3601 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3608 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3610 if (pnmh
->code
== TCN_SELCHANGE
)
3612 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3613 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3616 if(pnmh
->code
== TCN_SELCHANGING
)
3618 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3619 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3626 case WM_SYSCOLORCHANGE
:
3627 COMCTL32_RefreshSysColors();
3630 case PSM_GETCURRENTPAGEHWND
:
3632 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3638 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3639 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3641 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3647 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3651 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3654 case PSM_GETTABCONTROL
:
3656 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3658 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3667 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3668 if(msgResult
!= FALSE
)
3670 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3673 (HPROPSHEETPAGE
)lParam
);
3676 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3681 case PSM_CANCELTOCLOSE
:
3683 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3684 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3685 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3687 EnableWindow(hwndCancel
, FALSE
);
3688 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, ARRAY_SIZE(buf
)))
3689 SetWindowTextW(hwndOK
, buf
);
3694 case PSM_RESTARTWINDOWS
:
3696 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3701 /* reboot system takes precedence over restart windows */
3702 if (psInfo
->result
!= ID_PSREBOOTSYSTEM
)
3703 psInfo
->result
= ID_PSRESTARTWINDOWS
;
3708 case PSM_REBOOTSYSTEM
:
3710 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3715 psInfo
->result
= ID_PSREBOOTSYSTEM
;
3721 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3725 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3730 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3732 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3737 case PSM_QUERYSIBLINGS
:
3739 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3741 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3749 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3750 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3751 * on success or FALSE otherwise, as specified on MSDN Online.
3752 * Also see the MFC code for
3753 * CPropertySheet::AddPage(CPropertyPage* pPage).
3756 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3758 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3763 case PSM_REMOVEPAGE
:
3764 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3767 case PSM_ISDIALOGMESSAGE
:
3769 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3770 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3774 case PSM_PRESSBUTTON
:
3775 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3778 case PSM_SETFINISHTEXTA
:
3779 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3782 case PSM_SETWIZBUTTONS
:
3783 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3786 case PSM_SETCURSELID
:
3787 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3790 case PSM_SETFINISHTEXTW
:
3791 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3794 case PSM_INSERTPAGE
:
3796 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3797 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3801 case PSM_SETHEADERTITLEW
:
3802 PROPSHEET_SetHeaderTitleW(hwnd
, wParam
, (LPCWSTR
)lParam
);
3805 case PSM_SETHEADERTITLEA
:
3806 PROPSHEET_SetHeaderTitleA(hwnd
, wParam
, (LPCSTR
)lParam
);
3809 case PSM_SETHEADERSUBTITLEW
:
3810 PROPSHEET_SetHeaderSubTitleW(hwnd
, wParam
, (LPCWSTR
)lParam
);
3813 case PSM_SETHEADERSUBTITLEA
:
3814 PROPSHEET_SetHeaderSubTitleA(hwnd
, wParam
, (LPCSTR
)lParam
);
3817 case PSM_HWNDTOINDEX
:
3819 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3820 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3824 case PSM_INDEXTOHWND
:
3826 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3827 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3831 case PSM_PAGETOINDEX
:
3833 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3834 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3838 case PSM_INDEXTOPAGE
:
3840 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3841 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3847 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3848 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3854 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3855 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3861 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3862 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3866 case PSM_RECALCPAGESIZES
:
3868 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3869 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);