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
:
1179 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1180 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1183 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1187 * Get the size of an in-memory Template
1189 *( Based on the code of PROPSHEET_CollectPageInfo)
1190 * See also dialog.c/DIALOG_ParseTemplate32().
1193 static UINT
GetTemplateSize(const DLGTEMPLATE
* pTemplate
)
1196 const WORD
* p
= (const WORD
*)pTemplate
;
1197 BOOL istemplateex
= (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1203 /* DLGTEMPLATEEX (not defined in any std. header file) */
1205 TRACE("is DLGTEMPLATEEX\n");
1207 p
++; /* signature */
1208 p
+= 2; /* help ID */
1209 p
+= 2; /* ext style */
1216 TRACE("is DLGTEMPLATE\n");
1218 p
+= 2; /* ext style */
1221 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1237 TRACE("menu %s\n",debugstr_w( p
));
1238 p
+= lstrlenW( p
) + 1;
1249 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1252 TRACE("class %s\n",debugstr_w( p
));
1253 p
+= lstrlenW( p
) + 1;
1258 TRACE("title %s\n",debugstr_w( p
));
1259 p
+= lstrlenW( p
) + 1;
1261 /* font, if DS_SETFONT set */
1262 if ((DS_SETFONT
& ((istemplateex
)? ((const MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1265 p
+=(istemplateex
)?3:1;
1266 TRACE("font %s\n",debugstr_w( p
));
1267 p
+= lstrlenW( p
) + 1; /* the font name */
1270 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1271 * that are following the DLGTEMPLATE(EX) data */
1272 TRACE("%d items\n",nrofitems
);
1273 while (nrofitems
> 0)
1275 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1278 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1287 TRACE("class ordinal 0x%08x\n",*(const DWORD
*)p
);
1291 TRACE("class %s\n",debugstr_w( p
));
1292 p
+= lstrlenW( p
) + 1;
1296 /* check title text */
1303 TRACE("text ordinal 0x%08x\n",*(const DWORD
*)p
);
1307 TRACE("text %s\n",debugstr_w( p
));
1308 p
+= lstrlenW( p
) + 1;
1311 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1315 ret
= (p
- (const WORD
*)pTemplate
) * sizeof(WORD
);
1316 TRACE("%p %p size 0x%08x\n", p
, pTemplate
, ret
);
1320 /******************************************************************************
1321 * PROPSHEET_CreatePage
1325 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1327 const PropSheetInfo
* psInfo
,
1328 LPCPROPSHEETPAGEW ppshpage
)
1330 const DLGTEMPLATE
* pTemplate
;
1333 DLGTEMPLATE
* pTemplateCopy
= NULL
;
1335 TRACE("index %d\n", index
);
1337 if (ppshpage
== NULL
)
1342 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1344 pTemplate
= ppshpage
->u
.pResource
;
1345 resSize
= GetTemplateSize(pTemplate
);
1347 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1352 hResource
= FindResourceW(ppshpage
->hInstance
,
1353 ppshpage
->u
.pszTemplate
,
1358 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1360 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1364 pTemplate
= LockResource(hTemplate
);
1366 * Make a copy of the dialog template to make it writable
1374 hResource
= FindResourceA(ppshpage
->hInstance
,
1375 (LPCSTR
)ppshpage
->u
.pszTemplate
,
1380 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1382 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1386 pTemplate
= LockResource(hTemplate
);
1388 * Make a copy of the dialog template to make it writable
1391 pTemplateCopy
= Alloc(resSize
);
1395 TRACE("copying pTemplate %p into pTemplateCopy %p (%d)\n", pTemplate
, pTemplateCopy
, resSize
);
1396 memcpy(pTemplateCopy
, pTemplate
, resSize
);
1398 if (((MyDLGTEMPLATEEX
*)pTemplateCopy
)->signature
== 0xFFFF)
1400 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1401 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~DS_MODALFRAME
;
1402 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_CAPTION
;
1403 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_SYSMENU
;
1404 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_POPUP
;
1405 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_DISABLED
;
1406 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_VISIBLE
;
1407 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_THICKFRAME
;
1409 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->exStyle
|= WS_EX_CONTROLPARENT
;
1413 pTemplateCopy
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1414 pTemplateCopy
->style
&= ~DS_MODALFRAME
;
1415 pTemplateCopy
->style
&= ~WS_CAPTION
;
1416 pTemplateCopy
->style
&= ~WS_SYSMENU
;
1417 pTemplateCopy
->style
&= ~WS_POPUP
;
1418 pTemplateCopy
->style
&= ~WS_DISABLED
;
1419 pTemplateCopy
->style
&= ~WS_VISIBLE
;
1420 pTemplateCopy
->style
&= ~WS_THICKFRAME
;
1422 pTemplateCopy
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1425 if (psInfo
->proppage
[index
].useCallback
)
1426 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1427 (LPPROPSHEETPAGEW
)ppshpage
);
1429 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1430 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1433 ppshpage
->pfnDlgProc
,
1436 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1439 ppshpage
->pfnDlgProc
,
1441 /* Free a no more needed copy */
1442 Free(pTemplateCopy
);
1447 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1449 /* Subclass exterior wizard pages */
1450 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1451 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1452 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1454 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1455 (DWORD_PTR
)ppshpage
);
1457 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1458 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1463 /******************************************************************************
1464 * PROPSHEET_LoadWizardBitmaps
1466 * Loads the watermark and header bitmaps for a wizard.
1468 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1470 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1472 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1473 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1474 considers hbmWatermark as valid. */
1475 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1476 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1478 psInfo
->ppshheader
.u4
.hbmWatermark
=
1479 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1482 /* Same behavior as for watermarks */
1483 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1484 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1486 psInfo
->ppshheader
.u5
.hbmHeader
=
1487 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1493 /******************************************************************************
1494 * PROPSHEET_ShowPage
1496 * Displays or creates the specified page.
1498 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1501 HWND hwndLineHeader
;
1503 LPCPROPSHEETPAGEW ppshpage
;
1505 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1506 if (index
== psInfo
->active_page
)
1508 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1509 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1513 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1514 if (psInfo
->proppage
[index
].hwndPage
== 0)
1516 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1519 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1521 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1522 psInfo
->proppage
[index
].pszText
);
1524 control
= GetNextDlgTabItem(psInfo
->proppage
[index
].hwndPage
, NULL
, FALSE
);
1529 if (psInfo
->active_page
!= -1)
1530 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1532 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1534 /* Synchronize current selection with tab control
1535 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1536 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1537 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1539 psInfo
->active_page
= index
;
1540 psInfo
->activeValid
= TRUE
;
1542 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1544 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1545 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1547 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1548 ShowWindow(hwndLineHeader
, SW_HIDE
);
1550 ShowWindow(hwndLineHeader
, SW_SHOW
);
1556 /******************************************************************************
1559 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1563 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1567 TRACE("active_page %d\n", psInfo
->active_page
);
1568 if (psInfo
->active_page
< 0)
1571 psn
.hdr
.code
= PSN_WIZBACK
;
1572 psn
.hdr
.hwndFrom
= hwndDlg
;
1576 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1578 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1581 else if (result
== 0)
1582 idx
= psInfo
->active_page
- 1;
1584 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1586 if (idx
>= 0 && idx
< psInfo
->nPages
)
1588 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1590 SetFocus(GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
));
1591 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
1592 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1598 /******************************************************************************
1601 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1605 LRESULT msgResult
= 0;
1606 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1609 TRACE("active_page %d\n", psInfo
->active_page
);
1610 if (psInfo
->active_page
< 0)
1613 psn
.hdr
.code
= PSN_WIZNEXT
;
1614 psn
.hdr
.hwndFrom
= hwndDlg
;
1618 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1620 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1621 if (msgResult
== -1)
1623 else if (msgResult
== 0)
1624 idx
= psInfo
->active_page
+ 1;
1626 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1628 if (idx
< psInfo
->nPages
)
1630 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1632 SetFocus(GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
));
1633 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
1634 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1641 /******************************************************************************
1644 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1648 LRESULT msgResult
= 0;
1649 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1651 TRACE("active_page %d\n", psInfo
->active_page
);
1652 if (psInfo
->active_page
< 0)
1655 psn
.hdr
.code
= PSN_WIZFINISH
;
1656 psn
.hdr
.hwndFrom
= hwndDlg
;
1660 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1662 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1664 TRACE("msg result %ld\n", msgResult
);
1669 if (psInfo
->result
== 0)
1670 psInfo
->result
= IDOK
;
1671 if (psInfo
->isModeless
)
1672 psInfo
->activeValid
= FALSE
;
1674 psInfo
->ended
= TRUE
;
1679 /******************************************************************************
1682 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1687 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1689 TRACE("active_page %d\n", psInfo
->active_page
);
1690 if (psInfo
->active_page
< 0)
1693 psn
.hdr
.hwndFrom
= hwndDlg
;
1699 * Send PSN_KILLACTIVE to the current page.
1701 psn
.hdr
.code
= PSN_KILLACTIVE
;
1703 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1705 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1709 * Send PSN_APPLY to all pages.
1711 psn
.hdr
.code
= PSN_APPLY
;
1712 psn
.lParam
= lParam
;
1714 for (i
= 0; i
< psInfo
->nPages
; i
++)
1716 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1719 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1721 case PSNRET_INVALID
:
1722 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1724 case PSNRET_INVALID_NOCHANGEPAGE
:
1732 psInfo
->activeValid
= FALSE
;
1734 else if(psInfo
->active_page
>= 0)
1736 psn
.hdr
.code
= PSN_SETACTIVE
;
1738 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1739 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1745 /******************************************************************************
1748 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1750 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1755 TRACE("active_page %d\n", psInfo
->active_page
);
1756 if (psInfo
->active_page
< 0)
1759 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1760 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1761 psn
.hdr
.hwndFrom
= hwndDlg
;
1765 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1768 psn
.hdr
.code
= PSN_RESET
;
1769 psn
.lParam
= lParam
;
1771 for (i
= 0; i
< psInfo
->nPages
; i
++)
1773 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1776 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1779 if (psInfo
->isModeless
)
1781 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1782 psInfo
->activeValid
= FALSE
;
1785 psInfo
->ended
= TRUE
;
1788 /******************************************************************************
1791 static void PROPSHEET_Help(HWND hwndDlg
)
1793 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1797 TRACE("active_page %d\n", psInfo
->active_page
);
1798 if (psInfo
->active_page
< 0)
1801 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1802 psn
.hdr
.code
= PSN_HELP
;
1803 psn
.hdr
.hwndFrom
= hwndDlg
;
1807 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1810 /******************************************************************************
1813 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1816 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1819 if (!psInfo
) return;
1821 * Set the dirty flag of this page.
1823 for (i
= 0; i
< psInfo
->nPages
; i
++)
1825 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1826 psInfo
->proppage
[i
].isDirty
= TRUE
;
1830 * Enable the Apply button.
1832 if (psInfo
->hasApply
)
1834 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1836 EnableWindow(hwndApplyBtn
, TRUE
);
1840 /******************************************************************************
1841 * PROPSHEET_UnChanged
1843 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1846 BOOL noPageDirty
= TRUE
;
1847 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1848 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1851 if ( !psInfo
) return;
1852 for (i
= 0; i
< psInfo
->nPages
; i
++)
1854 /* set the specified page as clean */
1855 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1856 psInfo
->proppage
[i
].isDirty
= FALSE
;
1858 /* look to see if there are any dirty pages */
1859 if (psInfo
->proppage
[i
].isDirty
)
1860 noPageDirty
= FALSE
;
1864 * Disable Apply button.
1867 EnableWindow(hwndApplyBtn
, FALSE
);
1870 /******************************************************************************
1871 * PROPSHEET_PressButton
1873 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1875 TRACE("buttonID %d\n", buttonID
);
1878 case PSBTN_APPLYNOW
:
1879 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1882 PROPSHEET_Back(hwndDlg
);
1885 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1888 PROPSHEET_Finish(hwndDlg
);
1891 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1894 PROPSHEET_Next(hwndDlg
);
1897 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1900 FIXME("Invalid button index %d\n", buttonID
);
1905 /*************************************************************************
1906 * BOOL PROPSHEET_CanSetCurSel [Internal]
1908 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1911 * hwndDlg [I] handle to a Dialog hWnd
1914 * TRUE if Current Selection can change
1918 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
1920 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1931 TRACE("active_page %d\n", psInfo
->active_page
);
1932 if (psInfo
->active_page
< 0)
1939 * Notify the current page.
1941 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1942 psn
.hdr
.code
= PSN_KILLACTIVE
;
1943 psn
.hdr
.hwndFrom
= hwndDlg
;
1947 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1950 TRACE("<-- %d\n", res
);
1954 /******************************************************************************
1955 * PROPSHEET_SetCurSel
1957 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
1960 HPROPSHEETPAGE hpage
1963 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1964 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
1965 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1967 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
1969 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
1971 if (index
< 0 || index
>= psInfo
->nPages
)
1973 TRACE("Could not find page to select!\n");
1977 /* unset active page while doing this transition. */
1978 if (psInfo
->active_page
!= -1)
1979 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1980 psInfo
->active_page
= -1;
1986 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1989 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
1991 psn
.hdr
.code
= PSN_SETACTIVE
;
1992 psn
.hdr
.hwndFrom
= hwndDlg
;
1996 if (!psInfo
->proppage
[index
].hwndPage
) {
1997 if(!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
)) {
1998 PROPSHEET_RemovePage(hwndDlg
, index
, NULL
);
1999 if(index
>= psInfo
->nPages
)
2007 /* Resize the property sheet page to the fit in the Tab control
2008 * (for regular property sheets) or to fit in the client area (for
2010 * NOTE: The resizing happens every time the page is selected and
2011 * not only when it's created (some applications depend on it). */
2012 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2013 TRACE("setting page %p, rc (%s) w=%d, h=%d\n",
2014 psInfo
->proppage
[index
].hwndPage
, wine_dbgstr_rect(&rc
),
2015 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2016 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2018 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2020 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2027 WARN("Tried to skip before first property sheet page!\n");
2030 if (index
>= psInfo
->nPages
) {
2031 WARN("Tried to skip after last property sheet page!\n");
2032 index
= psInfo
->nPages
-1;
2036 else if (result
!= 0)
2038 int old_index
= index
;
2039 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2040 if(index
>= psInfo
->nPages
) {
2042 WARN("Tried to skip to nonexistent page by res id\n");
2049 /* Invalidate the header area */
2050 if ( (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
2051 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
2053 HWND hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
2056 GetClientRect(hwndLineHeader
, &r
);
2057 MapWindowPoints(hwndLineHeader
, hwndDlg
, (LPPOINT
) &r
, 2);
2058 SetRect(&r
, 0, 0, r
.right
+ 1, r
.top
- 1);
2060 InvalidateRect(hwndDlg
, &r
, TRUE
);
2064 * Display the new page.
2066 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2068 if (psInfo
->proppage
[index
].hasHelp
)
2069 EnableWindow(hwndHelp
, TRUE
);
2071 EnableWindow(hwndHelp
, FALSE
);
2076 /******************************************************************************
2077 * PROPSHEET_SetCurSelId
2079 * Selects the page, specified by resource id.
2081 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2084 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2086 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2087 if (idx
< psInfo
->nPages
)
2089 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2090 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2094 /******************************************************************************
2095 * PROPSHEET_SetTitleA
2097 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2099 if(!IS_INTRESOURCE(lpszText
))
2102 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2103 szTitle
, sizeof(szTitle
)/sizeof(WCHAR
));
2104 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2108 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2112 /******************************************************************************
2113 * PROPSHEET_SetTitleW
2115 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2117 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2120 TRACE("%s (style %08x)\n", debugstr_w(lpszText
), dwStyle
);
2121 if (IS_INTRESOURCE(lpszText
)) {
2122 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2123 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0])))
2127 if (dwStyle
& PSH_PROPTITLE
)
2130 int lentitle
= strlenW(lpszText
);
2131 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2133 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2134 wsprintfW(dest
, psInfo
->strPropertiesFor
, lpszText
);
2136 SetWindowTextW(hwndDlg
, dest
);
2140 SetWindowTextW(hwndDlg
, lpszText
);
2143 /******************************************************************************
2144 * PROPSHEET_SetFinishTextA
2146 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2148 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2149 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2151 TRACE("'%s'\n", lpszText
);
2152 /* Set text, show and enable the Finish button */
2153 SetWindowTextA(hwndButton
, lpszText
);
2154 ShowWindow(hwndButton
, SW_SHOW
);
2155 EnableWindow(hwndButton
, TRUE
);
2157 /* Make it default pushbutton */
2158 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2160 /* Hide Back button */
2161 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2162 ShowWindow(hwndButton
, SW_HIDE
);
2164 if (!psInfo
->hasFinish
)
2166 /* Hide Next button */
2167 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2168 ShowWindow(hwndButton
, SW_HIDE
);
2172 /******************************************************************************
2173 * PROPSHEET_SetFinishTextW
2175 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2177 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2178 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2180 TRACE("%s\n", debugstr_w(lpszText
));
2181 /* Set text, show and enable the Finish button */
2182 SetWindowTextW(hwndButton
, lpszText
);
2183 ShowWindow(hwndButton
, SW_SHOW
);
2184 EnableWindow(hwndButton
, TRUE
);
2186 /* Make it default pushbutton */
2187 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2189 /* Hide Back button */
2190 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2191 ShowWindow(hwndButton
, SW_HIDE
);
2193 if (!psInfo
->hasFinish
)
2195 /* Hide Next button */
2196 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2197 ShowWindow(hwndButton
, SW_HIDE
);
2201 /******************************************************************************
2202 * PROPSHEET_QuerySiblings
2204 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2205 WPARAM wParam
, LPARAM lParam
)
2209 LRESULT msgResult
= 0;
2210 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2212 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2214 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2215 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2222 /******************************************************************************
2223 * PROPSHEET_InsertPage
2225 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2227 PropSheetInfo
*psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2228 PropPageInfo
*ppi
, *prev_ppi
= psInfo
->proppage
;
2229 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2230 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2234 TRACE("hwndDlg %p, hpageInsertAfter %p, hpage %p\n", hwndDlg
, hpageInsertAfter
, hpage
);
2236 if (IS_INTRESOURCE(hpageInsertAfter
))
2237 index
= LOWORD(hpageInsertAfter
);
2240 index
= PROPSHEET_GetPageIndex(hpageInsertAfter
, psInfo
, -1);
2243 TRACE("Could not find page to insert after!\n");
2249 if (index
> psInfo
->nPages
)
2250 index
= psInfo
->nPages
;
2252 ppi
= Alloc(sizeof(PropPageInfo
) * (psInfo
->nPages
+ 1));
2257 * Fill in a new PropPageInfo entry.
2260 memcpy(ppi
, prev_ppi
, index
* sizeof(PropPageInfo
));
2261 memset(&ppi
[index
], 0, sizeof(PropPageInfo
));
2262 if (index
< psInfo
->nPages
)
2263 memcpy(&ppi
[index
+ 1], &prev_ppi
[index
], (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2264 psInfo
->proppage
= ppi
;
2266 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, index
, FALSE
))
2268 psInfo
->proppage
= prev_ppi
;
2273 psInfo
->proppage
[index
].hpage
= hpage
;
2275 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2277 /* Create the page but don't show it */
2278 if (!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppsp
))
2280 psInfo
->proppage
= prev_ppi
;
2288 if (index
<= psInfo
->active_page
)
2289 psInfo
->active_page
++;
2292 * Add a new tab to the tab control.
2294 item
.mask
= TCIF_TEXT
;
2295 item
.pszText
= (LPWSTR
) psInfo
->proppage
[index
].pszText
;
2296 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2298 if (psInfo
->hImageList
)
2299 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2301 if (psInfo
->proppage
[index
].hasIcon
)
2303 item
.mask
|= TCIF_IMAGE
;
2304 item
.iImage
= index
;
2307 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, index
, (LPARAM
)&item
);
2309 /* If it is the only page - show it */
2310 if (psInfo
->nPages
== 1)
2311 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2316 /******************************************************************************
2319 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
, HPROPSHEETPAGE hpage
)
2321 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2322 TRACE("hwndDlg %p, hpage %p\n", hwndDlg
, hpage
);
2323 return PROPSHEET_InsertPage(hwndDlg
, UlongToPtr(psInfo
->nPages
), hpage
);
2326 /******************************************************************************
2327 * PROPSHEET_RemovePage
2329 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2331 HPROPSHEETPAGE hpage
)
2333 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2334 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2335 PropPageInfo
* oldPages
;
2337 TRACE("index %d, hpage %p\n", index
, hpage
);
2342 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
2344 /* Make sure that index is within range */
2345 if (index
< 0 || index
>= psInfo
->nPages
)
2347 TRACE("Could not find page to remove!\n");
2351 TRACE("total pages %d removing page %d active page %d\n",
2352 psInfo
->nPages
, index
, psInfo
->active_page
);
2354 * Check if we're removing the active page.
2356 if (index
== psInfo
->active_page
)
2358 if (psInfo
->nPages
> 1)
2362 /* activate previous page */
2363 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2367 /* activate the next page */
2368 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2369 psInfo
->active_page
= index
;
2374 psInfo
->active_page
= -1;
2375 if (!psInfo
->isModeless
)
2377 psInfo
->ended
= TRUE
;
2382 else if (index
< psInfo
->active_page
)
2383 psInfo
->active_page
--;
2385 /* Unsubclass the page dialog window */
2386 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2387 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2388 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2390 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2391 PROPSHEET_WizardSubclassProc
, 1);
2394 /* Destroy page dialog window */
2395 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2397 /* Free page resources */
2398 if(psInfo
->proppage
[index
].hpage
)
2400 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2402 if (psp
->dwFlags
& PSP_USETITLE
)
2403 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2405 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2408 /* Remove the tab */
2409 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2411 oldPages
= psInfo
->proppage
;
2413 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2416 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2418 if (index
< psInfo
->nPages
)
2419 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2420 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2427 /******************************************************************************
2428 * PROPSHEET_SetWizButtons
2430 * This code will work if (and assumes that) the Next button is on top of the
2431 * Finish button. ie. Finish comes after Next in the Z order.
2432 * This means make sure the dialog template reflects this.
2435 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2437 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2438 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2439 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2440 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2441 BOOL enable_finish
= ((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
);
2444 HWND hwndCancel
= GetDlgItem(hwndDlg
, IDCANCEL
);
2449 TRACE("%d\n", dwFlags
);
2451 EnableWindow(hwndBack
, dwFlags
& PSWIZB_BACK
);
2452 EnableWindow(hwndNext
, dwFlags
& PSWIZB_NEXT
);
2453 EnableWindow(hwndFinish
, enable_finish
);
2456 /* set the default pushbutton to an enabled button */
2458 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2459 else if (dwFlags
& PSWIZB_NEXT
)
2460 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2461 else if (dwFlags
& PSWIZB_BACK
)
2462 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
2464 SendMessageW(hwndDlg
, DM_SETDEFID
, IDCANCEL
, 0);
2467 if (!psInfo
->hasFinish
)
2469 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2471 /* Hide the Next button */
2472 ShowWindow(hwndNext
, SW_HIDE
);
2474 /* Show the Finish button */
2475 ShowWindow(hwndFinish
, SW_SHOW
);
2479 /* Hide the Finish button */
2480 ShowWindow(hwndFinish
, SW_HIDE
);
2481 /* Show the Next button */
2482 ShowWindow(hwndNext
, SW_SHOW
);
2487 /* set the default pushbutton to an enabled button */
2488 if (((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
))
2489 iDefItem
= IDC_FINISH_BUTTON
;
2490 else if (dwFlags
& PSWIZB_NEXT
)
2491 iDefItem
= IDC_NEXT_BUTTON
;
2492 else if (dwFlags
& PSWIZB_BACK
)
2493 iDefItem
= IDC_BACK_BUTTON
;
2495 iDefItem
= IDCANCEL
;
2496 SendMessageW(hwndDlg
, DM_SETDEFID
, iDefItem
, 0);
2498 /* Set focus if no control has it */
2499 hwndFocus
= GetFocus();
2500 if (!hwndFocus
|| hwndFocus
== hwndCancel
)
2501 SetFocus(GetDlgItem(hwndDlg
, iDefItem
));
2506 /******************************************************************************
2507 * PROPSHEET_SetHeaderTitleW
2509 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, UINT page_index
, const WCHAR
*title
)
2511 PropSheetInfo
*psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2512 PROPSHEETPAGEW
*page
;
2514 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_w(title
));
2516 if (page_index
>= psInfo
->nPages
)
2519 page
= (PROPSHEETPAGEW
*)psInfo
->proppage
[page_index
].hpage
;
2521 if (!IS_INTRESOURCE(page
->pszHeaderTitle
))
2522 Free((void *)page
->pszHeaderTitle
);
2524 page
->pszHeaderTitle
= heap_strdupW(title
);
2525 page
->dwFlags
|= PSP_USEHEADERTITLE
;
2528 /******************************************************************************
2529 * PROPSHEET_SetHeaderTitleA
2531 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, UINT page_index
, const char *title
)
2535 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_a(title
));
2537 titleW
= heap_strdupAtoW(title
);
2538 PROPSHEET_SetHeaderTitleW(hwndDlg
, page_index
, titleW
);
2542 /******************************************************************************
2543 * PROPSHEET_SetHeaderSubTitleW
2545 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, UINT page_index
, const WCHAR
*subtitle
)
2547 PropSheetInfo
*psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2548 PROPSHEETPAGEW
*page
;
2550 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_w(subtitle
));
2552 if (page_index
>= psInfo
->nPages
)
2555 page
= (PROPSHEETPAGEW
*)psInfo
->proppage
[page_index
].hpage
;
2557 if (!IS_INTRESOURCE(page
->pszHeaderSubTitle
))
2558 Free((void *)page
->pszHeaderSubTitle
);
2560 page
->pszHeaderSubTitle
= heap_strdupW(subtitle
);
2561 page
->dwFlags
|= PSP_USEHEADERSUBTITLE
;
2564 /******************************************************************************
2565 * PROPSHEET_SetHeaderSubTitleA
2567 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, UINT page_index
, const char *subtitle
)
2571 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_a(subtitle
));
2573 subtitleW
= heap_strdupAtoW(subtitle
);
2574 PROPSHEET_SetHeaderSubTitleW(hwndDlg
, page_index
, subtitleW
);
2578 /******************************************************************************
2579 * PROPSHEET_HwndToIndex
2581 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2584 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2586 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2588 for (index
= 0; index
< psInfo
->nPages
; index
++)
2589 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2591 WARN("%p not found\n", hPageDlg
);
2595 /******************************************************************************
2596 * PROPSHEET_IndexToHwnd
2598 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2600 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2601 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2604 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2605 WARN("%d out of range.\n", iPageIndex
);
2608 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2611 /******************************************************************************
2612 * PROPSHEET_PageToIndex
2614 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2616 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2618 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2620 return PROPSHEET_GetPageIndex(hPage
, psInfo
, -1);
2623 /******************************************************************************
2624 * PROPSHEET_IndexToPage
2626 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2628 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2629 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2630 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2631 WARN("%d out of range.\n", iPageIndex
);
2634 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2637 /******************************************************************************
2638 * PROPSHEET_IdToIndex
2640 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2643 LPCPROPSHEETPAGEW psp
;
2644 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2645 TRACE("(%p, %d)\n", hwndDlg
, iPageId
);
2646 for (index
= 0; index
< psInfo
->nPages
; index
++) {
2647 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2648 if (psp
->u
.pszTemplate
== MAKEINTRESOURCEW(iPageId
))
2655 /******************************************************************************
2656 * PROPSHEET_IndexToId
2658 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2660 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2661 LPCPROPSHEETPAGEW psp
;
2662 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2663 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2664 WARN("%d out of range.\n", iPageIndex
);
2667 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2668 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| !IS_INTRESOURCE(psp
->u
.pszTemplate
)) {
2671 return (LRESULT
)psp
->u
.pszTemplate
;
2674 /******************************************************************************
2675 * PROPSHEET_GetResult
2677 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2679 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2680 return psInfo
->result
;
2683 /******************************************************************************
2684 * PROPSHEET_RecalcPageSizes
2686 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2688 FIXME("(%p): stub\n", hwndDlg
);
2692 /******************************************************************************
2693 * PROPSHEET_GetPageIndex
2695 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2696 * the array of PropPageInfo. If page is not found original index is used
2697 * (page takes precedence over index).
2699 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE page
, const PropSheetInfo
* psInfo
, int original_index
)
2703 TRACE("page %p index %d\n", page
, original_index
);
2705 for (index
= 0; index
< psInfo
->nPages
; index
++)
2706 if (psInfo
->proppage
[index
].hpage
== page
)
2709 return original_index
;
2712 /******************************************************************************
2715 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2718 PropSheetInfo
* psInfo
= RemovePropW(hwndDlg
, PropSheetInfoStr
);
2721 if (!psInfo
) return;
2722 if (!IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
))
2723 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2725 for (i
= 0; i
< psInfo
->nPages
; i
++)
2727 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2729 /* Unsubclass the page dialog window */
2730 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2731 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2732 (psp
->dwFlags
& PSP_HIDEHEADER
))
2734 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2735 PROPSHEET_WizardSubclassProc
, 1);
2738 if(psInfo
->proppage
[i
].hwndPage
)
2739 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2743 if (psp
->dwFlags
& PSP_USETITLE
)
2744 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2746 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2750 DeleteObject(psInfo
->hFont
);
2751 DeleteObject(psInfo
->hFontBold
);
2752 /* If we created the bitmaps, destroy them */
2753 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2754 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2755 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2756 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2757 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2758 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2760 Free(psInfo
->proppage
);
2761 Free(psInfo
->strPropertiesFor
);
2762 ImageList_Destroy(psInfo
->hImageList
);
2767 static INT
do_loop(const PropSheetInfo
*psInfo
)
2771 HWND hwnd
= psInfo
->hwnd
;
2772 HWND parent
= psInfo
->ppshheader
.hwndParent
;
2774 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2779 if(!IsDialogMessageW(hwnd
, &msg
))
2781 TranslateMessage(&msg
);
2782 DispatchMessageW(&msg
);
2788 PostQuitMessage(msg
.wParam
);
2793 ret
= psInfo
->result
;
2796 EnableWindow(parent
, TRUE
);
2798 DestroyWindow(hwnd
);
2802 /******************************************************************************
2803 * PROPSHEET_PropertySheet
2805 * Common code between PropertySheetA/W
2807 static INT_PTR
PROPSHEET_PropertySheet(PropSheetInfo
* psInfo
, BOOL unicode
)
2811 if (psInfo
->active_page
>= psInfo
->nPages
) psInfo
->active_page
= 0;
2812 TRACE("startpage: %d of %d pages\n", psInfo
->active_page
, psInfo
->nPages
);
2814 psInfo
->unicode
= unicode
;
2815 psInfo
->ended
= FALSE
;
2817 if(!psInfo
->isModeless
)
2819 parent
= psInfo
->ppshheader
.hwndParent
;
2820 if (parent
) EnableWindow(parent
, FALSE
);
2822 bRet
= PROPSHEET_CreateDialog(psInfo
);
2823 if(!psInfo
->isModeless
)
2824 bRet
= do_loop(psInfo
);
2828 /******************************************************************************
2829 * PropertySheet (COMCTL32.@)
2830 * PropertySheetA (COMCTL32.@)
2832 * Creates a property sheet in the specified property sheet header.
2835 * Modal property sheets: Positive if successful or -1 otherwise.
2836 * Modeless property sheets: Property sheet handle.
2838 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2839 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2841 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2843 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2847 TRACE("(%p)\n", lppsh
);
2849 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2851 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2852 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2854 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2856 if (!psInfo
->usePropPage
)
2857 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2860 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2861 pByte
+= ((LPCPROPSHEETPAGEA
)pByte
)->dwSize
;
2864 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2867 if (psInfo
->usePropPage
)
2868 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2874 return PROPSHEET_PropertySheet(psInfo
, FALSE
);
2877 /******************************************************************************
2878 * PropertySheetW (COMCTL32.@)
2880 * See PropertySheetA.
2882 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2884 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2888 TRACE("(%p)\n", lppsh
);
2890 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2892 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2893 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2895 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2897 if (!psInfo
->usePropPage
)
2898 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2901 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2902 pByte
+= ((LPCPROPSHEETPAGEW
)pByte
)->dwSize
;
2905 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2908 if (psInfo
->usePropPage
)
2909 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2915 return PROPSHEET_PropertySheet(psInfo
, TRUE
);
2918 static LPWSTR
load_string( HINSTANCE instance
, LPCWSTR str
)
2922 if (IS_INTRESOURCE(str
))
2927 WORD i
, id
= LOWORD(str
);
2930 if (!(hrsrc
= FindResourceW( instance
, MAKEINTRESOURCEW((id
>> 4) + 1), (LPWSTR
)RT_STRING
)))
2932 if (!(hmem
= LoadResource( instance
, hrsrc
))) return NULL
;
2933 if (!(ptr
= LockResource( hmem
))) return NULL
;
2934 for (i
= id
& 0x0f; i
> 0; i
--) ptr
+= *ptr
+ 1;
2936 if (!len
) return NULL
;
2937 ret
= Alloc( (len
+ 1) * sizeof(WCHAR
) );
2940 memcpy( ret
, ptr
+ 1, len
* sizeof(WCHAR
) );
2946 int len
= (strlenW(str
) + 1) * sizeof(WCHAR
);
2948 if (ret
) memcpy( ret
, str
, len
);
2954 /******************************************************************************
2955 * CreatePropertySheetPage (COMCTL32.@)
2956 * CreatePropertySheetPageA (COMCTL32.@)
2958 * Creates a new property sheet page.
2961 * Success: Handle to new property sheet page.
2965 * An application must use the PSM_ADDPAGE message to add the new page to
2966 * an existing property sheet.
2968 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2969 LPCPROPSHEETPAGEA lpPropSheetPage
)
2971 PROPSHEETPAGEW
*ppsp
;
2973 if (lpPropSheetPage
->dwSize
< PROPSHEETPAGEA_V1_SIZE
)
2976 /* original data is used for callback notifications */
2977 if ((lpPropSheetPage
->dwFlags
& PSP_USECALLBACK
) && lpPropSheetPage
->pfnCallback
)
2979 ppsp
= Alloc(2 * sizeof(*ppsp
));
2980 memcpy(ppsp
, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEA
)));
2981 memcpy(ppsp
+ 1, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEA
)));
2985 ppsp
= Alloc(sizeof(*ppsp
));
2986 memcpy(ppsp
, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEA
)));
2989 ppsp
->dwFlags
&= ~PSP_INTERNAL_UNICODE
;
2991 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2993 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
2995 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
) + 1;
2996 char *template = Alloc( len
);
2998 ppsp
->u
.pszTemplate
= (LPWSTR
)strcpy( template, lpPropSheetPage
->u
.pszTemplate
);
3002 if (ppsp
->dwFlags
& PSP_USEICONID
)
3004 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
3005 ppsp
->u2
.pszIcon
= heap_strdupAtoW( lpPropSheetPage
->u2
.pszIcon
);
3008 if (ppsp
->dwFlags
& PSP_USETITLE
)
3010 if (IS_INTRESOURCE( ppsp
->pszTitle
))
3011 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3013 ppsp
->pszTitle
= heap_strdupAtoW( lpPropSheetPage
->pszTitle
);
3016 ppsp
->pszTitle
= NULL
;
3018 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3019 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3021 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3023 if (IS_INTRESOURCE( ppsp
->pszHeaderTitle
))
3024 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3026 ppsp
->pszHeaderTitle
= heap_strdupAtoW( lpPropSheetPage
->pszHeaderTitle
);
3029 ppsp
->pszHeaderTitle
= NULL
;
3031 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3033 if (IS_INTRESOURCE( ppsp
->pszHeaderSubTitle
))
3034 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3036 ppsp
->pszHeaderSubTitle
= heap_strdupAtoW( lpPropSheetPage
->pszHeaderSubTitle
);
3039 ppsp
->pszHeaderSubTitle
= NULL
;
3041 if ((ppsp
->dwFlags
& PSP_USECALLBACK
) && ppsp
->dwSize
> PROPSHEETPAGEA_V1_SIZE
&& ppsp
->pfnCallback
)
3042 ppsp
->pfnCallback(0, PSPCB_ADDREF
, ppsp
+ 1);
3044 return (HPROPSHEETPAGE
)ppsp
;
3047 /******************************************************************************
3048 * CreatePropertySheetPageW (COMCTL32.@)
3050 * See CreatePropertySheetA.
3052 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
3054 PROPSHEETPAGEW
*ppsp
;
3056 if (lpPropSheetPage
->dwSize
< PROPSHEETPAGEW_V1_SIZE
)
3059 /* original data is used for callback notifications */
3060 if ((lpPropSheetPage
->dwFlags
& PSP_USECALLBACK
) && lpPropSheetPage
->pfnCallback
)
3062 ppsp
= Alloc(2 * sizeof(*ppsp
));
3063 memcpy(ppsp
, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEW
)));
3064 memcpy(ppsp
+ 1, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEW
)));
3068 ppsp
= Alloc(sizeof(*ppsp
));
3069 memcpy(ppsp
, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEW
)));
3072 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
3074 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
3076 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
3077 ppsp
->u
.pszTemplate
= heap_strdupW( lpPropSheetPage
->u
.pszTemplate
);
3080 if ( ppsp
->dwFlags
& PSP_USEICONID
)
3082 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
3083 ppsp
->u2
.pszIcon
= heap_strdupW( lpPropSheetPage
->u2
.pszIcon
);
3086 if (ppsp
->dwFlags
& PSP_USETITLE
)
3087 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3089 ppsp
->pszTitle
= NULL
;
3091 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3092 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3094 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3095 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3097 ppsp
->pszHeaderTitle
= NULL
;
3099 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3100 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3102 ppsp
->pszHeaderSubTitle
= NULL
;
3104 if ((ppsp
->dwFlags
& PSP_USECALLBACK
) && ppsp
->dwSize
> PROPSHEETPAGEW_V1_SIZE
&& ppsp
->pfnCallback
)
3105 ppsp
->pfnCallback(0, PSPCB_ADDREF
, ppsp
+ 1);
3107 return (HPROPSHEETPAGE
)ppsp
;
3110 /******************************************************************************
3111 * DestroyPropertySheetPage (COMCTL32.@)
3113 * Destroys a property sheet page previously created with
3114 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
3121 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
3123 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3128 if ((psp
->dwFlags
& PSP_USECALLBACK
) && psp
->pfnCallback
)
3129 psp
->pfnCallback(0, PSPCB_RELEASE
, psp
+ 1);
3131 if (!(psp
->dwFlags
& PSP_DLGINDIRECT
) && !IS_INTRESOURCE( psp
->u
.pszTemplate
))
3132 Free ((LPVOID
)psp
->u
.pszTemplate
);
3134 if ((psp
->dwFlags
& PSP_USEICONID
) && !IS_INTRESOURCE( psp
->u2
.pszIcon
))
3135 Free ((LPVOID
)psp
->u2
.pszIcon
);
3137 if ((psp
->dwFlags
& PSP_USETITLE
) && !IS_INTRESOURCE( psp
->pszTitle
))
3138 Free ((LPVOID
)psp
->pszTitle
);
3140 if ((psp
->dwFlags
& PSP_USEHEADERTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderTitle
))
3141 Free ((LPVOID
)psp
->pszHeaderTitle
);
3143 if ((psp
->dwFlags
& PSP_USEHEADERSUBTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderSubTitle
))
3144 Free ((LPVOID
)psp
->pszHeaderSubTitle
);
3151 /******************************************************************************
3152 * PROPSHEET_IsDialogMessage
3154 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3156 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3159 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3162 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3165 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3167 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3169 switch (lpMsg
->wParam
)
3172 if (GetKeyState(VK_SHIFT
) & 0x8000)
3178 case VK_NEXT
: new_page
= 1; break;
3179 case VK_PRIOR
: new_page
= -1; break;
3185 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3187 new_page
+= psInfo
->active_page
;
3190 new_page
= psInfo
->nPages
- 1;
3191 else if (new_page
>= psInfo
->nPages
)
3194 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3201 return IsDialogMessageW(hwnd
, lpMsg
);
3204 /******************************************************************************
3205 * PROPSHEET_DoCommand
3207 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3213 case IDC_APPLY_BUTTON
:
3215 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3217 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3222 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3224 /* don't overwrite ID_PSRESTARTWINDOWS or ID_PSREBOOTSYSTEM */
3225 if (psInfo
->result
== 0)
3226 psInfo
->result
= IDOK
;
3228 if (psInfo
->isModeless
)
3229 psInfo
->activeValid
= FALSE
;
3231 psInfo
->ended
= TRUE
;
3234 EnableWindow(hwndApplyBtn
, FALSE
);
3239 case IDC_BACK_BUTTON
:
3240 PROPSHEET_Back(hwnd
);
3243 case IDC_NEXT_BUTTON
:
3244 PROPSHEET_Next(hwnd
);
3247 case IDC_FINISH_BUTTON
:
3248 PROPSHEET_Finish(hwnd
);
3252 PROPSHEET_Cancel(hwnd
, 0);
3256 PROPSHEET_Help(hwnd
);
3266 /******************************************************************************
3269 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3271 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3276 HPALETTE hOldPal
= 0;
3280 LPCPROPSHEETPAGEW ppshpage
;
3281 WCHAR szBuffer
[256];
3284 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3287 hdcSrc
= CreateCompatibleDC(0);
3289 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3290 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3292 if (psInfo
->active_page
< 0)
3295 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3297 if ( (ppshpage
&& !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3298 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3299 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3301 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3303 COLORREF clrOld
= 0;
3306 GetClientRect(hwndLineHeader
, &r
);
3307 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3308 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3310 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3313 if (psInfo
->ppshheader
.u5
.hbmHeader
)
3315 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)
3318 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3320 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), &bm
);
3321 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3323 /* Fill the unoccupied part of the header with color of the
3324 * left-top pixel, but do it only when needed.
3326 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3328 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3330 if (bm
.bmWidth
< r
.right
)
3332 r
.left
= bm
.bmWidth
;
3333 FillRect(hdc
, &r
, hbr
);
3335 if (bm
.bmHeight
< r
.bottom
)
3338 r
.top
= bm
.bmHeight
;
3339 FillRect(hdc
, &r
, hbr
);
3344 /* Draw the header itself. */
3345 BitBlt(hdc
, 0, 0, bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3346 hdcSrc
, 0, 0, SRCCOPY
);
3351 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3352 FillRect(hdc
, &rzone
, hbr
);
3354 /* Draw the header bitmap. It's always centered like a
3355 * common 49 x 49 bitmap. */
3356 margin
= (rzone
.bottom
- 49) / 2;
3357 BitBlt(hdc
, rzone
.right
- 49 - margin
, margin
,
3358 min(bm
.bmWidth
, 49), min(bm
.bmHeight
, 49),
3359 hdcSrc
, 0, 0, SRCCOPY
);
3361 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3362 * if its height is smaller than 49 pixels. Because the reason
3363 * for this bug is unknown the current code doesn't try to
3367 SelectObject(hdcSrc
, hbmp
);
3370 clrOld
= SetTextColor (hdc
, 0x00000000);
3371 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3373 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3374 SetRect(&r
, 20, 10, 0, 0);
3375 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3376 DrawTextW(hdc
, ppshpage
->pszHeaderTitle
, -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3379 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderTitle
,
3383 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3388 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3389 SelectObject(hdc
, psInfo
->hFont
);
3390 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3392 if (!IS_INTRESOURCE(ppshpage
->pszHeaderSubTitle
))
3394 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3396 DrawTextW(hdc
, ppshpage
->pszHeaderSubTitle
, -1, &r
, DT_LEFT
| DT_WORDBREAK
);
3399 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderSubTitle
,
3403 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_WORDBREAK
);
3408 offsety
= rzone
.bottom
+ 2;
3410 SetTextColor(hdc
, clrOld
);
3411 SetBkMode(hdc
, oldBkMode
);
3412 SelectObject(hdc
, hOldFont
);
3415 if ( (ppshpage
&& (ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3416 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3418 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
3419 (psInfo
->ppshheader
.u4
.hbmWatermark
) )
3421 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3424 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3426 GetClientRect(hwndLine
, &r
);
3427 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3428 SetRect(&rzone
, 0, 0, r
.right
, r
.top
- 1);
3430 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3431 FillRect(hdc
, &rzone
, hbr
);
3433 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), &bm
);
3434 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3436 /* The watermark is truncated to a width of 164 pixels */
3437 r
.right
= min(r
.right
, 164);
3438 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3439 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3441 /* If the bitmap is not big enough, fill the remaining area
3442 with the color of pixel (0,0) of bitmap - see MSDN */
3443 if (r
.top
> bm
.bmHeight
) {
3444 r
.bottom
= r
.top
- 1;
3445 r
.top
= bm
.bmHeight
;
3447 r
.right
= bm
.bmWidth
;
3448 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3449 FillRect(hdc
, &r
, hbr
);
3453 SelectObject(hdcSrc
, hbmp
);
3456 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3457 SelectPalette(hdc
, hOldPal
, FALSE
);
3461 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3466 /******************************************************************************
3467 * PROPSHEET_DialogProc
3469 static INT_PTR CALLBACK
3470 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3472 TRACE("hwnd=%p msg=0x%04x wparam=%lx lparam=%lx\n",
3473 hwnd
, uMsg
, wParam
, lParam
);
3479 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3480 WCHAR
* strCaption
= Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3481 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3485 /* Using PropSheetInfoStr to store extra data doesn't match the native
3486 * common control: native uses TCM_[GS]ETITEM
3488 SetPropW(hwnd
, PropSheetInfoStr
, psInfo
);
3491 * psInfo->hwnd is not being used by WINE code - it exists
3492 * for compatibility with "real" Windoze. The same about
3493 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3496 psInfo
->hwnd
= hwnd
;
3497 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3499 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3501 /* set up the Next and Back buttons by default */
3502 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3506 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3507 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3508 logFont
.lfWeight
= FW_BOLD
;
3509 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3512 * Small icon in the title bar.
3514 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3515 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3518 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3519 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3521 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3522 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3523 psInfo
->ppshheader
.u
.pszIcon
,
3528 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3530 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3533 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3534 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3536 psInfo
->strPropertiesFor
= strCaption
;
3538 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3540 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3542 PROPSHEET_LoadWizardBitmaps(psInfo
);
3544 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3546 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3547 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3548 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3549 SetFocus(GetDlgItem(hwnd
, IDC_NEXT_BUTTON
));
3553 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3555 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3556 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3558 SetFocus(GetDlgItem(hwnd
, IDOK
));
3561 if (IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
) &&
3562 psInfo
->ppshheader
.hInstance
)
3566 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3567 (UINT_PTR
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3568 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3572 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3573 psInfo
->ppshheader
.pszCaption
);
3577 if (psInfo
->useCallback
)
3578 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
, PSCB_INITIALIZED
, 0);
3580 idx
= psInfo
->active_page
;
3581 psInfo
->active_page
= -1;
3583 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3585 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3586 * as some programs call TCM_GETCURSEL to get the current selection
3587 * from which to switch to the next page */
3588 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3590 PROPSHEET_UnChanged(hwnd
, NULL
);
3592 /* wizards set their focus during init */
3593 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3599 case WM_PRINTCLIENT
:
3601 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3605 PROPSHEET_CleanUp(hwnd
);
3609 PROPSHEET_Cancel(hwnd
, 1);
3610 return FALSE
; /* let DefDlgProc post us WM_COMMAND/IDCANCEL */
3613 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3615 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3620 /* No default handler, forward notification to active page */
3621 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3623 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3624 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3631 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3633 if (pnmh
->code
== TCN_SELCHANGE
)
3635 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3636 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3639 if(pnmh
->code
== TCN_SELCHANGING
)
3641 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3642 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3649 case WM_SYSCOLORCHANGE
:
3650 COMCTL32_RefreshSysColors();
3653 case PSM_GETCURRENTPAGEHWND
:
3655 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3661 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3662 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3664 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3670 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3674 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3677 case PSM_GETTABCONTROL
:
3679 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3681 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3690 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3691 if(msgResult
!= FALSE
)
3693 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3696 (HPROPSHEETPAGE
)lParam
);
3699 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3704 case PSM_CANCELTOCLOSE
:
3706 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3707 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3708 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3710 EnableWindow(hwndCancel
, FALSE
);
3711 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, sizeof(buf
)/sizeof(buf
[0])))
3712 SetWindowTextW(hwndOK
, buf
);
3717 case PSM_RESTARTWINDOWS
:
3719 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3724 /* reboot system takes precedence over restart windows */
3725 if (psInfo
->result
!= ID_PSREBOOTSYSTEM
)
3726 psInfo
->result
= ID_PSRESTARTWINDOWS
;
3731 case PSM_REBOOTSYSTEM
:
3733 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3738 psInfo
->result
= ID_PSREBOOTSYSTEM
;
3744 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3748 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3753 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3755 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3760 case PSM_QUERYSIBLINGS
:
3762 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3764 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3772 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3773 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3774 * on success or FALSE otherwise, as specified on MSDN Online.
3775 * Also see the MFC code for
3776 * CPropertySheet::AddPage(CPropertyPage* pPage).
3779 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3781 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3786 case PSM_REMOVEPAGE
:
3787 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3790 case PSM_ISDIALOGMESSAGE
:
3792 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3793 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3797 case PSM_PRESSBUTTON
:
3798 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3801 case PSM_SETFINISHTEXTA
:
3802 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3805 case PSM_SETWIZBUTTONS
:
3806 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3809 case PSM_SETCURSELID
:
3810 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3813 case PSM_SETFINISHTEXTW
:
3814 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3817 case PSM_INSERTPAGE
:
3819 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3820 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3824 case PSM_SETHEADERTITLEW
:
3825 PROPSHEET_SetHeaderTitleW(hwnd
, wParam
, (LPCWSTR
)lParam
);
3828 case PSM_SETHEADERTITLEA
:
3829 PROPSHEET_SetHeaderTitleA(hwnd
, wParam
, (LPCSTR
)lParam
);
3832 case PSM_SETHEADERSUBTITLEW
:
3833 PROPSHEET_SetHeaderSubTitleW(hwnd
, wParam
, (LPCWSTR
)lParam
);
3836 case PSM_SETHEADERSUBTITLEA
:
3837 PROPSHEET_SetHeaderSubTitleA(hwnd
, wParam
, (LPCSTR
)lParam
);
3840 case PSM_HWNDTOINDEX
:
3842 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3843 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3847 case PSM_INDEXTOHWND
:
3849 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3850 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3854 case PSM_PAGETOINDEX
:
3856 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3857 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3861 case PSM_INDEXTOPAGE
:
3863 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3864 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3870 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3871 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3877 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3878 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3884 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3885 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3889 case PSM_RECALCPAGESIZES
:
3891 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3892 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);