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
54 /******************************************************************************
78 } MyDLGITEMTEMPLATEEX
;
81 typedef struct tagPropPageInfo
83 HPROPSHEETPAGE hpage
; /* to keep track of pages not passed to PropertySheet */
92 typedef struct tagPropSheetInfo
95 PROPSHEETHEADERW ppshheader
;
97 LPWSTR strPropertiesFor
;
107 PropPageInfo
* proppage
;
112 HIMAGELIST hImageList
;
123 /******************************************************************************
124 * Defines and global variables
127 static const WCHAR PropSheetInfoStr
[] =
128 {'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0 };
130 #define PSP_INTERNAL_UNICODE 0x80000000
132 #define MAX_CAPTION_LENGTH 255
133 #define MAX_TABTEXT_LENGTH 255
134 #define MAX_BUTTONTEXT_LENGTH 64
136 #define INTRNL_ANY_WIZARD (PSH_WIZARD | PSH_WIZARD97_OLD | PSH_WIZARD97_NEW | PSH_WIZARD_LITE)
138 /* Wizard metrics specified in DLUs */
139 #define WIZARD_PADDING 7
140 #define WIZARD_HEADER_HEIGHT 36
142 /******************************************************************************
145 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
);
146 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
);
147 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
);
148 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
151 HPROPSHEETPAGE hpage
);
152 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, const PropSheetInfo
* psInfo
, int original_index
);
153 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
);
154 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
);
155 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
, int index
, HPROPSHEETPAGE hpage
);
157 static INT_PTR CALLBACK
158 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
160 WINE_DEFAULT_DEBUG_CHANNEL(propsheet
);
162 static WCHAR
*heap_strdupW(const WCHAR
*str
)
164 int len
= strlenW(str
) + 1;
165 WCHAR
*ret
= Alloc(len
* sizeof(WCHAR
));
170 static WCHAR
*heap_strdupAtoW(const char *str
)
175 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, 0, 0);
176 ret
= Alloc(len
* sizeof(WCHAR
));
177 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
182 #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");}
183 /******************************************************************************
184 * PROPSHEET_UnImplementedFlags
186 * Document use of flags we don't implement yet.
188 static VOID
PROPSHEET_UnImplementedFlags(DWORD dwFlags
)
195 * unhandled header flags:
196 * PSH_RTLREADING 0x00000800
197 * PSH_STRETCHWATERMARK 0x00040000
198 * PSH_USEPAGELANG 0x00200000
201 add_flag(PSH_RTLREADING
);
202 add_flag(PSH_STRETCHWATERMARK
);
203 add_flag(PSH_USEPAGELANG
);
204 if (string
[0] != '\0')
205 FIXME("%s\n", string
);
209 /******************************************************************************
210 * PROPSHEET_GetPageRect
212 * Retrieve rect from tab control and map into the dialog for SetWindowPos
214 static void PROPSHEET_GetPageRect(const PropSheetInfo
* psInfo
, HWND hwndDlg
,
215 RECT
*rc
, LPCPROPSHEETPAGEW ppshpage
)
217 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) {
221 if (((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
222 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
223 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) ||
224 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
))
226 rc
->left
= rc
->top
= WIZARD_PADDING
;
230 rc
->left
= rc
->top
= 0;
232 rc
->right
= psInfo
->width
- rc
->left
;
233 rc
->bottom
= psInfo
->height
- rc
->top
;
234 MapDialogRect(hwndDlg
, rc
);
236 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
237 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
238 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
))
240 hwndChild
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
241 GetClientRect(hwndChild
, &r
);
242 MapWindowPoints(hwndChild
, hwndDlg
, (LPPOINT
) &r
, 2);
243 rc
->top
+= r
.bottom
+ 1;
246 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
247 GetClientRect(hwndTabCtrl
, rc
);
248 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)rc
);
249 MapWindowPoints(hwndTabCtrl
, hwndDlg
, (LPPOINT
)rc
, 2);
253 /******************************************************************************
254 * PROPSHEET_FindPageByResId
256 * Find page index corresponding to page resource id.
258 static INT
PROPSHEET_FindPageByResId(const PropSheetInfo
* psInfo
, LRESULT resId
)
262 for (i
= 0; i
< psInfo
->nPages
; i
++)
264 LPCPROPSHEETPAGEA lppsp
= (LPCPROPSHEETPAGEA
)psInfo
->proppage
[i
].hpage
;
266 /* Fixme: if resource ID is a string shall we use strcmp ??? */
267 if (lppsp
->u
.pszTemplate
== (LPVOID
)resId
)
274 /******************************************************************************
275 * PROPSHEET_CollectSheetInfoCommon
277 * Common code for PROPSHEET_CollectSheetInfoA/W
279 static void PROPSHEET_CollectSheetInfoCommon(PropSheetInfo
* psInfo
, DWORD dwFlags
)
281 PROPSHEET_UnImplementedFlags(dwFlags
);
283 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
284 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
285 psInfo
->hasFinish
= dwFlags
& PSH_WIZARDHASFINISH
;
286 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
287 psInfo
->usePropPage
= dwFlags
& PSH_PROPSHEETPAGE
;
288 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
289 psInfo
->active_page
= 0;
292 psInfo
->hImageList
= 0;
293 psInfo
->activeValid
= FALSE
;
296 /******************************************************************************
297 * PROPSHEET_CollectSheetInfoA
299 * Collect relevant data.
301 static void PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh
,
302 PropSheetInfo
* psInfo
)
304 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERA
));
305 DWORD dwFlags
= lppsh
->dwFlags
;
307 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
)&& (lppsh
->pfnCallback
);
309 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
310 TRACE("\n** PROPSHEETHEADER **\ndwSize\t\t%d\ndwFlags\t\t%08x\nhwndParent\t%p\nhInstance\t%p\npszCaption\t'%s'\nnPages\t\t%d\npfnCallback\t%p\n",
311 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
,
312 debugstr_a(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
314 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
315 psInfo
->ppshheader
.pszCaption
= NULL
;
318 if (!IS_INTRESOURCE(lppsh
->pszCaption
))
320 int len
= MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, NULL
, 0);
321 WCHAR
*caption
= Alloc( len
*sizeof (WCHAR
) );
323 MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, caption
, len
);
324 psInfo
->ppshheader
.pszCaption
= caption
;
327 psInfo
->nPages
= lppsh
->nPages
;
329 if (dwFlags
& PSH_USEPSTARTPAGE
)
331 TRACE("PSH_USEPSTARTPAGE is on\n");
332 psInfo
->active_page
= 0;
335 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
337 PROPSHEET_CollectSheetInfoCommon(psInfo
, dwFlags
);
340 /******************************************************************************
341 * PROPSHEET_CollectSheetInfoW
343 * Collect relevant data.
345 static void PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
346 PropSheetInfo
* psInfo
)
348 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERW
));
349 DWORD dwFlags
= lppsh
->dwFlags
;
351 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
) && (lppsh
->pfnCallback
);
353 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
354 TRACE("\n** PROPSHEETHEADER **\ndwSize\t\t%d\ndwFlags\t\t%08x\nhwndParent\t%p\nhInstance\t%p\npszCaption\t%s\nnPages\t\t%d\npfnCallback\t%p\n",
355 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
, debugstr_w(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
357 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
358 psInfo
->ppshheader
.pszCaption
= NULL
;
361 if (!IS_INTRESOURCE(lppsh
->pszCaption
))
362 psInfo
->ppshheader
.pszCaption
= heap_strdupW( lppsh
->pszCaption
);
364 psInfo
->nPages
= lppsh
->nPages
;
366 if (dwFlags
& PSH_USEPSTARTPAGE
)
368 TRACE("PSH_USEPSTARTPAGE is on\n");
369 psInfo
->active_page
= 0;
372 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
374 PROPSHEET_CollectSheetInfoCommon(psInfo
, dwFlags
);
377 /******************************************************************************
378 * PROPSHEET_CollectPageInfo
380 * Collect property sheet data.
381 * With code taken from DIALOG_ParseTemplate32.
383 static BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
384 PropSheetInfo
* psInfo
,
385 int index
, BOOL resize
)
387 const DLGTEMPLATE
* pTemplate
;
396 psInfo
->proppage
[index
].hpage
= (HPROPSHEETPAGE
)lppsp
;
397 psInfo
->proppage
[index
].hwndPage
= 0;
398 psInfo
->proppage
[index
].isDirty
= FALSE
;
401 * Process property page flags.
403 dwFlags
= lppsp
->dwFlags
;
404 psInfo
->proppage
[index
].useCallback
= (dwFlags
& PSP_USECALLBACK
) && (lppsp
->pfnCallback
);
405 psInfo
->proppage
[index
].hasHelp
= dwFlags
& PSP_HASHELP
;
406 psInfo
->proppage
[index
].hasIcon
= dwFlags
& (PSP_USEHICON
| PSP_USEICONID
);
408 /* as soon as we have a page with the help flag, set the sheet flag on */
409 if (psInfo
->proppage
[index
].hasHelp
)
410 psInfo
->hasHelp
= TRUE
;
413 * Process page template.
415 if (dwFlags
& PSP_DLGINDIRECT
)
416 pTemplate
= lppsp
->u
.pResource
;
417 else if(dwFlags
& PSP_INTERNAL_UNICODE
)
419 HRSRC hResource
= FindResourceW(lppsp
->hInstance
,
420 lppsp
->u
.pszTemplate
,
422 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
424 pTemplate
= LockResource(hTemplate
);
428 HRSRC hResource
= FindResourceA(lppsp
->hInstance
,
429 (LPCSTR
)lppsp
->u
.pszTemplate
,
431 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
433 pTemplate
= LockResource(hTemplate
);
437 * Extract the size of the page and the caption.
442 p
= (const WORD
*)pTemplate
;
444 if (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
446 /* DLGTEMPLATEEX (not defined in any std. header file) */
450 p
+= 2; /* help ID */
451 p
+= 2; /* ext style */
459 p
+= 2; /* ext style */
465 width
= (WORD
)*p
; p
++;
466 height
= (WORD
)*p
; p
++;
468 if (lppsp
->dwFlags
& (PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
))
469 psInfo
->ppshheader
.dwFlags
|= PSH_HEADER
;
471 /* Special calculation for interior wizard pages so the largest page is
472 * calculated correctly. We need to add all the padding and space occupied
473 * by the header so the width and height sums up to the whole wizard client
475 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
476 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
477 !(dwFlags
& PSP_HIDEHEADER
))
479 height
+= 2 * WIZARD_PADDING
+ WIZARD_HEADER_HEIGHT
;
480 width
+= 2 * WIZARD_PADDING
;
482 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
)
484 height
+= 2 * WIZARD_PADDING
;
485 width
+= 2 * WIZARD_PADDING
;
488 /* remember the largest width and height */
491 if (width
> psInfo
->width
)
492 psInfo
->width
= width
;
494 if (height
> psInfo
->height
)
495 psInfo
->height
= height
;
508 p
+= lstrlenW( p
) + 1;
522 p
+= lstrlenW( p
) + 1;
526 /* Extract the caption */
527 psInfo
->proppage
[index
].pszText
= p
;
528 TRACE("Tab %d %s\n",index
,debugstr_w( p
));
530 if (dwFlags
& PSP_USETITLE
)
534 static const WCHAR pszNull
[] = { '(','n','u','l','l',')',0 };
536 if (IS_INTRESOURCE( lppsp
->pszTitle
))
538 if (LoadStringW( lppsp
->hInstance
, (DWORD_PTR
)lppsp
->pszTitle
, szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0]) ))
546 pTitle
= lppsp
->pszTitle
;
548 psInfo
->proppage
[index
].pszText
= heap_strdupW( pTitle
);
552 * Build the image list for icons
554 if ((dwFlags
& PSP_USEHICON
) || (dwFlags
& PSP_USEICONID
))
557 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
558 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
560 if (dwFlags
& PSP_USEICONID
)
561 hIcon
= LoadImageW(lppsp
->hInstance
, lppsp
->u2
.pszIcon
, IMAGE_ICON
,
562 icon_cx
, icon_cy
, LR_DEFAULTCOLOR
);
564 hIcon
= lppsp
->u2
.hIcon
;
568 if (psInfo
->hImageList
== 0 )
569 psInfo
->hImageList
= ImageList_Create(icon_cx
, icon_cy
, ILC_COLOR
, 1, 1);
571 ImageList_AddIcon(psInfo
->hImageList
, hIcon
);
579 /******************************************************************************
580 * PROPSHEET_CreateDialog
582 * Creates the actual property sheet.
584 static INT_PTR
PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
)
591 WORD resID
= IDD_PROPSHEET
;
593 TRACE("(%p)\n", psInfo
);
594 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
597 if( psInfo
->unicode
)
599 if(!(hRes
= FindResourceW(COMCTL32_hModule
,
600 MAKEINTRESOURCEW(resID
),
606 if(!(hRes
= FindResourceA(COMCTL32_hModule
,
607 MAKEINTRESOURCEA(resID
),
612 if(!(template = LoadResource(COMCTL32_hModule
, hRes
)))
616 * Make a copy of the dialog template.
618 resSize
= SizeofResource(COMCTL32_hModule
, hRes
);
620 temp
= Alloc(2 * resSize
);
625 memcpy(temp
, template, resSize
);
627 if (psInfo
->ppshheader
.dwFlags
& PSH_NOCONTEXTHELP
)
629 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
630 ((MyDLGTEMPLATEEX
*)temp
)->style
&= ~DS_CONTEXTHELP
;
632 ((DLGTEMPLATE
*)temp
)->style
&= ~DS_CONTEXTHELP
;
634 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
635 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARDCONTEXTHELP
))
637 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
638 ((MyDLGTEMPLATEEX
*)temp
)->style
|= DS_CONTEXTHELP
;
640 ((DLGTEMPLATE
*)temp
)->style
|= DS_CONTEXTHELP
;
643 if (psInfo
->useCallback
)
644 (*(psInfo
->ppshheader
.pfnCallback
))(0, PSCB_PRECREATE
, (LPARAM
)temp
);
646 /* NOTE: MSDN states "Returns a positive value if successful, or -1
647 * otherwise for modal property sheets.", but this is wrong. The
648 * actual return value is either TRUE (success), FALSE (cancel) or
650 if( psInfo
->unicode
)
652 ret
= (INT_PTR
)CreateDialogIndirectParamW(psInfo
->ppshheader
.hInstance
,
653 temp
, psInfo
->ppshheader
.hwndParent
,
654 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
655 if ( !ret
) ret
= -1;
659 ret
= (INT_PTR
)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
660 temp
, psInfo
->ppshheader
.hwndParent
,
661 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
662 if ( !ret
) ret
= -1;
670 /******************************************************************************
671 * PROPSHEET_SizeMismatch
673 * Verify that the tab control and the "largest" property sheet page dlg. template
676 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
678 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
679 RECT rcOrigTab
, rcPage
;
684 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
685 TRACE("orig tab %s\n", wine_dbgstr_rect(&rcOrigTab
));
690 SetRect(&rcPage
, 0, 0, psInfo
->width
, psInfo
->height
);
691 MapDialogRect(hwndDlg
, &rcPage
);
692 TRACE("biggest page %s\n", wine_dbgstr_rect(&rcPage
));
694 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
696 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
702 /******************************************************************************
703 * PROPSHEET_AdjustSize
705 * Resizes the property sheet and the tab control to fit the largest page.
707 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
709 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
710 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
713 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
717 /* Get the height of buttons */
718 GetClientRect(hwndButton
, &rc
);
719 buttonHeight
= rc
.bottom
;
724 SetRect(&rc
, 0, 0, psInfo
->width
, psInfo
->height
);
725 MapDialogRect(hwndDlg
, &rc
);
727 /* retrieve the dialog units */
728 units
.left
= units
.right
= 4;
729 units
.top
= units
.bottom
= 8;
730 MapDialogRect(hwndDlg
, &units
);
733 * Resize the tab control.
735 GetClientRect(hwndTabCtrl
,&tabRect
);
737 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
739 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
741 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
742 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
745 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
747 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
748 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
751 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
755 TRACE("setting tab %p, rc (0,0)-(%d,%d)\n",
756 hwndTabCtrl
, rc
.right
, rc
.bottom
);
757 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
758 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
760 GetClientRect(hwndTabCtrl
, &rc
);
762 TRACE("tab client rc %s\n", wine_dbgstr_rect(&rc
));
764 rc
.right
+= (padding
.x
* 2);
765 rc
.bottom
+= buttonHeight
+ (3 * padding
.y
);
767 style
= GetWindowLongW(hwndDlg
, GWL_STYLE
);
768 if (!(style
& WS_CHILD
))
769 AdjustWindowRect(&rc
, style
, FALSE
);
775 * Resize the property sheet.
777 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
778 hwndDlg
, rc
.right
, rc
.bottom
);
779 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
780 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
784 /******************************************************************************
785 * PROPSHEET_AdjustSizeWizard
787 * Resizes the property sheet to fit the largest page.
789 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
791 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
792 RECT rc
, lineRect
, dialogRect
;
794 /* Biggest page size */
795 SetRect(&rc
, 0, 0, psInfo
->width
, psInfo
->height
);
796 MapDialogRect(hwndDlg
, &rc
);
798 TRACE("Biggest page %s\n", wine_dbgstr_rect(&rc
));
800 /* Add space for the buttons row */
801 GetWindowRect(hwndLine
, &lineRect
);
802 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
803 GetClientRect(hwndDlg
, &dialogRect
);
804 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
806 /* Convert the client coordinates to window coordinates */
807 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
809 /* Resize the property sheet */
810 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
811 hwndDlg
, rc
.right
, rc
.bottom
);
812 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
813 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
818 /******************************************************************************
819 * PROPSHEET_AdjustButtons
821 * Adjusts the buttons' positions.
823 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, const PropSheetInfo
* psInfo
)
825 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
829 int buttonWidth
, buttonHeight
;
830 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
832 if (psInfo
->hasApply
)
839 * Obtain the size of the buttons.
841 GetClientRect(hwndButton
, &rcSheet
);
842 buttonWidth
= rcSheet
.right
;
843 buttonHeight
= rcSheet
.bottom
;
846 * Get the size of the property sheet.
848 GetClientRect(hwndParent
, &rcSheet
);
851 * All buttons will be at this y coordinate.
853 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
856 * Position OK button and make it default.
858 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
860 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
862 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
863 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
865 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
869 * Position Cancel button.
871 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
873 x
+= padding
.x
+ buttonWidth
;
875 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
876 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
879 * Position Apply button.
881 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
884 x
+= padding
.x
+ buttonWidth
;
886 ShowWindow(hwndButton
, SW_HIDE
);
888 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
889 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
890 EnableWindow(hwndButton
, FALSE
);
893 * Position Help button.
895 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
897 x
+= padding
.x
+ buttonWidth
;
898 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
899 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
902 ShowWindow(hwndButton
, SW_HIDE
);
907 /******************************************************************************
908 * PROPSHEET_AdjustButtonsWizard
910 * Adjusts the buttons' positions.
912 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
913 const PropSheetInfo
* psInfo
)
915 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
916 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
917 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
921 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
922 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
926 if (psInfo
->hasFinish
)
930 * Obtain the size of the buttons.
932 GetClientRect(hwndButton
, &rcSheet
);
933 buttonWidth
= rcSheet
.right
;
934 buttonHeight
= rcSheet
.bottom
;
936 GetClientRect(hwndLine
, &rcSheet
);
937 lineHeight
= rcSheet
.bottom
;
940 * Get the size of the property sheet.
942 GetClientRect(hwndParent
, &rcSheet
);
945 * All buttons will be at this y coordinate.
947 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
950 * Position the Back button.
952 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
954 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1)) - buttonWidth
;
956 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
957 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
960 * Position the Next button.
962 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
966 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
967 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
970 * Position the Finish button.
972 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
974 if (psInfo
->hasFinish
)
975 x
+= padding
.x
+ buttonWidth
;
977 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
978 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
980 if (!psInfo
->hasFinish
)
981 ShowWindow(hwndButton
, SW_HIDE
);
984 * Position the Cancel button.
986 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
988 x
+= padding
.x
+ buttonWidth
;
990 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
991 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
994 * Position Help button.
996 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1000 x
+= padding
.x
+ buttonWidth
;
1002 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1003 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1006 ShowWindow(hwndButton
, SW_HIDE
);
1008 if (psInfo
->ppshheader
.dwFlags
&
1009 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1013 * Position and resize the sunken line.
1016 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1018 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1019 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1020 SWP_NOZORDER
| SWP_NOACTIVATE
);
1023 * Position and resize the header sunken line.
1026 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1027 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1028 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1029 ShowWindow(hwndLineHeader
, SW_HIDE
);
1034 /******************************************************************************
1035 * PROPSHEET_GetPaddingInfo
1037 * Returns the layout information.
1039 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1041 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1043 PADDING_INFO padding
;
1045 GetWindowRect(hwndTab
, &rcTab
);
1046 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rcTab
, 2 );
1048 padding
.x
= rcTab
.left
;
1049 padding
.y
= rcTab
.top
;
1054 /******************************************************************************
1055 * PROPSHEET_GetPaddingInfoWizard
1057 * Returns the layout information.
1058 * Vertical spacing is the distance between the line and the buttons.
1059 * Do NOT use the Help button to gather padding information when it isn't mapped
1060 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1061 * for it in this case !
1062 * FIXME: I'm not sure about any other coordinate problems with these evil
1063 * buttons. Fix it in case additional problems appear or maybe calculate
1064 * a padding in a completely different way, as this is somewhat messy.
1066 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1069 PADDING_INFO padding
;
1073 POINT ptButton
, ptLine
;
1076 if (psInfo
->hasHelp
)
1082 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1084 idButton
= IDC_NEXT_BUTTON
;
1088 /* hopefully this is ok */
1089 idButton
= IDCANCEL
;
1093 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1094 GetWindowRect(hwndControl
, &rc
);
1095 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1096 ptButton
.x
= rc
.left
;
1097 ptButton
.y
= rc
.top
;
1100 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1101 GetWindowRect(hwndControl
, &rc
);
1102 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1104 ptLine
.y
= rc
.bottom
;
1106 padding
.y
= ptButton
.y
- ptLine
.y
;
1109 ERR("padding negative ! Please report this !\n");
1111 /* this is most probably not correct, but the best we have now */
1112 padding
.x
= padding
.y
;
1116 /******************************************************************************
1117 * PROPSHEET_CreateTabControl
1119 * Insert the tabs in the tab control.
1121 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1122 const PropSheetInfo
* psInfo
)
1124 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1130 item
.mask
= TCIF_TEXT
;
1131 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1133 nTabs
= psInfo
->nPages
;
1136 * Set the image list for icons.
1138 if (psInfo
->hImageList
)
1140 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1143 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 0, 0);
1144 for (i
= 0; i
< nTabs
; i
++)
1146 if ( psInfo
->proppage
[i
].hasIcon
)
1148 item
.mask
|= TCIF_IMAGE
;
1149 item
.iImage
= iImage
++;
1153 item
.mask
&= ~TCIF_IMAGE
;
1156 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1157 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, i
, (LPARAM
)&item
);
1159 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 1, 0);
1164 /******************************************************************************
1165 * PROPSHEET_WizardSubclassProc
1167 * Subclassing window procedure for wizard exterior pages to prevent drawing
1168 * background and so drawing above the watermark.
1170 static LRESULT CALLBACK
1171 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1178 case WM_CTLCOLORSTATIC
:
1180 SetBkMode((HDC
)wParam
, TRANSPARENT
);
1181 return (INT_PTR
)GetStockObject(HOLLOW_BRUSH
);
1183 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1184 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1188 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1192 * Get the size of an in-memory Template
1194 *( Based on the code of PROPSHEET_CollectPageInfo)
1195 * See also dialog.c/DIALOG_ParseTemplate32().
1198 static UINT
GetTemplateSize(const DLGTEMPLATE
* pTemplate
)
1201 const WORD
* p
= (const WORD
*)pTemplate
;
1202 BOOL istemplateex
= (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1208 /* DLGTEMPLATEEX (not defined in any std. header file) */
1210 TRACE("is DLGTEMPLATEEX\n");
1212 p
++; /* signature */
1213 p
+= 2; /* help ID */
1214 p
+= 2; /* ext style */
1221 TRACE("is DLGTEMPLATE\n");
1223 p
+= 2; /* ext style */
1226 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1242 TRACE("menu %s\n",debugstr_w( p
));
1243 p
+= lstrlenW( p
) + 1;
1254 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1257 TRACE("class %s\n",debugstr_w( p
));
1258 p
+= lstrlenW( p
) + 1;
1263 TRACE("title %s\n",debugstr_w( p
));
1264 p
+= lstrlenW( p
) + 1;
1266 /* font, if DS_SETFONT set */
1267 if ((DS_SETFONT
& ((istemplateex
)? ((const MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1270 p
+=(istemplateex
)?3:1;
1271 TRACE("font %s\n",debugstr_w( p
));
1272 p
+= lstrlenW( p
) + 1; /* the font name */
1275 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1276 * that are following the DLGTEMPLATE(EX) data */
1277 TRACE("%d items\n",nrofitems
);
1278 while (nrofitems
> 0)
1280 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1283 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1292 TRACE("class ordinal 0x%08x\n",*(const DWORD
*)p
);
1296 TRACE("class %s\n",debugstr_w( p
));
1297 p
+= lstrlenW( p
) + 1;
1301 /* check title text */
1308 TRACE("text ordinal 0x%08x\n",*(const DWORD
*)p
);
1312 TRACE("text %s\n",debugstr_w( p
));
1313 p
+= lstrlenW( p
) + 1;
1316 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1320 ret
= (p
- (const WORD
*)pTemplate
) * sizeof(WORD
);
1321 TRACE("%p %p size 0x%08x\n", p
, pTemplate
, ret
);
1325 /******************************************************************************
1326 * PROPSHEET_CreatePage
1330 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1332 const PropSheetInfo
* psInfo
,
1333 LPCPROPSHEETPAGEW ppshpage
)
1335 const DLGTEMPLATE
* pTemplate
;
1338 DLGTEMPLATE
* pTemplateCopy
= NULL
;
1340 TRACE("index %d\n", index
);
1342 if (ppshpage
== NULL
)
1347 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1349 pTemplate
= ppshpage
->u
.pResource
;
1350 resSize
= GetTemplateSize(pTemplate
);
1352 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1357 hResource
= FindResourceW(ppshpage
->hInstance
,
1358 ppshpage
->u
.pszTemplate
,
1363 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1365 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1369 pTemplate
= LockResource(hTemplate
);
1371 * Make a copy of the dialog template to make it writable
1379 hResource
= FindResourceA(ppshpage
->hInstance
,
1380 (LPCSTR
)ppshpage
->u
.pszTemplate
,
1385 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1387 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1391 pTemplate
= LockResource(hTemplate
);
1393 * Make a copy of the dialog template to make it writable
1396 pTemplateCopy
= Alloc(resSize
);
1400 TRACE("copying pTemplate %p into pTemplateCopy %p (%d)\n", pTemplate
, pTemplateCopy
, resSize
);
1401 memcpy(pTemplateCopy
, pTemplate
, resSize
);
1403 if (((MyDLGTEMPLATEEX
*)pTemplateCopy
)->signature
== 0xFFFF)
1405 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1406 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~DS_MODALFRAME
;
1407 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_CAPTION
;
1408 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_SYSMENU
;
1409 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_POPUP
;
1410 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_DISABLED
;
1411 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_VISIBLE
;
1412 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_THICKFRAME
;
1414 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->exStyle
|= WS_EX_CONTROLPARENT
;
1418 pTemplateCopy
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1419 pTemplateCopy
->style
&= ~DS_MODALFRAME
;
1420 pTemplateCopy
->style
&= ~WS_CAPTION
;
1421 pTemplateCopy
->style
&= ~WS_SYSMENU
;
1422 pTemplateCopy
->style
&= ~WS_POPUP
;
1423 pTemplateCopy
->style
&= ~WS_DISABLED
;
1424 pTemplateCopy
->style
&= ~WS_VISIBLE
;
1425 pTemplateCopy
->style
&= ~WS_THICKFRAME
;
1427 pTemplateCopy
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1430 if (psInfo
->proppage
[index
].useCallback
)
1431 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1432 (LPPROPSHEETPAGEW
)ppshpage
);
1434 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1435 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1438 ppshpage
->pfnDlgProc
,
1441 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1444 ppshpage
->pfnDlgProc
,
1446 /* Free a no more needed copy */
1447 Free(pTemplateCopy
);
1452 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1454 /* Subclass exterior wizard pages */
1455 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1456 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1457 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1459 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1460 (DWORD_PTR
)ppshpage
);
1462 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1463 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1468 /******************************************************************************
1469 * PROPSHEET_LoadWizardBitmaps
1471 * Loads the watermark and header bitmaps for a wizard.
1473 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1475 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1477 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1478 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1479 considers hbmWatermark as valid. */
1480 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1481 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1483 psInfo
->ppshheader
.u4
.hbmWatermark
=
1484 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1487 /* Same behavior as for watermarks */
1488 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1489 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1491 psInfo
->ppshheader
.u5
.hbmHeader
=
1492 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1498 /******************************************************************************
1499 * PROPSHEET_ShowPage
1501 * Displays or creates the specified page.
1503 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1506 HWND hwndLineHeader
;
1508 LPCPROPSHEETPAGEW ppshpage
;
1510 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1511 if (index
== psInfo
->active_page
)
1513 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1514 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1518 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1519 if (psInfo
->proppage
[index
].hwndPage
== 0)
1521 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1524 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1526 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1527 psInfo
->proppage
[index
].pszText
);
1529 control
= GetNextDlgTabItem(psInfo
->proppage
[index
].hwndPage
, NULL
, FALSE
);
1534 if (psInfo
->active_page
!= -1)
1535 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1537 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1539 /* Synchronize current selection with tab control
1540 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1541 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1542 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1544 psInfo
->active_page
= index
;
1545 psInfo
->activeValid
= TRUE
;
1547 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1549 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1550 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1552 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1553 ShowWindow(hwndLineHeader
, SW_HIDE
);
1555 ShowWindow(hwndLineHeader
, SW_SHOW
);
1561 /******************************************************************************
1564 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1568 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1572 TRACE("active_page %d\n", psInfo
->active_page
);
1573 if (psInfo
->active_page
< 0)
1576 psn
.hdr
.code
= PSN_WIZBACK
;
1577 psn
.hdr
.hwndFrom
= hwndDlg
;
1581 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1583 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1586 else if (result
== 0)
1587 idx
= psInfo
->active_page
- 1;
1589 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1591 if (idx
>= 0 && idx
< psInfo
->nPages
)
1593 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1595 SetFocus(GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
));
1596 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
1597 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1603 /******************************************************************************
1606 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1610 LRESULT msgResult
= 0;
1611 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1614 TRACE("active_page %d\n", psInfo
->active_page
);
1615 if (psInfo
->active_page
< 0)
1618 psn
.hdr
.code
= PSN_WIZNEXT
;
1619 psn
.hdr
.hwndFrom
= hwndDlg
;
1623 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1625 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1626 if (msgResult
== -1)
1628 else if (msgResult
== 0)
1629 idx
= psInfo
->active_page
+ 1;
1631 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1633 if (idx
< psInfo
->nPages
)
1635 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1637 SetFocus(GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
));
1638 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
1639 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1646 /******************************************************************************
1649 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1653 LRESULT msgResult
= 0;
1654 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1656 TRACE("active_page %d\n", psInfo
->active_page
);
1657 if (psInfo
->active_page
< 0)
1660 psn
.hdr
.code
= PSN_WIZFINISH
;
1661 psn
.hdr
.hwndFrom
= hwndDlg
;
1665 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1667 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1669 TRACE("msg result %ld\n", msgResult
);
1674 if (psInfo
->result
== 0)
1675 psInfo
->result
= IDOK
;
1676 if (psInfo
->isModeless
)
1677 psInfo
->activeValid
= FALSE
;
1679 psInfo
->ended
= TRUE
;
1684 /******************************************************************************
1687 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1692 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1694 TRACE("active_page %d\n", psInfo
->active_page
);
1695 if (psInfo
->active_page
< 0)
1698 psn
.hdr
.hwndFrom
= hwndDlg
;
1704 * Send PSN_KILLACTIVE to the current page.
1706 psn
.hdr
.code
= PSN_KILLACTIVE
;
1708 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1710 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1714 * Send PSN_APPLY to all pages.
1716 psn
.hdr
.code
= PSN_APPLY
;
1717 psn
.lParam
= lParam
;
1719 for (i
= 0; i
< psInfo
->nPages
; i
++)
1721 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1724 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1726 case PSNRET_INVALID
:
1727 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1729 case PSNRET_INVALID_NOCHANGEPAGE
:
1737 psInfo
->activeValid
= FALSE
;
1739 else if(psInfo
->active_page
>= 0)
1741 psn
.hdr
.code
= PSN_SETACTIVE
;
1743 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1744 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1750 /******************************************************************************
1753 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1755 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1760 TRACE("active_page %d\n", psInfo
->active_page
);
1761 if (psInfo
->active_page
< 0)
1764 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1765 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1766 psn
.hdr
.hwndFrom
= hwndDlg
;
1770 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1773 psn
.hdr
.code
= PSN_RESET
;
1774 psn
.lParam
= lParam
;
1776 for (i
= 0; i
< psInfo
->nPages
; i
++)
1778 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1781 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1784 if (psInfo
->isModeless
)
1786 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1787 psInfo
->activeValid
= FALSE
;
1790 psInfo
->ended
= TRUE
;
1793 /******************************************************************************
1796 static void PROPSHEET_Help(HWND hwndDlg
)
1798 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1802 TRACE("active_page %d\n", psInfo
->active_page
);
1803 if (psInfo
->active_page
< 0)
1806 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1807 psn
.hdr
.code
= PSN_HELP
;
1808 psn
.hdr
.hwndFrom
= hwndDlg
;
1812 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1815 /******************************************************************************
1818 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1821 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1824 if (!psInfo
) return;
1826 * Set the dirty flag of this page.
1828 for (i
= 0; i
< psInfo
->nPages
; i
++)
1830 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1831 psInfo
->proppage
[i
].isDirty
= TRUE
;
1835 * Enable the Apply button.
1837 if (psInfo
->hasApply
)
1839 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1841 EnableWindow(hwndApplyBtn
, TRUE
);
1845 /******************************************************************************
1846 * PROPSHEET_UnChanged
1848 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1851 BOOL noPageDirty
= TRUE
;
1852 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1853 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1856 if ( !psInfo
) return;
1857 for (i
= 0; i
< psInfo
->nPages
; i
++)
1859 /* set the specified page as clean */
1860 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1861 psInfo
->proppage
[i
].isDirty
= FALSE
;
1863 /* look to see if there are any dirty pages */
1864 if (psInfo
->proppage
[i
].isDirty
)
1865 noPageDirty
= FALSE
;
1869 * Disable Apply button.
1872 EnableWindow(hwndApplyBtn
, FALSE
);
1875 /******************************************************************************
1876 * PROPSHEET_PressButton
1878 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1880 TRACE("buttonID %d\n", buttonID
);
1883 case PSBTN_APPLYNOW
:
1884 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1887 PROPSHEET_Back(hwndDlg
);
1890 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1893 PROPSHEET_Finish(hwndDlg
);
1896 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1899 PROPSHEET_Next(hwndDlg
);
1902 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1905 FIXME("Invalid button index %d\n", buttonID
);
1910 /*************************************************************************
1911 * BOOL PROPSHEET_CanSetCurSel [Internal]
1913 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1916 * hwndDlg [I] handle to a Dialog hWnd
1919 * TRUE if Current Selection can change
1923 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
1925 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1936 TRACE("active_page %d\n", psInfo
->active_page
);
1937 if (psInfo
->active_page
< 0)
1944 * Notify the current page.
1946 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1947 psn
.hdr
.code
= PSN_KILLACTIVE
;
1948 psn
.hdr
.hwndFrom
= hwndDlg
;
1952 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1955 TRACE("<-- %d\n", res
);
1959 /******************************************************************************
1960 * PROPSHEET_SetCurSel
1962 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
1965 HPROPSHEETPAGE hpage
1968 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1969 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
1970 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1972 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
1974 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
1976 if (index
< 0 || index
>= psInfo
->nPages
)
1978 TRACE("Could not find page to select!\n");
1982 /* unset active page while doing this transition. */
1983 if (psInfo
->active_page
!= -1)
1984 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1985 psInfo
->active_page
= -1;
1991 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1994 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
1996 psn
.hdr
.code
= PSN_SETACTIVE
;
1997 psn
.hdr
.hwndFrom
= hwndDlg
;
2001 if (!psInfo
->proppage
[index
].hwndPage
) {
2002 if(!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
)) {
2003 PROPSHEET_RemovePage(hwndDlg
, index
, NULL
);
2004 if(index
>= psInfo
->nPages
)
2012 /* Resize the property sheet page to the fit in the Tab control
2013 * (for regular property sheets) or to fit in the client area (for
2015 * NOTE: The resizing happens every time the page is selected and
2016 * not only when it's created (some applications depend on it). */
2017 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2018 TRACE("setting page %p, rc (%s) w=%d, h=%d\n",
2019 psInfo
->proppage
[index
].hwndPage
, wine_dbgstr_rect(&rc
),
2020 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2021 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2023 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2025 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2032 WARN("Tried to skip before first property sheet page!\n");
2035 if (index
>= psInfo
->nPages
) {
2036 WARN("Tried to skip after last property sheet page!\n");
2037 index
= psInfo
->nPages
-1;
2041 else if (result
!= 0)
2043 int old_index
= index
;
2044 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2045 if(index
>= psInfo
->nPages
) {
2047 WARN("Tried to skip to nonexistent page by res id\n");
2054 /* Invalidate the header area */
2055 if ( (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
2056 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
2058 HWND hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
2061 GetClientRect(hwndLineHeader
, &r
);
2062 MapWindowPoints(hwndLineHeader
, hwndDlg
, (LPPOINT
) &r
, 2);
2063 SetRect(&r
, 0, 0, r
.right
+ 1, r
.top
- 1);
2065 InvalidateRect(hwndDlg
, &r
, TRUE
);
2069 * Display the new page.
2071 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2073 if (psInfo
->proppage
[index
].hasHelp
)
2074 EnableWindow(hwndHelp
, TRUE
);
2076 EnableWindow(hwndHelp
, FALSE
);
2081 /******************************************************************************
2082 * PROPSHEET_SetCurSelId
2084 * Selects the page, specified by resource id.
2086 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2089 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2091 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2092 if (idx
< psInfo
->nPages
)
2094 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2095 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2099 /******************************************************************************
2100 * PROPSHEET_SetTitleA
2102 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2104 if(!IS_INTRESOURCE(lpszText
))
2107 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2108 szTitle
, sizeof(szTitle
)/sizeof(WCHAR
));
2109 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2113 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2117 /******************************************************************************
2118 * PROPSHEET_SetTitleW
2120 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2122 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2125 TRACE("%s (style %08x)\n", debugstr_w(lpszText
), dwStyle
);
2126 if (IS_INTRESOURCE(lpszText
)) {
2127 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2128 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0])))
2132 if (dwStyle
& PSH_PROPTITLE
)
2135 int lentitle
= strlenW(lpszText
);
2136 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2138 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2139 wsprintfW(dest
, psInfo
->strPropertiesFor
, lpszText
);
2141 SetWindowTextW(hwndDlg
, dest
);
2145 SetWindowTextW(hwndDlg
, lpszText
);
2148 /******************************************************************************
2149 * PROPSHEET_SetFinishTextA
2151 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2153 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2154 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2156 TRACE("'%s'\n", lpszText
);
2157 /* Set text, show and enable the Finish button */
2158 SetWindowTextA(hwndButton
, lpszText
);
2159 ShowWindow(hwndButton
, SW_SHOW
);
2160 EnableWindow(hwndButton
, TRUE
);
2162 /* Make it default pushbutton */
2163 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2165 /* Hide Back button */
2166 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2167 ShowWindow(hwndButton
, SW_HIDE
);
2169 if (!psInfo
->hasFinish
)
2171 /* Hide Next button */
2172 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2173 ShowWindow(hwndButton
, SW_HIDE
);
2177 /******************************************************************************
2178 * PROPSHEET_SetFinishTextW
2180 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2182 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2183 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2185 TRACE("%s\n", debugstr_w(lpszText
));
2186 /* Set text, show and enable the Finish button */
2187 SetWindowTextW(hwndButton
, lpszText
);
2188 ShowWindow(hwndButton
, SW_SHOW
);
2189 EnableWindow(hwndButton
, TRUE
);
2191 /* Make it default pushbutton */
2192 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2194 /* Hide Back button */
2195 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2196 ShowWindow(hwndButton
, SW_HIDE
);
2198 if (!psInfo
->hasFinish
)
2200 /* Hide Next button */
2201 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2202 ShowWindow(hwndButton
, SW_HIDE
);
2206 /******************************************************************************
2207 * PROPSHEET_QuerySiblings
2209 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2210 WPARAM wParam
, LPARAM lParam
)
2214 LRESULT msgResult
= 0;
2215 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2217 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2219 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2220 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2227 /******************************************************************************
2228 * PROPSHEET_InsertPage
2230 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2232 PropSheetInfo
*psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2233 PropPageInfo
*ppi
, *prev_ppi
= psInfo
->proppage
;
2234 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2235 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2239 TRACE("hwndDlg %p, hpageInsertAfter %p, hpage %p\n", hwndDlg
, hpageInsertAfter
, hpage
);
2241 if (IS_INTRESOURCE(hpageInsertAfter
))
2242 index
= LOWORD(hpageInsertAfter
);
2245 index
= PROPSHEET_GetPageIndex(hpageInsertAfter
, psInfo
, -1);
2248 TRACE("Could not find page to insert after!\n");
2254 if (index
> psInfo
->nPages
)
2255 index
= psInfo
->nPages
;
2257 ppi
= Alloc(sizeof(PropPageInfo
) * (psInfo
->nPages
+ 1));
2262 * Fill in a new PropPageInfo entry.
2265 memcpy(ppi
, prev_ppi
, index
* sizeof(PropPageInfo
));
2266 memset(&ppi
[index
], 0, sizeof(PropPageInfo
));
2267 if (index
< psInfo
->nPages
)
2268 memcpy(&ppi
[index
+ 1], &prev_ppi
[index
], (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2269 psInfo
->proppage
= ppi
;
2271 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, index
, FALSE
))
2273 psInfo
->proppage
= prev_ppi
;
2278 psInfo
->proppage
[index
].hpage
= hpage
;
2280 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2282 /* Create the page but don't show it */
2283 if (!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppsp
))
2285 psInfo
->proppage
= prev_ppi
;
2293 if (index
<= psInfo
->active_page
)
2294 psInfo
->active_page
++;
2297 * Add a new tab to the tab control.
2299 item
.mask
= TCIF_TEXT
;
2300 item
.pszText
= (LPWSTR
) psInfo
->proppage
[index
].pszText
;
2301 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2303 if (psInfo
->hImageList
)
2304 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2306 if (psInfo
->proppage
[index
].hasIcon
)
2308 item
.mask
|= TCIF_IMAGE
;
2309 item
.iImage
= index
;
2312 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, index
, (LPARAM
)&item
);
2314 /* If it is the only page - show it */
2315 if (psInfo
->nPages
== 1)
2316 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2321 /******************************************************************************
2324 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
, HPROPSHEETPAGE hpage
)
2326 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2327 TRACE("hwndDlg %p, hpage %p\n", hwndDlg
, hpage
);
2328 return PROPSHEET_InsertPage(hwndDlg
, UlongToPtr(psInfo
->nPages
), hpage
);
2331 /******************************************************************************
2332 * PROPSHEET_RemovePage
2334 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2336 HPROPSHEETPAGE hpage
)
2338 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2339 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2340 PropPageInfo
* oldPages
;
2342 TRACE("index %d, hpage %p\n", index
, hpage
);
2347 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
2349 /* Make sure that index is within range */
2350 if (index
< 0 || index
>= psInfo
->nPages
)
2352 TRACE("Could not find page to remove!\n");
2356 TRACE("total pages %d removing page %d active page %d\n",
2357 psInfo
->nPages
, index
, psInfo
->active_page
);
2359 * Check if we're removing the active page.
2361 if (index
== psInfo
->active_page
)
2363 if (psInfo
->nPages
> 1)
2367 /* activate previous page */
2368 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2372 /* activate the next page */
2373 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2374 psInfo
->active_page
= index
;
2379 psInfo
->active_page
= -1;
2380 if (!psInfo
->isModeless
)
2382 psInfo
->ended
= TRUE
;
2387 else if (index
< psInfo
->active_page
)
2388 psInfo
->active_page
--;
2390 /* Unsubclass the page dialog window */
2391 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2392 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2393 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2395 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2396 PROPSHEET_WizardSubclassProc
, 1);
2399 /* Destroy page dialog window */
2400 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2402 /* Free page resources */
2403 if(psInfo
->proppage
[index
].hpage
)
2405 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2407 if (psp
->dwFlags
& PSP_USETITLE
)
2408 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2410 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2413 /* Remove the tab */
2414 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2416 oldPages
= psInfo
->proppage
;
2418 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2421 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2423 if (index
< psInfo
->nPages
)
2424 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2425 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2432 /******************************************************************************
2433 * PROPSHEET_SetWizButtons
2435 * This code will work if (and assumes that) the Next button is on top of the
2436 * Finish button. ie. Finish comes after Next in the Z order.
2437 * This means make sure the dialog template reflects this.
2440 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2442 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2443 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2444 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2445 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2446 BOOL enable_finish
= ((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
);
2449 HWND hwndCancel
= GetDlgItem(hwndDlg
, IDCANCEL
);
2454 TRACE("%d\n", dwFlags
);
2456 EnableWindow(hwndBack
, dwFlags
& PSWIZB_BACK
);
2457 EnableWindow(hwndNext
, dwFlags
& PSWIZB_NEXT
);
2458 EnableWindow(hwndFinish
, enable_finish
);
2461 /* set the default pushbutton to an enabled button */
2463 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2464 else if (dwFlags
& PSWIZB_NEXT
)
2465 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2466 else if (dwFlags
& PSWIZB_BACK
)
2467 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
2469 SendMessageW(hwndDlg
, DM_SETDEFID
, IDCANCEL
, 0);
2472 if (!psInfo
->hasFinish
)
2474 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2476 /* Hide the Next button */
2477 ShowWindow(hwndNext
, SW_HIDE
);
2479 /* Show the Finish button */
2480 ShowWindow(hwndFinish
, SW_SHOW
);
2484 /* Hide the Finish button */
2485 ShowWindow(hwndFinish
, SW_HIDE
);
2486 /* Show the Next button */
2487 ShowWindow(hwndNext
, SW_SHOW
);
2492 /* set the default pushbutton to an enabled button */
2493 if (((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
))
2494 iDefItem
= IDC_FINISH_BUTTON
;
2495 else if (dwFlags
& PSWIZB_NEXT
)
2496 iDefItem
= IDC_NEXT_BUTTON
;
2497 else if (dwFlags
& PSWIZB_BACK
)
2498 iDefItem
= IDC_BACK_BUTTON
;
2500 iDefItem
= IDCANCEL
;
2501 SendMessageW(hwndDlg
, DM_SETDEFID
, iDefItem
, 0);
2503 /* Set focus if no control has it */
2504 hwndFocus
= GetFocus();
2505 if (!hwndFocus
|| hwndFocus
== hwndCancel
)
2506 SetFocus(GetDlgItem(hwndDlg
, iDefItem
));
2511 /******************************************************************************
2512 * PROPSHEET_SetHeaderTitleW
2514 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, UINT page_index
, const WCHAR
*title
)
2516 PropSheetInfo
*psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2517 PROPSHEETPAGEW
*page
;
2519 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_w(title
));
2521 if (page_index
>= psInfo
->nPages
)
2524 page
= (PROPSHEETPAGEW
*)psInfo
->proppage
[page_index
].hpage
;
2526 if (!IS_INTRESOURCE(page
->pszHeaderTitle
))
2527 Free((void *)page
->pszHeaderTitle
);
2529 page
->pszHeaderTitle
= heap_strdupW(title
);
2530 page
->dwFlags
|= PSP_USEHEADERTITLE
;
2533 /******************************************************************************
2534 * PROPSHEET_SetHeaderTitleA
2536 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, UINT page_index
, const char *title
)
2540 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_a(title
));
2542 titleW
= heap_strdupAtoW(title
);
2543 PROPSHEET_SetHeaderTitleW(hwndDlg
, page_index
, titleW
);
2547 /******************************************************************************
2548 * PROPSHEET_SetHeaderSubTitleW
2550 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, UINT page_index
, const WCHAR
*subtitle
)
2552 PropSheetInfo
*psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2553 PROPSHEETPAGEW
*page
;
2555 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_w(subtitle
));
2557 if (page_index
>= psInfo
->nPages
)
2560 page
= (PROPSHEETPAGEW
*)psInfo
->proppage
[page_index
].hpage
;
2562 if (!IS_INTRESOURCE(page
->pszHeaderSubTitle
))
2563 Free((void *)page
->pszHeaderSubTitle
);
2565 page
->pszHeaderSubTitle
= heap_strdupW(subtitle
);
2566 page
->dwFlags
|= PSP_USEHEADERSUBTITLE
;
2569 /******************************************************************************
2570 * PROPSHEET_SetHeaderSubTitleA
2572 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, UINT page_index
, const char *subtitle
)
2576 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_a(subtitle
));
2578 subtitleW
= heap_strdupAtoW(subtitle
);
2579 PROPSHEET_SetHeaderSubTitleW(hwndDlg
, page_index
, subtitleW
);
2583 /******************************************************************************
2584 * PROPSHEET_HwndToIndex
2586 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2589 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2591 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2593 for (index
= 0; index
< psInfo
->nPages
; index
++)
2594 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2596 WARN("%p not found\n", hPageDlg
);
2600 /******************************************************************************
2601 * PROPSHEET_IndexToHwnd
2603 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2605 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2606 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2609 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2610 WARN("%d out of range.\n", iPageIndex
);
2613 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2616 /******************************************************************************
2617 * PROPSHEET_PageToIndex
2619 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2621 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2623 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2625 return PROPSHEET_GetPageIndex(hPage
, psInfo
, -1);
2628 /******************************************************************************
2629 * PROPSHEET_IndexToPage
2631 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2633 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2634 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2635 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2636 WARN("%d out of range.\n", iPageIndex
);
2639 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2642 /******************************************************************************
2643 * PROPSHEET_IdToIndex
2645 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2648 LPCPROPSHEETPAGEW psp
;
2649 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2650 TRACE("(%p, %d)\n", hwndDlg
, iPageId
);
2651 for (index
= 0; index
< psInfo
->nPages
; index
++) {
2652 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2653 if (psp
->u
.pszTemplate
== MAKEINTRESOURCEW(iPageId
))
2660 /******************************************************************************
2661 * PROPSHEET_IndexToId
2663 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2665 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2666 LPCPROPSHEETPAGEW psp
;
2667 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2668 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2669 WARN("%d out of range.\n", iPageIndex
);
2672 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2673 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| !IS_INTRESOURCE(psp
->u
.pszTemplate
)) {
2676 return (LRESULT
)psp
->u
.pszTemplate
;
2679 /******************************************************************************
2680 * PROPSHEET_GetResult
2682 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2684 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2685 return psInfo
->result
;
2688 /******************************************************************************
2689 * PROPSHEET_RecalcPageSizes
2691 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2693 FIXME("(%p): stub\n", hwndDlg
);
2697 /******************************************************************************
2698 * PROPSHEET_GetPageIndex
2700 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2701 * the array of PropPageInfo. If page is not found original index is used
2702 * (page takes precedence over index).
2704 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE page
, const PropSheetInfo
* psInfo
, int original_index
)
2708 TRACE("page %p index %d\n", page
, original_index
);
2710 for (index
= 0; index
< psInfo
->nPages
; index
++)
2711 if (psInfo
->proppage
[index
].hpage
== page
)
2714 return original_index
;
2717 /******************************************************************************
2720 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2723 PropSheetInfo
* psInfo
= RemovePropW(hwndDlg
, PropSheetInfoStr
);
2726 if (!psInfo
) return;
2727 if (!IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
))
2728 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2730 for (i
= 0; i
< psInfo
->nPages
; i
++)
2732 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2734 /* Unsubclass the page dialog window */
2735 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2736 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2737 (psp
->dwFlags
& PSP_HIDEHEADER
))
2739 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2740 PROPSHEET_WizardSubclassProc
, 1);
2743 if(psInfo
->proppage
[i
].hwndPage
)
2744 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2748 if (psp
->dwFlags
& PSP_USETITLE
)
2749 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2751 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2755 DeleteObject(psInfo
->hFont
);
2756 DeleteObject(psInfo
->hFontBold
);
2757 /* If we created the bitmaps, destroy them */
2758 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2759 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2760 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2761 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2762 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2763 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2765 Free(psInfo
->proppage
);
2766 Free(psInfo
->strPropertiesFor
);
2767 ImageList_Destroy(psInfo
->hImageList
);
2772 static INT
do_loop(const PropSheetInfo
*psInfo
)
2776 HWND hwnd
= psInfo
->hwnd
;
2777 HWND parent
= psInfo
->ppshheader
.hwndParent
;
2779 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2784 if(!IsDialogMessageW(hwnd
, &msg
))
2786 TranslateMessage(&msg
);
2787 DispatchMessageW(&msg
);
2793 PostQuitMessage(msg
.wParam
);
2798 ret
= psInfo
->result
;
2801 EnableWindow(parent
, TRUE
);
2803 DestroyWindow(hwnd
);
2807 /******************************************************************************
2808 * PROPSHEET_PropertySheet
2810 * Common code between PropertySheetA/W
2812 static INT_PTR
PROPSHEET_PropertySheet(PropSheetInfo
* psInfo
, BOOL unicode
)
2816 if (psInfo
->active_page
>= psInfo
->nPages
) psInfo
->active_page
= 0;
2817 TRACE("startpage: %d of %d pages\n", psInfo
->active_page
, psInfo
->nPages
);
2819 psInfo
->unicode
= unicode
;
2820 psInfo
->ended
= FALSE
;
2822 if(!psInfo
->isModeless
)
2824 parent
= psInfo
->ppshheader
.hwndParent
;
2825 if (parent
) EnableWindow(parent
, FALSE
);
2827 bRet
= PROPSHEET_CreateDialog(psInfo
);
2828 if(!psInfo
->isModeless
)
2829 bRet
= do_loop(psInfo
);
2833 /******************************************************************************
2834 * PropertySheet (COMCTL32.@)
2835 * PropertySheetA (COMCTL32.@)
2837 * Creates a property sheet in the specified property sheet header.
2840 * Modal property sheets: Positive if successful or -1 otherwise.
2841 * Modeless property sheets: Property sheet handle.
2843 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2844 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2846 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2848 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2852 TRACE("(%p)\n", lppsh
);
2854 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2856 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2857 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2859 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2861 if (!psInfo
->usePropPage
)
2862 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2865 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2866 pByte
+= ((LPCPROPSHEETPAGEA
)pByte
)->dwSize
;
2869 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2872 if (psInfo
->usePropPage
)
2873 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2879 return PROPSHEET_PropertySheet(psInfo
, FALSE
);
2882 /******************************************************************************
2883 * PropertySheetW (COMCTL32.@)
2885 * See PropertySheetA.
2887 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2889 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2893 TRACE("(%p)\n", lppsh
);
2895 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2897 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2898 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2900 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2902 if (!psInfo
->usePropPage
)
2903 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2906 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2907 pByte
+= ((LPCPROPSHEETPAGEW
)pByte
)->dwSize
;
2910 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2913 if (psInfo
->usePropPage
)
2914 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2920 return PROPSHEET_PropertySheet(psInfo
, TRUE
);
2923 static LPWSTR
load_string( HINSTANCE instance
, LPCWSTR str
)
2927 if (IS_INTRESOURCE(str
))
2932 WORD i
, id
= LOWORD(str
);
2935 if (!(hrsrc
= FindResourceW( instance
, MAKEINTRESOURCEW((id
>> 4) + 1), (LPWSTR
)RT_STRING
)))
2937 if (!(hmem
= LoadResource( instance
, hrsrc
))) return NULL
;
2938 if (!(ptr
= LockResource( hmem
))) return NULL
;
2939 for (i
= id
& 0x0f; i
> 0; i
--) ptr
+= *ptr
+ 1;
2941 if (!len
) return NULL
;
2942 ret
= Alloc( (len
+ 1) * sizeof(WCHAR
) );
2945 memcpy( ret
, ptr
+ 1, len
* sizeof(WCHAR
) );
2951 int len
= (strlenW(str
) + 1) * sizeof(WCHAR
);
2953 if (ret
) memcpy( ret
, str
, len
);
2959 /******************************************************************************
2960 * CreatePropertySheetPage (COMCTL32.@)
2961 * CreatePropertySheetPageA (COMCTL32.@)
2963 * Creates a new property sheet page.
2966 * Success: Handle to new property sheet page.
2970 * An application must use the PSM_ADDPAGE message to add the new page to
2971 * an existing property sheet.
2973 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2974 LPCPROPSHEETPAGEA lpPropSheetPage
)
2976 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2978 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEA
)));
2980 ppsp
->dwFlags
&= ~ PSP_INTERNAL_UNICODE
;
2982 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2984 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
2986 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
) + 1;
2987 char *template = Alloc( len
);
2989 ppsp
->u
.pszTemplate
= (LPWSTR
)strcpy( template, lpPropSheetPage
->u
.pszTemplate
);
2993 if (ppsp
->dwFlags
& PSP_USEICONID
)
2995 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
2996 ppsp
->u2
.pszIcon
= heap_strdupAtoW( lpPropSheetPage
->u2
.pszIcon
);
2999 if (ppsp
->dwFlags
& PSP_USETITLE
)
3001 if (IS_INTRESOURCE( ppsp
->pszTitle
))
3002 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3004 ppsp
->pszTitle
= heap_strdupAtoW( lpPropSheetPage
->pszTitle
);
3007 ppsp
->pszTitle
= NULL
;
3009 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3010 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3012 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3014 if (IS_INTRESOURCE( ppsp
->pszHeaderTitle
))
3015 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3017 ppsp
->pszHeaderTitle
= heap_strdupAtoW( lpPropSheetPage
->pszHeaderTitle
);
3020 ppsp
->pszHeaderTitle
= NULL
;
3022 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3024 if (IS_INTRESOURCE( ppsp
->pszHeaderSubTitle
))
3025 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3027 ppsp
->pszHeaderSubTitle
= heap_strdupAtoW( lpPropSheetPage
->pszHeaderSubTitle
);
3030 ppsp
->pszHeaderSubTitle
= NULL
;
3032 if ((ppsp
->dwFlags
& PSH_USECALLBACK
) && ppsp
->pfnCallback
)
3033 ppsp
->pfnCallback(0, PSPCB_ADDREF
, ppsp
);
3035 return (HPROPSHEETPAGE
)ppsp
;
3038 /******************************************************************************
3039 * CreatePropertySheetPageW (COMCTL32.@)
3041 * See CreatePropertySheetA.
3043 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
3045 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
3047 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEW
)));
3049 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
3051 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
3053 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
3054 ppsp
->u
.pszTemplate
= heap_strdupW( lpPropSheetPage
->u
.pszTemplate
);
3057 if ( ppsp
->dwFlags
& PSP_USEICONID
)
3059 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
3060 ppsp
->u2
.pszIcon
= heap_strdupW( lpPropSheetPage
->u2
.pszIcon
);
3063 if (ppsp
->dwFlags
& PSP_USETITLE
)
3064 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3066 ppsp
->pszTitle
= NULL
;
3068 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3069 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3071 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3072 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3074 ppsp
->pszHeaderTitle
= NULL
;
3076 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3077 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3079 ppsp
->pszHeaderSubTitle
= NULL
;
3081 if ((ppsp
->dwFlags
& PSH_USECALLBACK
) && ppsp
->pfnCallback
)
3082 ppsp
->pfnCallback(0, PSPCB_ADDREF
, ppsp
);
3084 return (HPROPSHEETPAGE
)ppsp
;
3087 /******************************************************************************
3088 * DestroyPropertySheetPage (COMCTL32.@)
3090 * Destroys a property sheet page previously created with
3091 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
3098 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
3100 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3105 if ((psp
->dwFlags
& PSH_USECALLBACK
) && psp
->pfnCallback
)
3106 psp
->pfnCallback(0, PSPCB_RELEASE
, psp
);
3108 if (!(psp
->dwFlags
& PSP_DLGINDIRECT
) && !IS_INTRESOURCE( psp
->u
.pszTemplate
))
3109 Free ((LPVOID
)psp
->u
.pszTemplate
);
3111 if ((psp
->dwFlags
& PSP_USEICONID
) && !IS_INTRESOURCE( psp
->u2
.pszIcon
))
3112 Free ((LPVOID
)psp
->u2
.pszIcon
);
3114 if ((psp
->dwFlags
& PSP_USETITLE
) && !IS_INTRESOURCE( psp
->pszTitle
))
3115 Free ((LPVOID
)psp
->pszTitle
);
3117 if ((psp
->dwFlags
& PSP_USEHEADERTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderTitle
))
3118 Free ((LPVOID
)psp
->pszHeaderTitle
);
3120 if ((psp
->dwFlags
& PSP_USEHEADERSUBTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderSubTitle
))
3121 Free ((LPVOID
)psp
->pszHeaderSubTitle
);
3128 /******************************************************************************
3129 * PROPSHEET_IsDialogMessage
3131 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3133 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3136 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3139 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3142 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3144 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3146 switch (lpMsg
->wParam
)
3149 if (GetKeyState(VK_SHIFT
) & 0x8000)
3155 case VK_NEXT
: new_page
= 1; break;
3156 case VK_PRIOR
: new_page
= -1; break;
3162 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3164 new_page
+= psInfo
->active_page
;
3167 new_page
= psInfo
->nPages
- 1;
3168 else if (new_page
>= psInfo
->nPages
)
3171 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3178 return IsDialogMessageW(hwnd
, lpMsg
);
3181 /******************************************************************************
3182 * PROPSHEET_DoCommand
3184 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3190 case IDC_APPLY_BUTTON
:
3192 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3194 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3199 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3201 /* don't overwrite ID_PSRESTARTWINDOWS or ID_PSREBOOTSYSTEM */
3202 if (psInfo
->result
== 0)
3203 psInfo
->result
= IDOK
;
3205 if (psInfo
->isModeless
)
3206 psInfo
->activeValid
= FALSE
;
3208 psInfo
->ended
= TRUE
;
3211 EnableWindow(hwndApplyBtn
, FALSE
);
3216 case IDC_BACK_BUTTON
:
3217 PROPSHEET_Back(hwnd
);
3220 case IDC_NEXT_BUTTON
:
3221 PROPSHEET_Next(hwnd
);
3224 case IDC_FINISH_BUTTON
:
3225 PROPSHEET_Finish(hwnd
);
3229 PROPSHEET_Cancel(hwnd
, 0);
3233 PROPSHEET_Help(hwnd
);
3243 /******************************************************************************
3246 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3248 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3253 HPALETTE hOldPal
= 0;
3257 LPCPROPSHEETPAGEW ppshpage
;
3258 WCHAR szBuffer
[256];
3261 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3264 hdcSrc
= CreateCompatibleDC(0);
3266 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3267 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3269 if (psInfo
->active_page
< 0)
3272 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3274 if ( (ppshpage
&& !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3275 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3276 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3278 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3280 COLORREF clrOld
= 0;
3283 GetClientRect(hwndLineHeader
, &r
);
3284 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3285 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3287 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3290 if (psInfo
->ppshheader
.u5
.hbmHeader
)
3292 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)
3295 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3297 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), &bm
);
3298 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3300 /* Fill the unoccupied part of the header with color of the
3301 * left-top pixel, but do it only when needed.
3303 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3305 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3307 if (bm
.bmWidth
< r
.right
)
3309 r
.left
= bm
.bmWidth
;
3310 FillRect(hdc
, &r
, hbr
);
3312 if (bm
.bmHeight
< r
.bottom
)
3315 r
.top
= bm
.bmHeight
;
3316 FillRect(hdc
, &r
, hbr
);
3321 /* Draw the header itself. */
3322 BitBlt(hdc
, 0, 0, bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3323 hdcSrc
, 0, 0, SRCCOPY
);
3328 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3329 FillRect(hdc
, &rzone
, hbr
);
3331 /* Draw the header bitmap. It's always centered like a
3332 * common 49 x 49 bitmap. */
3333 margin
= (rzone
.bottom
- 49) / 2;
3334 BitBlt(hdc
, rzone
.right
- 49 - margin
, margin
,
3335 min(bm
.bmWidth
, 49), min(bm
.bmHeight
, 49),
3336 hdcSrc
, 0, 0, SRCCOPY
);
3338 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3339 * if its height is smaller than 49 pixels. Because the reason
3340 * for this bug is unknown the current code doesn't try to
3344 SelectObject(hdcSrc
, hbmp
);
3347 clrOld
= SetTextColor (hdc
, 0x00000000);
3348 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3350 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3351 SetRect(&r
, 20, 10, 0, 0);
3352 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3353 DrawTextW(hdc
, ppshpage
->pszHeaderTitle
, -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3356 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderTitle
,
3360 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3365 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3366 SelectObject(hdc
, psInfo
->hFont
);
3367 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3369 if (!IS_INTRESOURCE(ppshpage
->pszHeaderSubTitle
))
3371 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3373 DrawTextW(hdc
, ppshpage
->pszHeaderSubTitle
, -1, &r
, DT_LEFT
| DT_WORDBREAK
);
3376 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderSubTitle
,
3380 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_WORDBREAK
);
3385 offsety
= rzone
.bottom
+ 2;
3387 SetTextColor(hdc
, clrOld
);
3388 SetBkMode(hdc
, oldBkMode
);
3389 SelectObject(hdc
, hOldFont
);
3392 if ( (ppshpage
&& (ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3393 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3395 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
3396 (psInfo
->ppshheader
.u4
.hbmWatermark
) )
3398 (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
, sizeof(buf
)/sizeof(buf
[0])))
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
);