4 * Copyright 1998 Francis Beaudet
5 * Copyright 1999 Thuy Nguyen
6 * Copyright 2004 Maxime Bellenge
7 * Copyright 2004 Filip Navara
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * This code was audited for completeness against the documented features
24 * of Comctl32.dll version 6.0 on Sep. 12, 2004, by Filip Navara.
26 * Unless otherwise noted, we believe this code to be complete, as per
27 * the specification mentioned above.
28 * If you discover missing features, or bugs, please note them below.
32 * - Wizard 97 header resizing
33 * - Enforcing of minimal wizard size
36 * o PSM_RECALCPAGESIZES
37 * o PSM_SETHEADERSUBTITLE
38 * o PSM_SETHEADERTITLE
43 * o PSN_QUERYINITIALFOCUS
44 * o PSN_TRANSLATEACCELERATOR
47 * o PSH_STRETCHWATERMARK
51 * o PSP_USEFUSIONCONTEXT
58 #define NONAMELESSUNION
70 #include "wine/debug.h"
71 #include "wine/unicode.h"
73 /******************************************************************************
97 } MyDLGITEMTEMPLATEEX
;
100 typedef struct tagPropPageInfo
102 HPROPSHEETPAGE hpage
; /* to keep track of pages not passed to PropertySheet */
111 typedef struct tagPropSheetInfo
114 PROPSHEETHEADERW ppshheader
;
116 LPWSTR strPropertiesFor
;
126 PropPageInfo
* proppage
;
131 HIMAGELIST hImageList
;
142 /******************************************************************************
143 * Defines and global variables
146 static const WCHAR PropSheetInfoStr
[] =
147 {'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0 };
149 #define PSP_INTERNAL_UNICODE 0x80000000
151 #define MAX_CAPTION_LENGTH 255
152 #define MAX_TABTEXT_LENGTH 255
153 #define MAX_BUTTONTEXT_LENGTH 64
155 #define INTRNL_ANY_WIZARD (PSH_WIZARD | PSH_WIZARD97_OLD | PSH_WIZARD97_NEW | PSH_WIZARD_LITE)
157 /* Wizard metrics specified in DLUs */
158 #define WIZARD_PADDING 7
159 #define WIZARD_HEADER_HEIGHT 36
161 /******************************************************************************
164 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
);
165 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
);
166 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
);
167 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
170 HPROPSHEETPAGE hpage
);
171 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, const PropSheetInfo
* psInfo
, int original_index
);
172 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
);
173 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
);
174 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
, int index
, HPROPSHEETPAGE hpage
);
176 static INT_PTR CALLBACK
177 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
179 WINE_DEFAULT_DEBUG_CHANNEL(propsheet
);
181 #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");}
182 /******************************************************************************
183 * PROPSHEET_UnImplementedFlags
185 * Document use of flags we don't implement yet.
187 static VOID
PROPSHEET_UnImplementedFlags(DWORD dwFlags
)
194 * unhandled header flags:
195 * PSH_RTLREADING 0x00000800
196 * PSH_STRETCHWATERMARK 0x00040000
197 * PSH_USEPAGELANG 0x00200000
200 add_flag(PSH_RTLREADING
);
201 add_flag(PSH_STRETCHWATERMARK
);
202 add_flag(PSH_USEPAGELANG
);
203 if (string
[0] != '\0')
204 FIXME("%s\n", string
);
208 /******************************************************************************
209 * PROPSHEET_GetPageRect
211 * Retrieve rect from tab control and map into the dialog for SetWindowPos
213 static void PROPSHEET_GetPageRect(const PropSheetInfo
* psInfo
, HWND hwndDlg
,
214 RECT
*rc
, LPCPROPSHEETPAGEW ppshpage
)
216 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) {
220 if (((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
221 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
222 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) ||
223 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
))
225 rc
->left
= rc
->top
= WIZARD_PADDING
;
229 rc
->left
= rc
->top
= 0;
231 rc
->right
= psInfo
->width
- rc
->left
;
232 rc
->bottom
= psInfo
->height
- rc
->top
;
233 MapDialogRect(hwndDlg
, rc
);
235 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
236 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
237 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
))
239 hwndChild
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
240 GetClientRect(hwndChild
, &r
);
241 MapWindowPoints(hwndChild
, hwndDlg
, (LPPOINT
) &r
, 2);
242 rc
->top
+= r
.bottom
+ 1;
245 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
246 GetClientRect(hwndTabCtrl
, rc
);
247 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)rc
);
248 MapWindowPoints(hwndTabCtrl
, hwndDlg
, (LPPOINT
)rc
, 2);
252 /******************************************************************************
253 * PROPSHEET_FindPageByResId
255 * Find page index corresponding to page resource id.
257 static INT
PROPSHEET_FindPageByResId(const PropSheetInfo
* psInfo
, LRESULT resId
)
261 for (i
= 0; i
< psInfo
->nPages
; i
++)
263 LPCPROPSHEETPAGEA lppsp
= (LPCPROPSHEETPAGEA
)psInfo
->proppage
[i
].hpage
;
265 /* Fixme: if resource ID is a string shall we use strcmp ??? */
266 if (lppsp
->u
.pszTemplate
== (LPVOID
)resId
)
273 /******************************************************************************
276 * Convert ASCII to Unicode since all data is saved as Unicode.
278 static void PROPSHEET_AtoW(LPCWSTR
*tostr
, LPCSTR frstr
)
283 TRACE("<%s>\n", frstr
);
284 len
= MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, 0, 0);
285 to
= Alloc(len
* sizeof(WCHAR
));
286 MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, to
, len
);
290 /******************************************************************************
291 * PROPSHEET_CollectSheetInfoCommon
293 * Common code for PROPSHEET_CollectSheetInfoA/W
295 static void PROPSHEET_CollectSheetInfoCommon(PropSheetInfo
* psInfo
, DWORD dwFlags
)
297 PROPSHEET_UnImplementedFlags(dwFlags
);
299 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
300 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
301 psInfo
->hasFinish
= dwFlags
& PSH_WIZARDHASFINISH
;
302 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
303 psInfo
->usePropPage
= dwFlags
& PSH_PROPSHEETPAGE
;
304 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
305 psInfo
->active_page
= 0;
308 psInfo
->hImageList
= 0;
309 psInfo
->activeValid
= FALSE
;
312 /******************************************************************************
313 * PROPSHEET_CollectSheetInfoA
315 * Collect relevant data.
317 static void PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh
,
318 PropSheetInfo
* psInfo
)
320 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERA
));
321 DWORD dwFlags
= lppsh
->dwFlags
;
323 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
)&& (lppsh
->pfnCallback
);
325 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
326 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",
327 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
,
328 debugstr_a(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
330 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
331 psInfo
->ppshheader
.pszCaption
= NULL
;
334 if (!IS_INTRESOURCE(lppsh
->pszCaption
))
336 int len
= MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, NULL
, 0);
337 WCHAR
*caption
= Alloc( len
*sizeof (WCHAR
) );
339 MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, caption
, len
);
340 psInfo
->ppshheader
.pszCaption
= caption
;
343 psInfo
->nPages
= lppsh
->nPages
;
345 if (dwFlags
& PSH_USEPSTARTPAGE
)
347 TRACE("PSH_USEPSTARTPAGE is on\n");
348 psInfo
->active_page
= 0;
351 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
353 PROPSHEET_CollectSheetInfoCommon(psInfo
, dwFlags
);
356 /******************************************************************************
357 * PROPSHEET_CollectSheetInfoW
359 * Collect relevant data.
361 static void PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
362 PropSheetInfo
* psInfo
)
364 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERW
));
365 DWORD dwFlags
= lppsh
->dwFlags
;
367 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
) && (lppsh
->pfnCallback
);
369 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
370 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",
371 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
, debugstr_w(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
373 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
374 psInfo
->ppshheader
.pszCaption
= NULL
;
377 if (!IS_INTRESOURCE(lppsh
->pszCaption
))
379 int len
= strlenW(lppsh
->pszCaption
);
380 WCHAR
*caption
= Alloc( (len
+1)*sizeof(WCHAR
) );
382 psInfo
->ppshheader
.pszCaption
= strcpyW( caption
, lppsh
->pszCaption
);
385 psInfo
->nPages
= lppsh
->nPages
;
387 if (dwFlags
& PSH_USEPSTARTPAGE
)
389 TRACE("PSH_USEPSTARTPAGE is on\n");
390 psInfo
->active_page
= 0;
393 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
395 PROPSHEET_CollectSheetInfoCommon(psInfo
, dwFlags
);
398 /******************************************************************************
399 * PROPSHEET_CollectPageInfo
401 * Collect property sheet data.
402 * With code taken from DIALOG_ParseTemplate32.
404 static BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
405 PropSheetInfo
* psInfo
,
406 int index
, BOOL resize
)
408 const DLGTEMPLATE
* pTemplate
;
417 psInfo
->proppage
[index
].hpage
= (HPROPSHEETPAGE
)lppsp
;
418 psInfo
->proppage
[index
].hwndPage
= 0;
419 psInfo
->proppage
[index
].isDirty
= FALSE
;
422 * Process property page flags.
424 dwFlags
= lppsp
->dwFlags
;
425 psInfo
->proppage
[index
].useCallback
= (dwFlags
& PSP_USECALLBACK
) && (lppsp
->pfnCallback
);
426 psInfo
->proppage
[index
].hasHelp
= dwFlags
& PSP_HASHELP
;
427 psInfo
->proppage
[index
].hasIcon
= dwFlags
& (PSP_USEHICON
| PSP_USEICONID
);
429 /* as soon as we have a page with the help flag, set the sheet flag on */
430 if (psInfo
->proppage
[index
].hasHelp
)
431 psInfo
->hasHelp
= TRUE
;
434 * Process page template.
436 if (dwFlags
& PSP_DLGINDIRECT
)
437 pTemplate
= lppsp
->u
.pResource
;
438 else if(dwFlags
& PSP_INTERNAL_UNICODE
)
440 HRSRC hResource
= FindResourceW(lppsp
->hInstance
,
441 lppsp
->u
.pszTemplate
,
443 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
445 pTemplate
= LockResource(hTemplate
);
449 HRSRC hResource
= FindResourceA(lppsp
->hInstance
,
450 (LPCSTR
)lppsp
->u
.pszTemplate
,
452 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
454 pTemplate
= LockResource(hTemplate
);
458 * Extract the size of the page and the caption.
463 p
= (const WORD
*)pTemplate
;
465 if (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
467 /* DLGTEMPLATEEX (not defined in any std. header file) */
471 p
+= 2; /* help ID */
472 p
+= 2; /* ext style */
480 p
+= 2; /* ext style */
486 width
= (WORD
)*p
; p
++;
487 height
= (WORD
)*p
; p
++;
489 /* Special calculation for interior wizard pages so the largest page is
490 * calculated correctly. We need to add all the padding and space occupied
491 * by the header so the width and height sums up to the whole wizard client
493 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
494 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
495 !(dwFlags
& PSP_HIDEHEADER
))
497 height
+= 2 * WIZARD_PADDING
+ WIZARD_HEADER_HEIGHT
;
498 width
+= 2 * WIZARD_PADDING
;
500 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
)
502 height
+= 2 * WIZARD_PADDING
;
503 width
+= 2 * WIZARD_PADDING
;
506 /* remember the largest width and height */
509 if (width
> psInfo
->width
)
510 psInfo
->width
= width
;
512 if (height
> psInfo
->height
)
513 psInfo
->height
= height
;
526 p
+= lstrlenW( p
) + 1;
540 p
+= lstrlenW( p
) + 1;
544 /* Extract the caption */
545 psInfo
->proppage
[index
].pszText
= p
;
546 TRACE("Tab %d %s\n",index
,debugstr_w( p
));
548 if (dwFlags
& PSP_USETITLE
)
552 static const WCHAR pszNull
[] = { '(','n','u','l','l',')',0 };
556 if (IS_INTRESOURCE( lppsp
->pszTitle
))
558 if (LoadStringW( lppsp
->hInstance
, (DWORD_PTR
)lppsp
->pszTitle
, szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0]) ))
566 pTitle
= lppsp
->pszTitle
;
568 len
= strlenW(pTitle
);
569 text
= Alloc( (len
+1)*sizeof (WCHAR
) );
570 psInfo
->proppage
[index
].pszText
= strcpyW( text
, pTitle
);
574 * Build the image list for icons
576 if ((dwFlags
& PSP_USEHICON
) || (dwFlags
& PSP_USEICONID
))
579 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
580 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
582 if (dwFlags
& PSP_USEICONID
)
583 hIcon
= LoadImageW(lppsp
->hInstance
, lppsp
->u2
.pszIcon
, IMAGE_ICON
,
584 icon_cx
, icon_cy
, LR_DEFAULTCOLOR
);
586 hIcon
= lppsp
->u2
.hIcon
;
590 if (psInfo
->hImageList
== 0 )
591 psInfo
->hImageList
= ImageList_Create(icon_cx
, icon_cy
, ILC_COLOR
, 1, 1);
593 ImageList_AddIcon(psInfo
->hImageList
, hIcon
);
601 /******************************************************************************
602 * PROPSHEET_CreateDialog
604 * Creates the actual property sheet.
606 static INT_PTR
PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
)
613 WORD resID
= IDD_PROPSHEET
;
615 TRACE("(%p)\n", psInfo
);
616 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
619 if( psInfo
->unicode
)
621 if(!(hRes
= FindResourceW(COMCTL32_hModule
,
622 MAKEINTRESOURCEW(resID
),
628 if(!(hRes
= FindResourceA(COMCTL32_hModule
,
629 MAKEINTRESOURCEA(resID
),
634 if(!(template = LoadResource(COMCTL32_hModule
, hRes
)))
638 * Make a copy of the dialog template.
640 resSize
= SizeofResource(COMCTL32_hModule
, hRes
);
642 temp
= Alloc(resSize
);
647 memcpy(temp
, template, resSize
);
649 if (psInfo
->ppshheader
.dwFlags
& PSH_NOCONTEXTHELP
)
651 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
652 ((MyDLGTEMPLATEEX
*)temp
)->style
&= ~DS_CONTEXTHELP
;
654 ((DLGTEMPLATE
*)temp
)->style
&= ~DS_CONTEXTHELP
;
656 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
657 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARDCONTEXTHELP
))
659 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
660 ((MyDLGTEMPLATEEX
*)temp
)->style
|= DS_CONTEXTHELP
;
662 ((DLGTEMPLATE
*)temp
)->style
|= DS_CONTEXTHELP
;
665 if (psInfo
->useCallback
)
666 (*(psInfo
->ppshheader
.pfnCallback
))(0, PSCB_PRECREATE
, (LPARAM
)temp
);
668 /* NOTE: MSDN states "Returns a positive value if successful, or -1
669 * otherwise for modal property sheets.", but this is wrong. The
670 * actual return value is either TRUE (success), FALSE (cancel) or
672 if( psInfo
->unicode
)
674 ret
= (INT_PTR
)CreateDialogIndirectParamW(psInfo
->ppshheader
.hInstance
,
675 temp
, psInfo
->ppshheader
.hwndParent
,
676 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
677 if ( !ret
) ret
= -1;
681 ret
= (INT_PTR
)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
682 temp
, psInfo
->ppshheader
.hwndParent
,
683 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
684 if ( !ret
) ret
= -1;
692 /******************************************************************************
693 * PROPSHEET_SizeMismatch
695 * Verify that the tab control and the "largest" property sheet page dlg. template
698 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
700 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
701 RECT rcOrigTab
, rcPage
;
706 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
707 TRACE("orig tab %s\n", wine_dbgstr_rect(&rcOrigTab
));
712 SetRect(&rcPage
, 0, 0, psInfo
->width
, psInfo
->height
);
713 MapDialogRect(hwndDlg
, &rcPage
);
714 TRACE("biggest page %s\n", wine_dbgstr_rect(&rcPage
));
716 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
718 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
724 /******************************************************************************
725 * PROPSHEET_AdjustSize
727 * Resizes the property sheet and the tab control to fit the largest page.
729 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
731 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
732 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
735 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
739 /* Get the height of buttons */
740 GetClientRect(hwndButton
, &rc
);
741 buttonHeight
= rc
.bottom
;
746 SetRect(&rc
, 0, 0, psInfo
->width
, psInfo
->height
);
747 MapDialogRect(hwndDlg
, &rc
);
749 /* retrieve the dialog units */
750 units
.left
= units
.right
= 4;
751 units
.top
= units
.bottom
= 8;
752 MapDialogRect(hwndDlg
, &units
);
755 * Resize the tab control.
757 GetClientRect(hwndTabCtrl
,&tabRect
);
759 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
761 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
763 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
764 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
767 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
769 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
770 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
773 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
777 TRACE("setting tab %p, rc (0,0)-(%d,%d)\n",
778 hwndTabCtrl
, rc
.right
, rc
.bottom
);
779 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
780 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
782 GetClientRect(hwndTabCtrl
, &rc
);
784 TRACE("tab client rc %s\n", wine_dbgstr_rect(&rc
));
786 rc
.right
+= (padding
.x
* 2);
787 rc
.bottom
+= buttonHeight
+ (3 * padding
.y
);
789 style
= GetWindowLongW(hwndDlg
, GWL_STYLE
);
790 if (!(style
& WS_CHILD
))
791 AdjustWindowRect(&rc
, style
, FALSE
);
797 * Resize the property sheet.
799 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
800 hwndDlg
, rc
.right
, rc
.bottom
);
801 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
802 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
806 /******************************************************************************
807 * PROPSHEET_AdjustSizeWizard
809 * Resizes the property sheet to fit the largest page.
811 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
813 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
814 RECT rc
, lineRect
, dialogRect
;
816 /* Biggest page size */
817 SetRect(&rc
, 0, 0, psInfo
->width
, psInfo
->height
);
818 MapDialogRect(hwndDlg
, &rc
);
820 TRACE("Biggest page %s\n", wine_dbgstr_rect(&rc
));
822 /* Add space for the buttons row */
823 GetWindowRect(hwndLine
, &lineRect
);
824 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
825 GetClientRect(hwndDlg
, &dialogRect
);
826 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
828 /* Convert the client coordinates to window coordinates */
829 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
831 /* Resize the property sheet */
832 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
833 hwndDlg
, rc
.right
, rc
.bottom
);
834 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
835 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
840 /******************************************************************************
841 * PROPSHEET_AdjustButtons
843 * Adjusts the buttons' positions.
845 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, const PropSheetInfo
* psInfo
)
847 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
851 int buttonWidth
, buttonHeight
;
852 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
854 if (psInfo
->hasApply
)
861 * Obtain the size of the buttons.
863 GetClientRect(hwndButton
, &rcSheet
);
864 buttonWidth
= rcSheet
.right
;
865 buttonHeight
= rcSheet
.bottom
;
868 * Get the size of the property sheet.
870 GetClientRect(hwndParent
, &rcSheet
);
873 * All buttons will be at this y coordinate.
875 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
878 * Position OK button and make it default.
880 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
882 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
884 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
885 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
887 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
891 * Position Cancel button.
893 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
895 x
+= padding
.x
+ buttonWidth
;
897 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
898 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
901 * Position Apply button.
903 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
906 x
+= padding
.x
+ buttonWidth
;
908 ShowWindow(hwndButton
, SW_HIDE
);
910 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
911 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
912 EnableWindow(hwndButton
, FALSE
);
915 * Position Help button.
917 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
919 x
+= padding
.x
+ buttonWidth
;
920 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
921 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
924 ShowWindow(hwndButton
, SW_HIDE
);
929 /******************************************************************************
930 * PROPSHEET_AdjustButtonsWizard
932 * Adjusts the buttons' positions.
934 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
935 const PropSheetInfo
* psInfo
)
937 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
938 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
939 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
943 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
944 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
948 if (psInfo
->hasFinish
)
952 * Obtain the size of the buttons.
954 GetClientRect(hwndButton
, &rcSheet
);
955 buttonWidth
= rcSheet
.right
;
956 buttonHeight
= rcSheet
.bottom
;
958 GetClientRect(hwndLine
, &rcSheet
);
959 lineHeight
= rcSheet
.bottom
;
962 * Get the size of the property sheet.
964 GetClientRect(hwndParent
, &rcSheet
);
967 * All buttons will be at this y coordinate.
969 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
972 * Position the Back button.
974 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
976 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1)) - buttonWidth
;
978 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
979 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
982 * Position the Next button.
984 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
988 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
989 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
992 * Position the Finish button.
994 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
996 if (psInfo
->hasFinish
)
997 x
+= padding
.x
+ buttonWidth
;
999 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1000 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1002 if (!psInfo
->hasFinish
)
1003 ShowWindow(hwndButton
, SW_HIDE
);
1006 * Position the Cancel button.
1008 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1010 x
+= padding
.x
+ buttonWidth
;
1012 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1013 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1016 * Position Help button.
1018 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1020 if (psInfo
->hasHelp
)
1022 x
+= padding
.x
+ buttonWidth
;
1024 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1025 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1028 ShowWindow(hwndButton
, SW_HIDE
);
1030 if (psInfo
->ppshheader
.dwFlags
&
1031 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1035 * Position and resize the sunken line.
1038 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1040 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1041 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1042 SWP_NOZORDER
| SWP_NOACTIVATE
);
1045 * Position and resize the header sunken line.
1048 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1049 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1050 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1051 ShowWindow(hwndLineHeader
, SW_HIDE
);
1056 /******************************************************************************
1057 * PROPSHEET_GetPaddingInfo
1059 * Returns the layout information.
1061 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1063 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1065 PADDING_INFO padding
;
1067 GetWindowRect(hwndTab
, &rcTab
);
1068 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rcTab
, 2 );
1070 padding
.x
= rcTab
.left
;
1071 padding
.y
= rcTab
.top
;
1076 /******************************************************************************
1077 * PROPSHEET_GetPaddingInfoWizard
1079 * Returns the layout information.
1080 * Vertical spacing is the distance between the line and the buttons.
1081 * Do NOT use the Help button to gather padding information when it isn't mapped
1082 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1083 * for it in this case !
1084 * FIXME: I'm not sure about any other coordinate problems with these evil
1085 * buttons. Fix it in case additional problems appear or maybe calculate
1086 * a padding in a completely different way, as this is somewhat messy.
1088 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1091 PADDING_INFO padding
;
1095 POINT ptButton
, ptLine
;
1098 if (psInfo
->hasHelp
)
1104 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1106 idButton
= IDC_NEXT_BUTTON
;
1110 /* hopefully this is ok */
1111 idButton
= IDCANCEL
;
1115 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1116 GetWindowRect(hwndControl
, &rc
);
1117 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1118 ptButton
.x
= rc
.left
;
1119 ptButton
.y
= rc
.top
;
1122 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1123 GetWindowRect(hwndControl
, &rc
);
1124 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1126 ptLine
.y
= rc
.bottom
;
1128 padding
.y
= ptButton
.y
- ptLine
.y
;
1131 ERR("padding negative ! Please report this !\n");
1133 /* this is most probably not correct, but the best we have now */
1134 padding
.x
= padding
.y
;
1138 /******************************************************************************
1139 * PROPSHEET_CreateTabControl
1141 * Insert the tabs in the tab control.
1143 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1144 const PropSheetInfo
* psInfo
)
1146 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1152 item
.mask
= TCIF_TEXT
;
1153 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1155 nTabs
= psInfo
->nPages
;
1158 * Set the image list for icons.
1160 if (psInfo
->hImageList
)
1162 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1165 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 0, 0);
1166 for (i
= 0; i
< nTabs
; i
++)
1168 if ( psInfo
->proppage
[i
].hasIcon
)
1170 item
.mask
|= TCIF_IMAGE
;
1171 item
.iImage
= iImage
++;
1175 item
.mask
&= ~TCIF_IMAGE
;
1178 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1179 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, i
, (LPARAM
)&item
);
1181 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 1, 0);
1186 /******************************************************************************
1187 * PROPSHEET_WizardSubclassProc
1189 * Subclassing window procedure for wizard exterior pages to prevent drawing
1190 * background and so drawing above the watermark.
1192 static LRESULT CALLBACK
1193 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1200 case WM_CTLCOLORSTATIC
:
1201 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1202 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1205 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1209 * Get the size of an in-memory Template
1211 *( Based on the code of PROPSHEET_CollectPageInfo)
1212 * See also dialog.c/DIALOG_ParseTemplate32().
1215 static UINT
GetTemplateSize(const DLGTEMPLATE
* pTemplate
)
1218 const WORD
* p
= (const WORD
*)pTemplate
;
1219 BOOL istemplateex
= (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1225 /* DLGTEMPLATEEX (not defined in any std. header file) */
1227 TRACE("is DLGTEMPLATEEX\n");
1229 p
++; /* signature */
1230 p
+= 2; /* help ID */
1231 p
+= 2; /* ext style */
1238 TRACE("is DLGTEMPLATE\n");
1240 p
+= 2; /* ext style */
1243 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1259 TRACE("menu %s\n",debugstr_w( p
));
1260 p
+= lstrlenW( p
) + 1;
1271 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1274 TRACE("class %s\n",debugstr_w( p
));
1275 p
+= lstrlenW( p
) + 1;
1280 TRACE("title %s\n",debugstr_w( p
));
1281 p
+= lstrlenW( p
) + 1;
1283 /* font, if DS_SETFONT set */
1284 if ((DS_SETFONT
& ((istemplateex
)? ((const MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1287 p
+=(istemplateex
)?3:1;
1288 TRACE("font %s\n",debugstr_w( p
));
1289 p
+= lstrlenW( p
) + 1; /* the font name */
1292 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1293 * that are following the DLGTEMPLATE(EX) data */
1294 TRACE("%d items\n",nrofitems
);
1295 while (nrofitems
> 0)
1297 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1300 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1309 TRACE("class ordinal 0x%08x\n",*(const DWORD
*)p
);
1313 TRACE("class %s\n",debugstr_w( p
));
1314 p
+= lstrlenW( p
) + 1;
1318 /* check title text */
1325 TRACE("text ordinal 0x%08x\n",*(const DWORD
*)p
);
1329 TRACE("text %s\n",debugstr_w( p
));
1330 p
+= lstrlenW( p
) + 1;
1333 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1337 ret
= (p
- (const WORD
*)pTemplate
) * sizeof(WORD
);
1338 TRACE("%p %p size 0x%08x\n", p
, pTemplate
, ret
);
1342 /******************************************************************************
1343 * PROPSHEET_CreatePage
1347 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1349 const PropSheetInfo
* psInfo
,
1350 LPCPROPSHEETPAGEW ppshpage
)
1352 const DLGTEMPLATE
* pTemplate
;
1355 DLGTEMPLATE
* pTemplateCopy
= NULL
;
1357 TRACE("index %d\n", index
);
1359 if (ppshpage
== NULL
)
1364 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1366 pTemplate
= ppshpage
->u
.pResource
;
1367 resSize
= GetTemplateSize(pTemplate
);
1369 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1374 hResource
= FindResourceW(ppshpage
->hInstance
,
1375 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
1396 hResource
= FindResourceA(ppshpage
->hInstance
,
1397 (LPCSTR
)ppshpage
->u
.pszTemplate
,
1402 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1404 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1408 pTemplate
= LockResource(hTemplate
);
1410 * Make a copy of the dialog template to make it writable
1413 pTemplateCopy
= Alloc(resSize
);
1417 TRACE("copying pTemplate %p into pTemplateCopy %p (%d)\n", pTemplate
, pTemplateCopy
, resSize
);
1418 memcpy(pTemplateCopy
, pTemplate
, resSize
);
1420 if (((MyDLGTEMPLATEEX
*)pTemplateCopy
)->signature
== 0xFFFF)
1422 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1423 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~DS_MODALFRAME
;
1424 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_CAPTION
;
1425 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_SYSMENU
;
1426 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_POPUP
;
1427 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_DISABLED
;
1428 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_VISIBLE
;
1429 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_THICKFRAME
;
1431 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->exStyle
|= WS_EX_CONTROLPARENT
;
1435 pTemplateCopy
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1436 pTemplateCopy
->style
&= ~DS_MODALFRAME
;
1437 pTemplateCopy
->style
&= ~WS_CAPTION
;
1438 pTemplateCopy
->style
&= ~WS_SYSMENU
;
1439 pTemplateCopy
->style
&= ~WS_POPUP
;
1440 pTemplateCopy
->style
&= ~WS_DISABLED
;
1441 pTemplateCopy
->style
&= ~WS_VISIBLE
;
1442 pTemplateCopy
->style
&= ~WS_THICKFRAME
;
1444 pTemplateCopy
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1447 if (psInfo
->proppage
[index
].useCallback
)
1448 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1449 (LPPROPSHEETPAGEW
)ppshpage
);
1451 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1452 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1455 ppshpage
->pfnDlgProc
,
1458 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1461 ppshpage
->pfnDlgProc
,
1463 /* Free a no more needed copy */
1464 Free(pTemplateCopy
);
1469 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1471 /* Subclass exterior wizard pages */
1472 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1473 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1474 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1476 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1477 (DWORD_PTR
)ppshpage
);
1479 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1480 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1485 /******************************************************************************
1486 * PROPSHEET_LoadWizardBitmaps
1488 * Loads the watermark and header bitmaps for a wizard.
1490 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1492 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1494 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1495 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1496 considers hbmWatermark as valid. */
1497 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1498 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1500 psInfo
->ppshheader
.u4
.hbmWatermark
=
1501 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1504 /* Same behavior as for watermarks */
1505 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1506 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1508 psInfo
->ppshheader
.u5
.hbmHeader
=
1509 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1515 /******************************************************************************
1516 * PROPSHEET_ShowPage
1518 * Displays or creates the specified page.
1520 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1523 HWND hwndLineHeader
;
1525 LPCPROPSHEETPAGEW ppshpage
;
1527 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1528 if (index
== psInfo
->active_page
)
1530 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1531 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1535 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1536 if (psInfo
->proppage
[index
].hwndPage
== 0)
1538 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1541 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1543 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1544 psInfo
->proppage
[index
].pszText
);
1546 control
= GetNextDlgTabItem(psInfo
->proppage
[index
].hwndPage
, NULL
, FALSE
);
1551 if (psInfo
->active_page
!= -1)
1552 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1554 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1556 /* Synchronize current selection with tab control
1557 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1558 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1559 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1561 psInfo
->active_page
= index
;
1562 psInfo
->activeValid
= TRUE
;
1564 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1566 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1567 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1569 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1570 ShowWindow(hwndLineHeader
, SW_HIDE
);
1572 ShowWindow(hwndLineHeader
, SW_SHOW
);
1578 /******************************************************************************
1581 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1585 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1589 TRACE("active_page %d\n", psInfo
->active_page
);
1590 if (psInfo
->active_page
< 0)
1593 psn
.hdr
.code
= PSN_WIZBACK
;
1594 psn
.hdr
.hwndFrom
= hwndDlg
;
1598 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1600 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1603 else if (result
== 0)
1604 idx
= psInfo
->active_page
- 1;
1606 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1608 if (idx
>= 0 && idx
< psInfo
->nPages
)
1610 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1612 SetFocus(GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
));
1613 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
1614 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1620 /******************************************************************************
1623 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1627 LRESULT msgResult
= 0;
1628 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1631 TRACE("active_page %d\n", psInfo
->active_page
);
1632 if (psInfo
->active_page
< 0)
1635 psn
.hdr
.code
= PSN_WIZNEXT
;
1636 psn
.hdr
.hwndFrom
= hwndDlg
;
1640 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1642 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1643 if (msgResult
== -1)
1645 else if (msgResult
== 0)
1646 idx
= psInfo
->active_page
+ 1;
1648 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1650 if (idx
< psInfo
->nPages
)
1652 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1654 SetFocus(GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
));
1655 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
1656 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1663 /******************************************************************************
1666 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1670 LRESULT msgResult
= 0;
1671 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1673 TRACE("active_page %d\n", psInfo
->active_page
);
1674 if (psInfo
->active_page
< 0)
1677 psn
.hdr
.code
= PSN_WIZFINISH
;
1678 psn
.hdr
.hwndFrom
= hwndDlg
;
1682 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1684 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1686 TRACE("msg result %ld\n", msgResult
);
1691 if (psInfo
->result
== 0)
1692 psInfo
->result
= IDOK
;
1693 if (psInfo
->isModeless
)
1694 psInfo
->activeValid
= FALSE
;
1696 psInfo
->ended
= TRUE
;
1701 /******************************************************************************
1704 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1709 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1711 TRACE("active_page %d\n", psInfo
->active_page
);
1712 if (psInfo
->active_page
< 0)
1715 psn
.hdr
.hwndFrom
= hwndDlg
;
1721 * Send PSN_KILLACTIVE to the current page.
1723 psn
.hdr
.code
= PSN_KILLACTIVE
;
1725 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1727 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1731 * Send PSN_APPLY to all pages.
1733 psn
.hdr
.code
= PSN_APPLY
;
1734 psn
.lParam
= lParam
;
1736 for (i
= 0; i
< psInfo
->nPages
; i
++)
1738 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1741 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1743 case PSNRET_INVALID
:
1744 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1746 case PSNRET_INVALID_NOCHANGEPAGE
:
1754 psInfo
->activeValid
= FALSE
;
1756 else if(psInfo
->active_page
>= 0)
1758 psn
.hdr
.code
= PSN_SETACTIVE
;
1760 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1761 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1767 /******************************************************************************
1770 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1772 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1777 TRACE("active_page %d\n", psInfo
->active_page
);
1778 if (psInfo
->active_page
< 0)
1781 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1782 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1783 psn
.hdr
.hwndFrom
= hwndDlg
;
1787 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1790 psn
.hdr
.code
= PSN_RESET
;
1791 psn
.lParam
= lParam
;
1793 for (i
= 0; i
< psInfo
->nPages
; i
++)
1795 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1798 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1801 if (psInfo
->isModeless
)
1803 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1804 psInfo
->activeValid
= FALSE
;
1807 psInfo
->ended
= TRUE
;
1810 /******************************************************************************
1813 static void PROPSHEET_Help(HWND hwndDlg
)
1815 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1819 TRACE("active_page %d\n", psInfo
->active_page
);
1820 if (psInfo
->active_page
< 0)
1823 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1824 psn
.hdr
.code
= PSN_HELP
;
1825 psn
.hdr
.hwndFrom
= hwndDlg
;
1829 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1832 /******************************************************************************
1835 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1838 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1841 if (!psInfo
) return;
1843 * Set the dirty flag of this page.
1845 for (i
= 0; i
< psInfo
->nPages
; i
++)
1847 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1848 psInfo
->proppage
[i
].isDirty
= TRUE
;
1852 * Enable the Apply button.
1854 if (psInfo
->hasApply
)
1856 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1858 EnableWindow(hwndApplyBtn
, TRUE
);
1862 /******************************************************************************
1863 * PROPSHEET_UnChanged
1865 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1868 BOOL noPageDirty
= TRUE
;
1869 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1870 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1873 if ( !psInfo
) return;
1874 for (i
= 0; i
< psInfo
->nPages
; i
++)
1876 /* set the specified page as clean */
1877 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1878 psInfo
->proppage
[i
].isDirty
= FALSE
;
1880 /* look to see if there are any dirty pages */
1881 if (psInfo
->proppage
[i
].isDirty
)
1882 noPageDirty
= FALSE
;
1886 * Disable Apply button.
1889 EnableWindow(hwndApplyBtn
, FALSE
);
1892 /******************************************************************************
1893 * PROPSHEET_PressButton
1895 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1897 TRACE("buttonID %d\n", buttonID
);
1900 case PSBTN_APPLYNOW
:
1901 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1904 PROPSHEET_Back(hwndDlg
);
1907 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1910 PROPSHEET_Finish(hwndDlg
);
1913 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1916 PROPSHEET_Next(hwndDlg
);
1919 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1922 FIXME("Invalid button index %d\n", buttonID
);
1927 /*************************************************************************
1928 * BOOL PROPSHEET_CanSetCurSel [Internal]
1930 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1933 * hwndDlg [I] handle to a Dialog hWnd
1936 * TRUE if Current Selection can change
1940 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
1942 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1953 TRACE("active_page %d\n", psInfo
->active_page
);
1954 if (psInfo
->active_page
< 0)
1961 * Notify the current page.
1963 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1964 psn
.hdr
.code
= PSN_KILLACTIVE
;
1965 psn
.hdr
.hwndFrom
= hwndDlg
;
1969 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1972 TRACE("<-- %d\n", res
);
1976 /******************************************************************************
1977 * PROPSHEET_SetCurSel
1979 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
1982 HPROPSHEETPAGE hpage
1985 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1986 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
1987 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1989 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
1991 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
1993 if (index
< 0 || index
>= psInfo
->nPages
)
1995 TRACE("Could not find page to select!\n");
1999 /* unset active page while doing this transition. */
2000 if (psInfo
->active_page
!= -1)
2001 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
2002 psInfo
->active_page
= -1;
2008 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2011 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
2013 psn
.hdr
.code
= PSN_SETACTIVE
;
2014 psn
.hdr
.hwndFrom
= hwndDlg
;
2018 if (!psInfo
->proppage
[index
].hwndPage
) {
2019 if(!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
)) {
2020 PROPSHEET_RemovePage(hwndDlg
, index
, NULL
);
2021 if(index
>= psInfo
->nPages
)
2029 /* Resize the property sheet page to the fit in the Tab control
2030 * (for regular property sheets) or to fit in the client area (for
2032 * NOTE: The resizing happens every time the page is selected and
2033 * not only when it's created (some applications depend on it). */
2034 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2035 TRACE("setting page %p, rc (%s) w=%d, h=%d\n",
2036 psInfo
->proppage
[index
].hwndPage
, wine_dbgstr_rect(&rc
),
2037 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2038 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2040 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2042 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2049 WARN("Tried to skip before first property sheet page!\n");
2052 if (index
>= psInfo
->nPages
) {
2053 WARN("Tried to skip after last property sheet page!\n");
2054 index
= psInfo
->nPages
-1;
2058 else if (result
!= 0)
2060 int old_index
= index
;
2061 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2062 if(index
>= psInfo
->nPages
) {
2064 WARN("Tried to skip to nonexistent page by res id\n");
2071 /* Invalidate the header area */
2072 if ( (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
2073 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
2075 HWND hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
2078 GetClientRect(hwndLineHeader
, &r
);
2079 MapWindowPoints(hwndLineHeader
, hwndDlg
, (LPPOINT
) &r
, 2);
2080 SetRect(&r
, 0, 0, r
.right
+ 1, r
.top
- 1);
2082 InvalidateRect(hwndDlg
, &r
, TRUE
);
2086 * Display the new page.
2088 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2090 if (psInfo
->proppage
[index
].hasHelp
)
2091 EnableWindow(hwndHelp
, TRUE
);
2093 EnableWindow(hwndHelp
, FALSE
);
2098 /******************************************************************************
2099 * PROPSHEET_SetCurSelId
2101 * Selects the page, specified by resource id.
2103 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2106 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2108 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2109 if (idx
< psInfo
->nPages
)
2111 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2112 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2116 /******************************************************************************
2117 * PROPSHEET_SetTitleA
2119 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2121 if(!IS_INTRESOURCE(lpszText
))
2124 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2125 szTitle
, sizeof(szTitle
)/sizeof(WCHAR
));
2126 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2130 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2134 /******************************************************************************
2135 * PROPSHEET_SetTitleW
2137 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2139 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2142 TRACE("%s (style %08x)\n", debugstr_w(lpszText
), dwStyle
);
2143 if (IS_INTRESOURCE(lpszText
)) {
2144 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2145 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0])))
2149 if (dwStyle
& PSH_PROPTITLE
)
2152 int lentitle
= strlenW(lpszText
);
2153 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2155 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2156 wsprintfW(dest
, psInfo
->strPropertiesFor
, lpszText
);
2158 SetWindowTextW(hwndDlg
, dest
);
2162 SetWindowTextW(hwndDlg
, lpszText
);
2165 /******************************************************************************
2166 * PROPSHEET_SetFinishTextA
2168 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2170 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2171 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2173 TRACE("'%s'\n", lpszText
);
2174 /* Set text, show and enable the Finish button */
2175 SetWindowTextA(hwndButton
, lpszText
);
2176 ShowWindow(hwndButton
, SW_SHOW
);
2177 EnableWindow(hwndButton
, TRUE
);
2179 /* Make it default pushbutton */
2180 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2182 /* Hide Back button */
2183 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2184 ShowWindow(hwndButton
, SW_HIDE
);
2186 if (!psInfo
->hasFinish
)
2188 /* Hide Next button */
2189 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2190 ShowWindow(hwndButton
, SW_HIDE
);
2194 /******************************************************************************
2195 * PROPSHEET_SetFinishTextW
2197 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2199 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2200 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2202 TRACE("%s\n", debugstr_w(lpszText
));
2203 /* Set text, show and enable the Finish button */
2204 SetWindowTextW(hwndButton
, lpszText
);
2205 ShowWindow(hwndButton
, SW_SHOW
);
2206 EnableWindow(hwndButton
, TRUE
);
2208 /* Make it default pushbutton */
2209 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2211 /* Hide Back button */
2212 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2213 ShowWindow(hwndButton
, SW_HIDE
);
2215 if (!psInfo
->hasFinish
)
2217 /* Hide Next button */
2218 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2219 ShowWindow(hwndButton
, SW_HIDE
);
2223 /******************************************************************************
2224 * PROPSHEET_QuerySiblings
2226 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2227 WPARAM wParam
, LPARAM lParam
)
2231 LRESULT msgResult
= 0;
2232 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2234 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2236 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2237 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2245 /******************************************************************************
2248 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
2249 HPROPSHEETPAGE hpage
)
2252 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2253 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2255 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2257 TRACE("hpage %p\n", hpage
);
2259 * Allocate and fill in a new PropPageInfo entry.
2261 ppi
= ReAlloc(psInfo
->proppage
, sizeof(PropPageInfo
) * (psInfo
->nPages
+ 1));
2265 psInfo
->proppage
= ppi
;
2266 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, psInfo
->nPages
, FALSE
))
2269 psInfo
->proppage
[psInfo
->nPages
].hpage
= hpage
;
2271 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2273 /* Create the page but don't show it */
2274 if(!PROPSHEET_CreatePage(hwndDlg
, psInfo
->nPages
, psInfo
, ppsp
))
2279 * Add a new tab to the tab control.
2281 item
.mask
= TCIF_TEXT
;
2282 item
.pszText
= (LPWSTR
) psInfo
->proppage
[psInfo
->nPages
].pszText
;
2283 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2285 if (psInfo
->hImageList
)
2287 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2290 if ( psInfo
->proppage
[psInfo
->nPages
].hasIcon
)
2292 item
.mask
|= TCIF_IMAGE
;
2293 item
.iImage
= psInfo
->nPages
;
2296 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, psInfo
->nPages
+ 1,
2301 /* If it is the only page - show it */
2302 if(psInfo
->nPages
== 1)
2303 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2307 /******************************************************************************
2308 * PROPSHEET_RemovePage
2310 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2312 HPROPSHEETPAGE hpage
)
2314 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2315 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2316 PropPageInfo
* oldPages
;
2318 TRACE("index %d, hpage %p\n", index
, hpage
);
2323 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
2325 /* Make sure that index is within range */
2326 if (index
< 0 || index
>= psInfo
->nPages
)
2328 TRACE("Could not find page to remove!\n");
2332 TRACE("total pages %d removing page %d active page %d\n",
2333 psInfo
->nPages
, index
, psInfo
->active_page
);
2335 * Check if we're removing the active page.
2337 if (index
== psInfo
->active_page
)
2339 if (psInfo
->nPages
> 1)
2343 /* activate previous page */
2344 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2348 /* activate the next page */
2349 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2350 psInfo
->active_page
= index
;
2355 psInfo
->active_page
= -1;
2356 if (!psInfo
->isModeless
)
2358 psInfo
->ended
= TRUE
;
2363 else if (index
< psInfo
->active_page
)
2364 psInfo
->active_page
--;
2366 /* Unsubclass the page dialog window */
2367 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2368 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2369 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2371 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2372 PROPSHEET_WizardSubclassProc
, 1);
2375 /* Destroy page dialog window */
2376 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2378 /* Free page resources */
2379 if(psInfo
->proppage
[index
].hpage
)
2381 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2383 if (psp
->dwFlags
& PSP_USETITLE
)
2384 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2386 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2389 /* Remove the tab */
2390 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2392 oldPages
= psInfo
->proppage
;
2394 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2397 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2399 if (index
< psInfo
->nPages
)
2400 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2401 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2408 /******************************************************************************
2409 * PROPSHEET_SetWizButtons
2411 * This code will work if (and assumes that) the Next button is on top of the
2412 * Finish button. ie. Finish comes after Next in the Z order.
2413 * This means make sure the dialog template reflects this.
2416 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2418 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2419 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2420 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2421 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2422 BOOL enable_finish
= ((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
);
2424 TRACE("%d\n", dwFlags
);
2426 EnableWindow(hwndBack
, dwFlags
& PSWIZB_BACK
);
2427 EnableWindow(hwndNext
, dwFlags
& PSWIZB_NEXT
);
2428 EnableWindow(hwndFinish
, enable_finish
);
2430 /* set the default pushbutton to an enabled button */
2432 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2433 else if (dwFlags
& PSWIZB_NEXT
)
2434 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2435 else if (dwFlags
& PSWIZB_BACK
)
2436 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
2438 SendMessageW(hwndDlg
, DM_SETDEFID
, IDCANCEL
, 0);
2440 if (!psInfo
->hasFinish
)
2442 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2444 /* Hide the Next button */
2445 ShowWindow(hwndNext
, SW_HIDE
);
2447 /* Show the Finish button */
2448 ShowWindow(hwndFinish
, SW_SHOW
);
2452 /* Hide the Finish button */
2453 ShowWindow(hwndFinish
, SW_HIDE
);
2454 /* Show the Next button */
2455 ShowWindow(hwndNext
, SW_SHOW
);
2460 /******************************************************************************
2461 * PROPSHEET_InsertPage
2463 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2465 if (IS_INTRESOURCE(hpageInsertAfter
))
2466 FIXME("(%p, %d, %p): stub\n", hwndDlg
, LOWORD(hpageInsertAfter
), hpage
);
2468 FIXME("(%p, %p, %p): stub\n", hwndDlg
, hpageInsertAfter
, hpage
);
2472 /******************************************************************************
2473 * PROPSHEET_SetHeaderTitleW
2475 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderTitle
)
2477 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderTitle
));
2480 /******************************************************************************
2481 * PROPSHEET_SetHeaderTitleA
2483 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderTitle
)
2485 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderTitle
));
2488 /******************************************************************************
2489 * PROPSHEET_SetHeaderSubTitleW
2491 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderSubTitle
)
2493 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderSubTitle
));
2496 /******************************************************************************
2497 * PROPSHEET_SetHeaderSubTitleA
2499 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderSubTitle
)
2501 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderSubTitle
));
2504 /******************************************************************************
2505 * PROPSHEET_HwndToIndex
2507 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2510 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2512 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2514 for (index
= 0; index
< psInfo
->nPages
; index
++)
2515 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2517 WARN("%p not found\n", hPageDlg
);
2521 /******************************************************************************
2522 * PROPSHEET_IndexToHwnd
2524 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2526 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2527 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2530 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2531 WARN("%d out of range.\n", iPageIndex
);
2534 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2537 /******************************************************************************
2538 * PROPSHEET_PageToIndex
2540 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2542 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2544 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2546 return PROPSHEET_GetPageIndex(hPage
, psInfo
, -1);
2549 /******************************************************************************
2550 * PROPSHEET_IndexToPage
2552 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2554 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2555 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2556 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2557 WARN("%d out of range.\n", iPageIndex
);
2560 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2563 /******************************************************************************
2564 * PROPSHEET_IdToIndex
2566 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2569 LPCPROPSHEETPAGEW psp
;
2570 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2571 TRACE("(%p, %d)\n", hwndDlg
, iPageId
);
2572 for (index
= 0; index
< psInfo
->nPages
; index
++) {
2573 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2574 if (psp
->u
.pszTemplate
== MAKEINTRESOURCEW(iPageId
))
2581 /******************************************************************************
2582 * PROPSHEET_IndexToId
2584 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2586 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2587 LPCPROPSHEETPAGEW psp
;
2588 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2589 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2590 WARN("%d out of range.\n", iPageIndex
);
2593 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2594 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| !IS_INTRESOURCE(psp
->u
.pszTemplate
)) {
2597 return (LRESULT
)psp
->u
.pszTemplate
;
2600 /******************************************************************************
2601 * PROPSHEET_GetResult
2603 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2605 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2606 return psInfo
->result
;
2609 /******************************************************************************
2610 * PROPSHEET_RecalcPageSizes
2612 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2614 FIXME("(%p): stub\n", hwndDlg
);
2618 /******************************************************************************
2619 * PROPSHEET_GetPageIndex
2621 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2622 * the array of PropPageInfo. If page is not found original index is used
2623 * (page takes precedence over index).
2625 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE page
, const PropSheetInfo
* psInfo
, int original_index
)
2629 TRACE("page %p index %d\n", page
, original_index
);
2631 for (index
= 0; index
< psInfo
->nPages
; index
++)
2632 if (psInfo
->proppage
[index
].hpage
== page
)
2635 return original_index
;
2638 /******************************************************************************
2641 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2644 PropSheetInfo
* psInfo
= RemovePropW(hwndDlg
, PropSheetInfoStr
);
2647 if (!psInfo
) return;
2648 if (!IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
))
2649 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2651 for (i
= 0; i
< psInfo
->nPages
; i
++)
2653 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2655 /* Unsubclass the page dialog window */
2656 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2657 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2658 (psp
->dwFlags
& PSP_HIDEHEADER
))
2660 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2661 PROPSHEET_WizardSubclassProc
, 1);
2664 if(psInfo
->proppage
[i
].hwndPage
)
2665 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2669 if (psp
->dwFlags
& PSP_USETITLE
)
2670 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2672 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2676 DeleteObject(psInfo
->hFont
);
2677 DeleteObject(psInfo
->hFontBold
);
2678 /* If we created the bitmaps, destroy them */
2679 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2680 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2681 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2682 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2683 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2684 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2686 Free(psInfo
->proppage
);
2687 Free(psInfo
->strPropertiesFor
);
2688 ImageList_Destroy(psInfo
->hImageList
);
2693 static INT
do_loop(const PropSheetInfo
*psInfo
)
2697 HWND hwnd
= psInfo
->hwnd
;
2698 HWND parent
= psInfo
->ppshheader
.hwndParent
;
2700 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2705 if(!IsDialogMessageW(hwnd
, &msg
))
2707 TranslateMessage(&msg
);
2708 DispatchMessageW(&msg
);
2714 PostQuitMessage(msg
.wParam
);
2719 ret
= psInfo
->result
;
2722 EnableWindow(parent
, TRUE
);
2724 DestroyWindow(hwnd
);
2728 /******************************************************************************
2729 * PROPSHEET_PropertySheet
2731 * Common code between PropertySheetA/W
2733 static INT_PTR
PROPSHEET_PropertySheet(PropSheetInfo
* psInfo
, BOOL unicode
)
2737 if (psInfo
->active_page
>= psInfo
->nPages
) psInfo
->active_page
= 0;
2738 TRACE("startpage: %d of %d pages\n", psInfo
->active_page
, psInfo
->nPages
);
2740 psInfo
->unicode
= unicode
;
2741 psInfo
->ended
= FALSE
;
2743 if(!psInfo
->isModeless
)
2745 parent
= psInfo
->ppshheader
.hwndParent
;
2746 if (parent
) EnableWindow(parent
, FALSE
);
2748 bRet
= PROPSHEET_CreateDialog(psInfo
);
2749 if(!psInfo
->isModeless
)
2750 bRet
= do_loop(psInfo
);
2754 /******************************************************************************
2755 * PropertySheet (COMCTL32.@)
2756 * PropertySheetA (COMCTL32.@)
2758 * Creates a property sheet in the specified property sheet header.
2761 * Modal property sheets: Positive if successful or -1 otherwise.
2762 * Modeless property sheets: Property sheet handle.
2764 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2765 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2767 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2769 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2773 TRACE("(%p)\n", lppsh
);
2775 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2777 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2778 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2780 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2782 if (!psInfo
->usePropPage
)
2783 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2786 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2787 pByte
+= ((LPCPROPSHEETPAGEA
)pByte
)->dwSize
;
2790 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2793 if (psInfo
->usePropPage
)
2794 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2800 return PROPSHEET_PropertySheet(psInfo
, FALSE
);
2803 /******************************************************************************
2804 * PropertySheetW (COMCTL32.@)
2806 * See PropertySheetA.
2808 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2810 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2814 TRACE("(%p)\n", lppsh
);
2816 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2818 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2819 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2821 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2823 if (!psInfo
->usePropPage
)
2824 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2827 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2828 pByte
+= ((LPCPROPSHEETPAGEW
)pByte
)->dwSize
;
2831 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2834 if (psInfo
->usePropPage
)
2835 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2841 return PROPSHEET_PropertySheet(psInfo
, TRUE
);
2844 static LPWSTR
load_string( HINSTANCE instance
, LPCWSTR str
)
2848 if (IS_INTRESOURCE(str
))
2853 WORD i
, id
= LOWORD(str
);
2856 if (!(hrsrc
= FindResourceW( instance
, MAKEINTRESOURCEW((id
>> 4) + 1), (LPWSTR
)RT_STRING
)))
2858 if (!(hmem
= LoadResource( instance
, hrsrc
))) return NULL
;
2859 if (!(ptr
= LockResource( hmem
))) return NULL
;
2860 for (i
= id
& 0x0f; i
> 0; i
--) ptr
+= *ptr
+ 1;
2862 if (!len
) return NULL
;
2863 ret
= Alloc( (len
+ 1) * sizeof(WCHAR
) );
2866 memcpy( ret
, ptr
+ 1, len
* sizeof(WCHAR
) );
2872 int len
= (strlenW(str
) + 1) * sizeof(WCHAR
);
2874 if (ret
) memcpy( ret
, str
, len
);
2880 /******************************************************************************
2881 * CreatePropertySheetPage (COMCTL32.@)
2882 * CreatePropertySheetPageA (COMCTL32.@)
2884 * Creates a new property sheet page.
2887 * Success: Handle to new property sheet page.
2891 * An application must use the PSM_ADDPAGE message to add the new page to
2892 * an existing property sheet.
2894 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2895 LPCPROPSHEETPAGEA lpPropSheetPage
)
2897 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2899 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEA
)));
2901 ppsp
->dwFlags
&= ~ PSP_INTERNAL_UNICODE
;
2903 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2905 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
2907 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
) + 1;
2908 char *template = Alloc( len
);
2910 ppsp
->u
.pszTemplate
= (LPWSTR
)strcpy( template, lpPropSheetPage
->u
.pszTemplate
);
2914 if (ppsp
->dwFlags
& PSP_USEICONID
)
2916 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
2917 PROPSHEET_AtoW(&ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2920 if (ppsp
->dwFlags
& PSP_USETITLE
)
2922 if (!IS_INTRESOURCE( ppsp
->pszTitle
))
2923 PROPSHEET_AtoW( &ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2925 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
2928 ppsp
->pszTitle
= NULL
;
2930 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
2931 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
2933 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
2935 if (!IS_INTRESOURCE( ppsp
->pszHeaderTitle
))
2936 PROPSHEET_AtoW(&ppsp
->pszHeaderTitle
, lpPropSheetPage
->pszHeaderTitle
);
2938 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
2941 ppsp
->pszHeaderTitle
= NULL
;
2943 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
2945 if (!IS_INTRESOURCE( ppsp
->pszHeaderSubTitle
))
2946 PROPSHEET_AtoW(&ppsp
->pszHeaderSubTitle
, lpPropSheetPage
->pszHeaderSubTitle
);
2948 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
2951 ppsp
->pszHeaderSubTitle
= NULL
;
2953 return (HPROPSHEETPAGE
)ppsp
;
2956 /******************************************************************************
2957 * CreatePropertySheetPageW (COMCTL32.@)
2959 * See CreatePropertySheetA.
2961 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
2963 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2965 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEW
)));
2967 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
2969 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2971 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
2973 int len
= strlenW(lpPropSheetPage
->u
.pszTemplate
) + 1;
2974 WCHAR
*template = Alloc( len
* sizeof (WCHAR
) );
2976 ppsp
->u
.pszTemplate
= strcpyW( template, lpPropSheetPage
->u
.pszTemplate
);
2980 if ( ppsp
->dwFlags
& PSP_USEICONID
)
2982 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
2984 int len
= strlenW(lpPropSheetPage
->u2
.pszIcon
) + 1;
2985 WCHAR
*icon
= Alloc( len
* sizeof (WCHAR
) );
2987 ppsp
->u2
.pszIcon
= strcpyW( icon
, lpPropSheetPage
->u2
.pszIcon
);
2991 if (ppsp
->dwFlags
& PSP_USETITLE
)
2992 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
2994 ppsp
->pszTitle
= NULL
;
2996 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
2997 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
2999 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3000 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3002 ppsp
->pszHeaderTitle
= NULL
;
3004 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3005 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3007 ppsp
->pszHeaderSubTitle
= NULL
;
3009 return (HPROPSHEETPAGE
)ppsp
;
3012 /******************************************************************************
3013 * DestroyPropertySheetPage (COMCTL32.@)
3015 * Destroys a property sheet page previously created with
3016 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
3023 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
3025 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3030 if (!(psp
->dwFlags
& PSP_DLGINDIRECT
) && !IS_INTRESOURCE( psp
->u
.pszTemplate
))
3031 Free ((LPVOID
)psp
->u
.pszTemplate
);
3033 if ((psp
->dwFlags
& PSP_USEICONID
) && !IS_INTRESOURCE( psp
->u2
.pszIcon
))
3034 Free ((LPVOID
)psp
->u2
.pszIcon
);
3036 if ((psp
->dwFlags
& PSP_USETITLE
) && !IS_INTRESOURCE( psp
->pszTitle
))
3037 Free ((LPVOID
)psp
->pszTitle
);
3039 if ((psp
->dwFlags
& PSP_USEHEADERTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderTitle
))
3040 Free ((LPVOID
)psp
->pszHeaderTitle
);
3042 if ((psp
->dwFlags
& PSP_USEHEADERSUBTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderSubTitle
))
3043 Free ((LPVOID
)psp
->pszHeaderSubTitle
);
3050 /******************************************************************************
3051 * PROPSHEET_IsDialogMessage
3053 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3055 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3058 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3061 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3064 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3066 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3068 switch (lpMsg
->wParam
)
3071 if (GetKeyState(VK_SHIFT
) & 0x8000)
3077 case VK_NEXT
: new_page
= 1; break;
3078 case VK_PRIOR
: new_page
= -1; break;
3084 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3086 new_page
+= psInfo
->active_page
;
3089 new_page
= psInfo
->nPages
- 1;
3090 else if (new_page
>= psInfo
->nPages
)
3093 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3100 return IsDialogMessageW(hwnd
, lpMsg
);
3103 /******************************************************************************
3104 * PROPSHEET_DoCommand
3106 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3112 case IDC_APPLY_BUTTON
:
3114 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3116 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3121 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3123 /* don't overwrite ID_PSRESTARTWINDOWS or ID_PSREBOOTSYSTEM */
3124 if (psInfo
->result
== 0)
3125 psInfo
->result
= IDOK
;
3127 if (psInfo
->isModeless
)
3128 psInfo
->activeValid
= FALSE
;
3130 psInfo
->ended
= TRUE
;
3133 EnableWindow(hwndApplyBtn
, FALSE
);
3138 case IDC_BACK_BUTTON
:
3139 PROPSHEET_Back(hwnd
);
3142 case IDC_NEXT_BUTTON
:
3143 PROPSHEET_Next(hwnd
);
3146 case IDC_FINISH_BUTTON
:
3147 PROPSHEET_Finish(hwnd
);
3151 PROPSHEET_Cancel(hwnd
, 0);
3155 PROPSHEET_Help(hwnd
);
3165 /******************************************************************************
3168 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3170 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3175 HPALETTE hOldPal
= 0;
3179 LPCPROPSHEETPAGEW ppshpage
;
3180 WCHAR szBuffer
[256];
3183 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3186 hdcSrc
= CreateCompatibleDC(0);
3188 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3189 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3191 if (psInfo
->active_page
< 0)
3194 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3196 if ( (ppshpage
&& !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3197 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3198 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3200 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3202 COLORREF clrOld
= 0;
3205 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3206 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3208 GetClientRect(hwndLineHeader
, &r
);
3209 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3210 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3212 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), &bm
);
3214 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3216 /* Fill the unoccupied part of the header with color of the
3217 * left-top pixel, but do it only when needed.
3219 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3221 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3222 CopyRect(&r
, &rzone
);
3223 if (bm
.bmWidth
< r
.right
)
3225 r
.left
= bm
.bmWidth
;
3226 FillRect(hdc
, &r
, hbr
);
3228 if (bm
.bmHeight
< r
.bottom
)
3231 r
.top
= bm
.bmHeight
;
3232 FillRect(hdc
, &r
, hbr
);
3237 /* Draw the header itself. */
3239 bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3240 hdcSrc
, 0, 0, SRCCOPY
);
3245 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3246 FillRect(hdc
, &rzone
, hbr
);
3248 /* Draw the header bitmap. It's always centered like a
3249 * common 49 x 49 bitmap. */
3250 margin
= (rzone
.bottom
- 49) / 2;
3251 BitBlt(hdc
, rzone
.right
- 49 - margin
, margin
,
3252 min(bm
.bmWidth
, 49), min(bm
.bmHeight
, 49),
3253 hdcSrc
, 0, 0, SRCCOPY
);
3255 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3256 * if its height is smaller than 49 pixels. Because the reason
3257 * for this bug is unknown the current code doesn't try to
3261 clrOld
= SetTextColor (hdc
, 0x00000000);
3262 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3264 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3265 SetRect(&r
, 20, 10, 0, 0);
3266 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3267 DrawTextW(hdc
, ppshpage
->pszHeaderTitle
, -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3270 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderTitle
,
3274 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3279 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3280 SelectObject(hdc
, psInfo
->hFont
);
3281 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3282 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3283 DrawTextW(hdc
, ppshpage
->pszHeaderSubTitle
, -1, &r
, DT_LEFT
| DT_WORDBREAK
);
3286 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderSubTitle
,
3290 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_WORDBREAK
);
3295 offsety
= rzone
.bottom
+ 2;
3297 SetTextColor(hdc
, clrOld
);
3298 SetBkMode(hdc
, oldBkMode
);
3299 SelectObject(hdc
, hOldFont
);
3300 SelectObject(hdcSrc
, hbmp
);
3303 if ( (ppshpage
&& (ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3304 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3305 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3307 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3309 GetClientRect(hwndLine
, &r
);
3310 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3311 SetRect(&rzone
, 0, 0, r
.right
, r
.top
- 1);
3313 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3314 FillRect(hdc
, &rzone
, hbr
);
3316 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), &bm
);
3317 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3319 /* The watermark is truncated to a width of 164 pixels */
3320 r
.right
= min(r
.right
, 164);
3321 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3322 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3324 /* If the bitmap is not big enough, fill the remaining area
3325 with the color of pixel (0,0) of bitmap - see MSDN */
3326 if (r
.top
> bm
.bmHeight
) {
3327 r
.bottom
= r
.top
- 1;
3328 r
.top
= bm
.bmHeight
;
3330 r
.right
= bm
.bmWidth
;
3331 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3332 FillRect(hdc
, &r
, hbr
);
3336 SelectObject(hdcSrc
, hbmp
);
3339 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3340 SelectPalette(hdc
, hOldPal
, FALSE
);
3344 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3349 /******************************************************************************
3350 * PROPSHEET_DialogProc
3352 static INT_PTR CALLBACK
3353 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3355 TRACE("hwnd=%p msg=0x%04x wparam=%lx lparam=%lx\n",
3356 hwnd
, uMsg
, wParam
, lParam
);
3362 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3363 WCHAR
* strCaption
= Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3364 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3368 /* Using PropSheetInfoStr to store extra data doesn't match the native
3369 * common control: native uses TCM_[GS]ETITEM
3371 SetPropW(hwnd
, PropSheetInfoStr
, psInfo
);
3374 * psInfo->hwnd is not being used by WINE code - it exists
3375 * for compatibility with "real" Windoze. The same about
3376 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3379 psInfo
->hwnd
= hwnd
;
3380 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3382 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3384 /* set up the Next and Back buttons by default */
3385 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3389 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3390 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3391 logFont
.lfWeight
= FW_BOLD
;
3392 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3395 * Small icon in the title bar.
3397 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3398 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3401 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3402 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3404 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3405 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3406 psInfo
->ppshheader
.u
.pszIcon
,
3411 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3413 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3416 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3417 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3419 psInfo
->strPropertiesFor
= strCaption
;
3421 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3423 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3425 PROPSHEET_LoadWizardBitmaps(psInfo
);
3427 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3429 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3430 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3431 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3432 SetFocus(GetDlgItem(hwnd
, IDC_NEXT_BUTTON
));
3436 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3438 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3439 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3441 SetFocus(GetDlgItem(hwnd
, IDOK
));
3444 if (IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
) &&
3445 psInfo
->ppshheader
.hInstance
)
3449 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3450 (UINT_PTR
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3451 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3455 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3456 psInfo
->ppshheader
.pszCaption
);
3460 if (psInfo
->useCallback
)
3461 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
, PSCB_INITIALIZED
, 0);
3463 idx
= psInfo
->active_page
;
3464 psInfo
->active_page
= -1;
3466 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3468 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3469 * as some programs call TCM_GETCURSEL to get the current selection
3470 * from which to switch to the next page */
3471 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3473 PROPSHEET_UnChanged(hwnd
, NULL
);
3475 /* wizards set their focus during init */
3476 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3482 case WM_PRINTCLIENT
:
3484 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3488 PROPSHEET_CleanUp(hwnd
);
3492 PROPSHEET_Cancel(hwnd
, 1);
3493 return FALSE
; /* let DefDlgProc post us WM_COMMAND/IDCANCEL */
3496 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3498 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3503 /* No default handler, forward notification to active page */
3504 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3506 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3507 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3514 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3516 if (pnmh
->code
== TCN_SELCHANGE
)
3518 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3519 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3522 if(pnmh
->code
== TCN_SELCHANGING
)
3524 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3525 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3532 case WM_SYSCOLORCHANGE
:
3533 COMCTL32_RefreshSysColors();
3536 case PSM_GETCURRENTPAGEHWND
:
3538 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3544 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3545 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3547 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3553 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3557 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3560 case PSM_GETTABCONTROL
:
3562 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3564 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3573 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3574 if(msgResult
!= FALSE
)
3576 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3579 (HPROPSHEETPAGE
)lParam
);
3582 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3587 case PSM_CANCELTOCLOSE
:
3589 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3590 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3591 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3593 EnableWindow(hwndCancel
, FALSE
);
3594 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, sizeof(buf
)/sizeof(buf
[0])))
3595 SetWindowTextW(hwndOK
, buf
);
3600 case PSM_RESTARTWINDOWS
:
3602 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3607 /* reboot system takes precedence over restart windows */
3608 if (psInfo
->result
!= ID_PSREBOOTSYSTEM
)
3609 psInfo
->result
= ID_PSRESTARTWINDOWS
;
3614 case PSM_REBOOTSYSTEM
:
3616 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3621 psInfo
->result
= ID_PSREBOOTSYSTEM
;
3627 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3631 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3636 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3638 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3643 case PSM_QUERYSIBLINGS
:
3645 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3647 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3655 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3656 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3657 * on success or FALSE otherwise, as specified on MSDN Online.
3658 * Also see the MFC code for
3659 * CPropertySheet::AddPage(CPropertyPage* pPage).
3662 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3664 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3669 case PSM_REMOVEPAGE
:
3670 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3673 case PSM_ISDIALOGMESSAGE
:
3675 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3676 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3680 case PSM_PRESSBUTTON
:
3681 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3684 case PSM_SETFINISHTEXTA
:
3685 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3688 case PSM_SETWIZBUTTONS
:
3689 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3692 case PSM_SETCURSELID
:
3693 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3696 case PSM_SETFINISHTEXTW
:
3697 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3700 case PSM_INSERTPAGE
:
3702 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3703 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3707 case PSM_SETHEADERTITLEW
:
3708 PROPSHEET_SetHeaderTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3711 case PSM_SETHEADERTITLEA
:
3712 PROPSHEET_SetHeaderTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3715 case PSM_SETHEADERSUBTITLEW
:
3716 PROPSHEET_SetHeaderSubTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3719 case PSM_SETHEADERSUBTITLEA
:
3720 PROPSHEET_SetHeaderSubTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3723 case PSM_HWNDTOINDEX
:
3725 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3726 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3730 case PSM_INDEXTOHWND
:
3732 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3733 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3737 case PSM_PAGETOINDEX
:
3739 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3740 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3744 case PSM_INDEXTOPAGE
:
3746 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3747 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3753 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3754 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3760 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3761 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3767 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3768 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3772 case PSM_RECALCPAGESIZES
:
3774 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3775 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);