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
59 #define NONAMELESSSTRUCT
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
));
714 rcPage
.right
= psInfo
->width
;
715 rcPage
.bottom
= psInfo
->height
;
717 MapDialogRect(hwndDlg
, &rcPage
);
718 TRACE("biggest page %s\n", wine_dbgstr_rect(&rcPage
));
720 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
722 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
728 /******************************************************************************
729 * PROPSHEET_AdjustSize
731 * Resizes the property sheet and the tab control to fit the largest page.
733 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
735 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
736 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
739 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
743 /* Get the height of buttons */
744 GetClientRect(hwndButton
, &rc
);
745 buttonHeight
= rc
.bottom
;
752 rc
.right
= psInfo
->width
;
753 rc
.bottom
= psInfo
->height
;
755 MapDialogRect(hwndDlg
, &rc
);
757 /* retrieve the dialog units */
758 units
.left
= units
.right
= 4;
759 units
.top
= units
.bottom
= 8;
760 MapDialogRect(hwndDlg
, &units
);
763 * Resize the tab control.
765 GetClientRect(hwndTabCtrl
,&tabRect
);
767 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
769 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
771 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
772 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
775 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
777 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
778 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
781 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
785 TRACE("setting tab %p, rc (0,0)-(%d,%d)\n",
786 hwndTabCtrl
, rc
.right
, rc
.bottom
);
787 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
788 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
790 GetClientRect(hwndTabCtrl
, &rc
);
792 TRACE("tab client rc %s\n", wine_dbgstr_rect(&rc
));
794 rc
.right
+= (padding
.x
* 2);
795 rc
.bottom
+= buttonHeight
+ (3 * padding
.y
);
797 style
= GetWindowLongW(hwndDlg
, GWL_STYLE
);
798 if (!(style
& WS_CHILD
))
799 AdjustWindowRect(&rc
, style
, FALSE
);
805 * Resize the property sheet.
807 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
808 hwndDlg
, rc
.right
, rc
.bottom
);
809 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
810 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
814 /******************************************************************************
815 * PROPSHEET_AdjustSizeWizard
817 * Resizes the property sheet to fit the largest page.
819 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
821 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
822 RECT rc
, lineRect
, dialogRect
;
824 /* Biggest page size */
827 rc
.right
= psInfo
->width
;
828 rc
.bottom
= psInfo
->height
;
829 MapDialogRect(hwndDlg
, &rc
);
831 TRACE("Biggest page %s\n", wine_dbgstr_rect(&rc
));
833 /* Add space for the buttons row */
834 GetWindowRect(hwndLine
, &lineRect
);
835 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
836 GetClientRect(hwndDlg
, &dialogRect
);
837 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
839 /* Convert the client coordinates to window coordinates */
840 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
842 /* Resize the property sheet */
843 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
844 hwndDlg
, rc
.right
, rc
.bottom
);
845 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
846 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
851 /******************************************************************************
852 * PROPSHEET_AdjustButtons
854 * Adjusts the buttons' positions.
856 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, const PropSheetInfo
* psInfo
)
858 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
862 int buttonWidth
, buttonHeight
;
863 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
865 if (psInfo
->hasApply
)
872 * Obtain the size of the buttons.
874 GetClientRect(hwndButton
, &rcSheet
);
875 buttonWidth
= rcSheet
.right
;
876 buttonHeight
= rcSheet
.bottom
;
879 * Get the size of the property sheet.
881 GetClientRect(hwndParent
, &rcSheet
);
884 * All buttons will be at this y coordinate.
886 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
889 * Position OK button and make it default.
891 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
893 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
895 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
896 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
898 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
902 * Position Cancel button.
904 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
906 x
+= padding
.x
+ buttonWidth
;
908 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
909 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
912 * Position Apply button.
914 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
917 x
+= padding
.x
+ buttonWidth
;
919 ShowWindow(hwndButton
, SW_HIDE
);
921 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
922 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
923 EnableWindow(hwndButton
, FALSE
);
926 * Position Help button.
928 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
930 x
+= padding
.x
+ buttonWidth
;
931 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
932 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
935 ShowWindow(hwndButton
, SW_HIDE
);
940 /******************************************************************************
941 * PROPSHEET_AdjustButtonsWizard
943 * Adjusts the buttons' positions.
945 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
946 const PropSheetInfo
* psInfo
)
948 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
949 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
950 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
954 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
955 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
959 if (psInfo
->hasFinish
)
963 * Obtain the size of the buttons.
965 GetClientRect(hwndButton
, &rcSheet
);
966 buttonWidth
= rcSheet
.right
;
967 buttonHeight
= rcSheet
.bottom
;
969 GetClientRect(hwndLine
, &rcSheet
);
970 lineHeight
= rcSheet
.bottom
;
973 * Get the size of the property sheet.
975 GetClientRect(hwndParent
, &rcSheet
);
978 * All buttons will be at this y coordinate.
980 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
983 * Position the Back button.
985 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
987 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1)) - buttonWidth
;
989 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
990 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
993 * Position the Next button.
995 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
999 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1000 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1003 * Position the Finish button.
1005 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
1007 if (psInfo
->hasFinish
)
1008 x
+= padding
.x
+ buttonWidth
;
1010 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1011 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1013 if (!psInfo
->hasFinish
)
1014 ShowWindow(hwndButton
, SW_HIDE
);
1017 * Position the Cancel button.
1019 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1021 x
+= padding
.x
+ buttonWidth
;
1023 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1024 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1027 * Position Help button.
1029 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1031 if (psInfo
->hasHelp
)
1033 x
+= padding
.x
+ buttonWidth
;
1035 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1036 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1039 ShowWindow(hwndButton
, SW_HIDE
);
1041 if (psInfo
->ppshheader
.dwFlags
&
1042 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1046 * Position and resize the sunken line.
1049 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1051 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1052 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1053 SWP_NOZORDER
| SWP_NOACTIVATE
);
1056 * Position and resize the header sunken line.
1059 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1060 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1061 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1062 ShowWindow(hwndLineHeader
, SW_HIDE
);
1067 /******************************************************************************
1068 * PROPSHEET_GetPaddingInfo
1070 * Returns the layout information.
1072 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1074 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1076 PADDING_INFO padding
;
1078 GetWindowRect(hwndTab
, &rcTab
);
1079 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rcTab
, 2 );
1081 padding
.x
= rcTab
.left
;
1082 padding
.y
= rcTab
.top
;
1087 /******************************************************************************
1088 * PROPSHEET_GetPaddingInfoWizard
1090 * Returns the layout information.
1091 * Vertical spacing is the distance between the line and the buttons.
1092 * Do NOT use the Help button to gather padding information when it isn't mapped
1093 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1094 * for it in this case !
1095 * FIXME: I'm not sure about any other coordinate problems with these evil
1096 * buttons. Fix it in case additional problems appear or maybe calculate
1097 * a padding in a completely different way, as this is somewhat messy.
1099 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1102 PADDING_INFO padding
;
1106 POINT ptButton
, ptLine
;
1109 if (psInfo
->hasHelp
)
1115 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1117 idButton
= IDC_NEXT_BUTTON
;
1121 /* hopefully this is ok */
1122 idButton
= IDCANCEL
;
1126 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1127 GetWindowRect(hwndControl
, &rc
);
1128 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1129 ptButton
.x
= rc
.left
;
1130 ptButton
.y
= rc
.top
;
1133 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1134 GetWindowRect(hwndControl
, &rc
);
1135 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1137 ptLine
.y
= rc
.bottom
;
1139 padding
.y
= ptButton
.y
- ptLine
.y
;
1142 ERR("padding negative ! Please report this !\n");
1144 /* this is most probably not correct, but the best we have now */
1145 padding
.x
= padding
.y
;
1149 /******************************************************************************
1150 * PROPSHEET_CreateTabControl
1152 * Insert the tabs in the tab control.
1154 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1155 const PropSheetInfo
* psInfo
)
1157 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1163 item
.mask
= TCIF_TEXT
;
1164 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1166 nTabs
= psInfo
->nPages
;
1169 * Set the image list for icons.
1171 if (psInfo
->hImageList
)
1173 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1176 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 0, 0);
1177 for (i
= 0; i
< nTabs
; i
++)
1179 if ( psInfo
->proppage
[i
].hasIcon
)
1181 item
.mask
|= TCIF_IMAGE
;
1182 item
.iImage
= iImage
++;
1186 item
.mask
&= ~TCIF_IMAGE
;
1189 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1190 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, i
, (LPARAM
)&item
);
1192 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 1, 0);
1197 /******************************************************************************
1198 * PROPSHEET_WizardSubclassProc
1200 * Subclassing window procedure for wizard exterior pages to prevent drawing
1201 * background and so drawing above the watermark.
1203 static LRESULT CALLBACK
1204 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1211 case WM_CTLCOLORSTATIC
:
1212 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1213 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1216 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1220 * Get the size of an in-memory Template
1222 *( Based on the code of PROPSHEET_CollectPageInfo)
1223 * See also dialog.c/DIALOG_ParseTemplate32().
1226 static UINT
GetTemplateSize(const DLGTEMPLATE
* pTemplate
)
1229 const WORD
* p
= (const WORD
*)pTemplate
;
1230 BOOL istemplateex
= (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1236 /* DLGTEMPLATEEX (not defined in any std. header file) */
1238 TRACE("is DLGTEMPLATEEX\n");
1240 p
++; /* signature */
1241 p
+= 2; /* help ID */
1242 p
+= 2; /* ext style */
1249 TRACE("is DLGTEMPLATE\n");
1251 p
+= 2; /* ext style */
1254 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1270 TRACE("menu %s\n",debugstr_w( p
));
1271 p
+= lstrlenW( p
) + 1;
1282 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1285 TRACE("class %s\n",debugstr_w( p
));
1286 p
+= lstrlenW( p
) + 1;
1291 TRACE("title %s\n",debugstr_w( p
));
1292 p
+= lstrlenW( p
) + 1;
1294 /* font, if DS_SETFONT set */
1295 if ((DS_SETFONT
& ((istemplateex
)? ((const MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1298 p
+=(istemplateex
)?3:1;
1299 TRACE("font %s\n",debugstr_w( p
));
1300 p
+= lstrlenW( p
) + 1; /* the font name */
1303 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1304 * that are following the DLGTEMPLATE(EX) data */
1305 TRACE("%d items\n",nrofitems
);
1306 while (nrofitems
> 0)
1308 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1311 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1320 TRACE("class ordinal 0x%08x\n",*(const DWORD
*)p
);
1324 TRACE("class %s\n",debugstr_w( p
));
1325 p
+= lstrlenW( p
) + 1;
1329 /* check title text */
1336 TRACE("text ordinal 0x%08x\n",*(const DWORD
*)p
);
1340 TRACE("text %s\n",debugstr_w( p
));
1341 p
+= lstrlenW( p
) + 1;
1344 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1348 ret
= (p
- (const WORD
*)pTemplate
) * sizeof(WORD
);
1349 TRACE("%p %p size 0x%08x\n", p
, pTemplate
, ret
);
1353 /******************************************************************************
1354 * PROPSHEET_CreatePage
1358 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1360 const PropSheetInfo
* psInfo
,
1361 LPCPROPSHEETPAGEW ppshpage
)
1363 const DLGTEMPLATE
* pTemplate
;
1366 DLGTEMPLATE
* pTemplateCopy
= NULL
;
1368 TRACE("index %d\n", index
);
1370 if (ppshpage
== NULL
)
1375 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1377 pTemplate
= ppshpage
->u
.pResource
;
1378 resSize
= GetTemplateSize(pTemplate
);
1380 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1385 hResource
= FindResourceW(ppshpage
->hInstance
,
1386 ppshpage
->u
.pszTemplate
,
1391 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1393 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1397 pTemplate
= LockResource(hTemplate
);
1399 * Make a copy of the dialog template to make it writable
1407 hResource
= FindResourceA(ppshpage
->hInstance
,
1408 (LPCSTR
)ppshpage
->u
.pszTemplate
,
1413 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1415 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1419 pTemplate
= LockResource(hTemplate
);
1421 * Make a copy of the dialog template to make it writable
1424 pTemplateCopy
= Alloc(resSize
);
1428 TRACE("copying pTemplate %p into pTemplateCopy %p (%d)\n", pTemplate
, pTemplateCopy
, resSize
);
1429 memcpy(pTemplateCopy
, pTemplate
, resSize
);
1431 if (((MyDLGTEMPLATEEX
*)pTemplateCopy
)->signature
== 0xFFFF)
1433 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1434 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~DS_MODALFRAME
;
1435 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_CAPTION
;
1436 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_SYSMENU
;
1437 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_POPUP
;
1438 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_DISABLED
;
1439 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_VISIBLE
;
1440 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_THICKFRAME
;
1442 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->exStyle
|= WS_EX_CONTROLPARENT
;
1446 pTemplateCopy
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1447 pTemplateCopy
->style
&= ~DS_MODALFRAME
;
1448 pTemplateCopy
->style
&= ~WS_CAPTION
;
1449 pTemplateCopy
->style
&= ~WS_SYSMENU
;
1450 pTemplateCopy
->style
&= ~WS_POPUP
;
1451 pTemplateCopy
->style
&= ~WS_DISABLED
;
1452 pTemplateCopy
->style
&= ~WS_VISIBLE
;
1453 pTemplateCopy
->style
&= ~WS_THICKFRAME
;
1455 pTemplateCopy
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1458 if (psInfo
->proppage
[index
].useCallback
)
1459 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1460 (LPPROPSHEETPAGEW
)ppshpage
);
1462 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1463 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1466 ppshpage
->pfnDlgProc
,
1469 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1472 ppshpage
->pfnDlgProc
,
1474 /* Free a no more needed copy */
1475 Free(pTemplateCopy
);
1480 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1482 /* Subclass exterior wizard pages */
1483 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1484 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1485 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1487 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1488 (DWORD_PTR
)ppshpage
);
1490 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1491 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1496 /******************************************************************************
1497 * PROPSHEET_LoadWizardBitmaps
1499 * Loads the watermark and header bitmaps for a wizard.
1501 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1503 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1505 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1506 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1507 considers hbmWatermark as valid. */
1508 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1509 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1511 psInfo
->ppshheader
.u4
.hbmWatermark
=
1512 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1515 /* Same behavior as for watermarks */
1516 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1517 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1519 psInfo
->ppshheader
.u5
.hbmHeader
=
1520 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1526 /******************************************************************************
1527 * PROPSHEET_ShowPage
1529 * Displays or creates the specified page.
1531 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1534 HWND hwndLineHeader
;
1536 LPCPROPSHEETPAGEW ppshpage
;
1538 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1539 if (index
== psInfo
->active_page
)
1541 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1542 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1546 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1547 if (psInfo
->proppage
[index
].hwndPage
== 0)
1549 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1552 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1554 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1555 psInfo
->proppage
[index
].pszText
);
1557 control
= GetNextDlgTabItem(psInfo
->proppage
[index
].hwndPage
, NULL
, FALSE
);
1562 if (psInfo
->active_page
!= -1)
1563 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1565 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1567 /* Synchronize current selection with tab control
1568 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1569 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1570 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1572 psInfo
->active_page
= index
;
1573 psInfo
->activeValid
= TRUE
;
1575 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1577 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1578 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1580 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1581 ShowWindow(hwndLineHeader
, SW_HIDE
);
1583 ShowWindow(hwndLineHeader
, SW_SHOW
);
1589 /******************************************************************************
1592 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1596 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1600 TRACE("active_page %d\n", psInfo
->active_page
);
1601 if (psInfo
->active_page
< 0)
1604 psn
.hdr
.code
= PSN_WIZBACK
;
1605 psn
.hdr
.hwndFrom
= hwndDlg
;
1609 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1611 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1614 else if (result
== 0)
1615 idx
= psInfo
->active_page
- 1;
1617 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1619 if (idx
>= 0 && idx
< psInfo
->nPages
)
1621 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1623 SetFocus(GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
));
1624 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
1625 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1631 /******************************************************************************
1634 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1638 LRESULT msgResult
= 0;
1639 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1642 TRACE("active_page %d\n", psInfo
->active_page
);
1643 if (psInfo
->active_page
< 0)
1646 psn
.hdr
.code
= PSN_WIZNEXT
;
1647 psn
.hdr
.hwndFrom
= hwndDlg
;
1651 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1653 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1654 if (msgResult
== -1)
1656 else if (msgResult
== 0)
1657 idx
= psInfo
->active_page
+ 1;
1659 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1661 if (idx
< psInfo
->nPages
)
1663 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1665 SetFocus(GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
));
1666 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
1667 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1674 /******************************************************************************
1677 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1681 LRESULT msgResult
= 0;
1682 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1684 TRACE("active_page %d\n", psInfo
->active_page
);
1685 if (psInfo
->active_page
< 0)
1688 psn
.hdr
.code
= PSN_WIZFINISH
;
1689 psn
.hdr
.hwndFrom
= hwndDlg
;
1693 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1695 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1697 TRACE("msg result %ld\n", msgResult
);
1702 if (psInfo
->result
== 0)
1703 psInfo
->result
= IDOK
;
1704 if (psInfo
->isModeless
)
1705 psInfo
->activeValid
= FALSE
;
1707 psInfo
->ended
= TRUE
;
1712 /******************************************************************************
1715 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1720 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1722 TRACE("active_page %d\n", psInfo
->active_page
);
1723 if (psInfo
->active_page
< 0)
1726 psn
.hdr
.hwndFrom
= hwndDlg
;
1732 * Send PSN_KILLACTIVE to the current page.
1734 psn
.hdr
.code
= PSN_KILLACTIVE
;
1736 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1738 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1742 * Send PSN_APPLY to all pages.
1744 psn
.hdr
.code
= PSN_APPLY
;
1745 psn
.lParam
= lParam
;
1747 for (i
= 0; i
< psInfo
->nPages
; i
++)
1749 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1752 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1754 case PSNRET_INVALID
:
1755 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1757 case PSNRET_INVALID_NOCHANGEPAGE
:
1765 psInfo
->activeValid
= FALSE
;
1767 else if(psInfo
->active_page
>= 0)
1769 psn
.hdr
.code
= PSN_SETACTIVE
;
1771 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1772 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1778 /******************************************************************************
1781 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1783 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1788 TRACE("active_page %d\n", psInfo
->active_page
);
1789 if (psInfo
->active_page
< 0)
1792 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1793 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1794 psn
.hdr
.hwndFrom
= hwndDlg
;
1798 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1801 psn
.hdr
.code
= PSN_RESET
;
1802 psn
.lParam
= lParam
;
1804 for (i
= 0; i
< psInfo
->nPages
; i
++)
1806 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1809 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1812 if (psInfo
->isModeless
)
1814 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1815 psInfo
->activeValid
= FALSE
;
1818 psInfo
->ended
= TRUE
;
1821 /******************************************************************************
1824 static void PROPSHEET_Help(HWND hwndDlg
)
1826 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1830 TRACE("active_page %d\n", psInfo
->active_page
);
1831 if (psInfo
->active_page
< 0)
1834 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1835 psn
.hdr
.code
= PSN_HELP
;
1836 psn
.hdr
.hwndFrom
= hwndDlg
;
1840 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1843 /******************************************************************************
1846 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1849 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1852 if (!psInfo
) return;
1854 * Set the dirty flag of this page.
1856 for (i
= 0; i
< psInfo
->nPages
; i
++)
1858 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1859 psInfo
->proppage
[i
].isDirty
= TRUE
;
1863 * Enable the Apply button.
1865 if (psInfo
->hasApply
)
1867 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1869 EnableWindow(hwndApplyBtn
, TRUE
);
1873 /******************************************************************************
1874 * PROPSHEET_UnChanged
1876 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1879 BOOL noPageDirty
= TRUE
;
1880 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1881 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1884 if ( !psInfo
) return;
1885 for (i
= 0; i
< psInfo
->nPages
; i
++)
1887 /* set the specified page as clean */
1888 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1889 psInfo
->proppage
[i
].isDirty
= FALSE
;
1891 /* look to see if there's any dirty pages */
1892 if (psInfo
->proppage
[i
].isDirty
)
1893 noPageDirty
= FALSE
;
1897 * Disable Apply button.
1900 EnableWindow(hwndApplyBtn
, FALSE
);
1903 /******************************************************************************
1904 * PROPSHEET_PressButton
1906 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1908 TRACE("buttonID %d\n", buttonID
);
1911 case PSBTN_APPLYNOW
:
1912 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1915 PROPSHEET_Back(hwndDlg
);
1918 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1921 PROPSHEET_Finish(hwndDlg
);
1924 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1927 PROPSHEET_Next(hwndDlg
);
1930 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1933 FIXME("Invalid button index %d\n", buttonID
);
1938 /*************************************************************************
1939 * BOOL PROPSHEET_CanSetCurSel [Internal]
1941 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1944 * hwndDlg [I] handle to a Dialog hWnd
1947 * TRUE if Current Selection can change
1951 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
1953 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1964 TRACE("active_page %d\n", psInfo
->active_page
);
1965 if (psInfo
->active_page
< 0)
1972 * Notify the current page.
1974 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1975 psn
.hdr
.code
= PSN_KILLACTIVE
;
1976 psn
.hdr
.hwndFrom
= hwndDlg
;
1980 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1983 TRACE("<-- %d\n", res
);
1987 /******************************************************************************
1988 * PROPSHEET_SetCurSel
1990 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
1993 HPROPSHEETPAGE hpage
1996 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1997 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
1998 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2000 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
2002 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
2004 if (index
< 0 || index
>= psInfo
->nPages
)
2006 TRACE("Could not find page to select!\n");
2010 /* unset active page while doing this transition. */
2011 if (psInfo
->active_page
!= -1)
2012 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
2013 psInfo
->active_page
= -1;
2019 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2022 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
2024 psn
.hdr
.code
= PSN_SETACTIVE
;
2025 psn
.hdr
.hwndFrom
= hwndDlg
;
2029 if (!psInfo
->proppage
[index
].hwndPage
) {
2030 if(!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
)) {
2031 PROPSHEET_RemovePage(hwndDlg
, index
, NULL
);
2032 if(index
>= psInfo
->nPages
)
2040 /* Resize the property sheet page to the fit in the Tab control
2041 * (for regular property sheets) or to fit in the client area (for
2043 * NOTE: The resizing happens every time the page is selected and
2044 * not only when it's created (some applications depend on it). */
2045 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2046 TRACE("setting page %p, rc (%s) w=%d, h=%d\n",
2047 psInfo
->proppage
[index
].hwndPage
, wine_dbgstr_rect(&rc
),
2048 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2049 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2051 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2053 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2060 WARN("Tried to skip before first property sheet page!\n");
2063 if (index
>= psInfo
->nPages
) {
2064 WARN("Tried to skip after last property sheet page!\n");
2065 index
= psInfo
->nPages
-1;
2069 else if (result
!= 0)
2071 int old_index
= index
;
2072 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2073 if(index
>= psInfo
->nPages
) {
2075 WARN("Tried to skip to nonexistent page by res id\n");
2082 /* Invalidate the header area */
2083 if ( (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
2084 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
2086 HWND hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
2089 GetClientRect(hwndLineHeader
, &r
);
2090 MapWindowPoints(hwndLineHeader
, hwndDlg
, (LPPOINT
) &r
, 2);
2091 SetRect(&r
, 0, 0, r
.right
+ 1, r
.top
- 1);
2093 InvalidateRect(hwndDlg
, &r
, TRUE
);
2097 * Display the new page.
2099 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2101 if (psInfo
->proppage
[index
].hasHelp
)
2102 EnableWindow(hwndHelp
, TRUE
);
2104 EnableWindow(hwndHelp
, FALSE
);
2109 /******************************************************************************
2110 * PROPSHEET_SetCurSelId
2112 * Selects the page, specified by resource id.
2114 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2117 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2119 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2120 if (idx
< psInfo
->nPages
)
2122 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2123 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2127 /******************************************************************************
2128 * PROPSHEET_SetTitleA
2130 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2132 if(!IS_INTRESOURCE(lpszText
))
2135 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2136 szTitle
, sizeof(szTitle
)/sizeof(WCHAR
));
2137 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2141 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2145 /******************************************************************************
2146 * PROPSHEET_SetTitleW
2148 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2150 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2153 TRACE("%s (style %08x)\n", debugstr_w(lpszText
), dwStyle
);
2154 if (IS_INTRESOURCE(lpszText
)) {
2155 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2156 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0])))
2160 if (dwStyle
& PSH_PROPTITLE
)
2163 int lentitle
= strlenW(lpszText
);
2164 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2166 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2167 wsprintfW(dest
, psInfo
->strPropertiesFor
, lpszText
);
2169 SetWindowTextW(hwndDlg
, dest
);
2173 SetWindowTextW(hwndDlg
, lpszText
);
2176 /******************************************************************************
2177 * PROPSHEET_SetFinishTextA
2179 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2181 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2182 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2184 TRACE("'%s'\n", lpszText
);
2185 /* Set text, show and enable the Finish button */
2186 SetWindowTextA(hwndButton
, lpszText
);
2187 ShowWindow(hwndButton
, SW_SHOW
);
2188 EnableWindow(hwndButton
, TRUE
);
2190 /* Make it default pushbutton */
2191 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2193 /* Hide Back button */
2194 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2195 ShowWindow(hwndButton
, SW_HIDE
);
2197 if (!psInfo
->hasFinish
)
2199 /* Hide Next button */
2200 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2201 ShowWindow(hwndButton
, SW_HIDE
);
2205 /******************************************************************************
2206 * PROPSHEET_SetFinishTextW
2208 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2210 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2211 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2213 TRACE("%s\n", debugstr_w(lpszText
));
2214 /* Set text, show and enable the Finish button */
2215 SetWindowTextW(hwndButton
, lpszText
);
2216 ShowWindow(hwndButton
, SW_SHOW
);
2217 EnableWindow(hwndButton
, TRUE
);
2219 /* Make it default pushbutton */
2220 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2222 /* Hide Back button */
2223 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2224 ShowWindow(hwndButton
, SW_HIDE
);
2226 if (!psInfo
->hasFinish
)
2228 /* Hide Next button */
2229 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2230 ShowWindow(hwndButton
, SW_HIDE
);
2234 /******************************************************************************
2235 * PROPSHEET_QuerySiblings
2237 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2238 WPARAM wParam
, LPARAM lParam
)
2242 LRESULT msgResult
= 0;
2243 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2245 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2247 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2248 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2256 /******************************************************************************
2259 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
2260 HPROPSHEETPAGE hpage
)
2263 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2264 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2266 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2268 TRACE("hpage %p\n", hpage
);
2270 * Allocate and fill in a new PropPageInfo entry.
2272 ppi
= ReAlloc(psInfo
->proppage
, sizeof(PropPageInfo
) * (psInfo
->nPages
+ 1));
2276 psInfo
->proppage
= ppi
;
2277 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, psInfo
->nPages
, FALSE
))
2280 psInfo
->proppage
[psInfo
->nPages
].hpage
= hpage
;
2282 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2284 /* Create the page but don't show it */
2285 if(!PROPSHEET_CreatePage(hwndDlg
, psInfo
->nPages
, psInfo
, ppsp
))
2290 * Add a new tab to the tab control.
2292 item
.mask
= TCIF_TEXT
;
2293 item
.pszText
= (LPWSTR
) psInfo
->proppage
[psInfo
->nPages
].pszText
;
2294 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2296 if (psInfo
->hImageList
)
2298 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2301 if ( psInfo
->proppage
[psInfo
->nPages
].hasIcon
)
2303 item
.mask
|= TCIF_IMAGE
;
2304 item
.iImage
= psInfo
->nPages
;
2307 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, psInfo
->nPages
+ 1,
2312 /* If it is the only page - show it */
2313 if(psInfo
->nPages
== 1)
2314 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2318 /******************************************************************************
2319 * PROPSHEET_RemovePage
2321 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2323 HPROPSHEETPAGE hpage
)
2325 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2326 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2327 PropPageInfo
* oldPages
;
2329 TRACE("index %d, hpage %p\n", index
, hpage
);
2334 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
2336 /* Make sure that index is within range */
2337 if (index
< 0 || index
>= psInfo
->nPages
)
2339 TRACE("Could not find page to remove!\n");
2343 TRACE("total pages %d removing page %d active page %d\n",
2344 psInfo
->nPages
, index
, psInfo
->active_page
);
2346 * Check if we're removing the active page.
2348 if (index
== psInfo
->active_page
)
2350 if (psInfo
->nPages
> 1)
2354 /* activate previous page */
2355 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2359 /* activate the next page */
2360 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2361 psInfo
->active_page
= index
;
2366 psInfo
->active_page
= -1;
2367 if (!psInfo
->isModeless
)
2369 psInfo
->ended
= TRUE
;
2374 else if (index
< psInfo
->active_page
)
2375 psInfo
->active_page
--;
2377 /* Unsubclass the page dialog window */
2378 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2379 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2380 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2382 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2383 PROPSHEET_WizardSubclassProc
, 1);
2386 /* Destroy page dialog window */
2387 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2389 /* Free page resources */
2390 if(psInfo
->proppage
[index
].hpage
)
2392 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2394 if (psp
->dwFlags
& PSP_USETITLE
)
2395 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2397 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2400 /* Remove the tab */
2401 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2403 oldPages
= psInfo
->proppage
;
2405 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2408 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2410 if (index
< psInfo
->nPages
)
2411 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2412 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2419 /******************************************************************************
2420 * PROPSHEET_SetWizButtons
2422 * This code will work if (and assumes that) the Next button is on top of the
2423 * Finish button. ie. Finish comes after Next in the Z order.
2424 * This means make sure the dialog template reflects this.
2427 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2429 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2430 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2431 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2432 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2434 TRACE("%d\n", dwFlags
);
2436 EnableWindow(hwndBack
, FALSE
);
2437 EnableWindow(hwndNext
, FALSE
);
2438 EnableWindow(hwndFinish
, FALSE
);
2440 /* set the default pushbutton to an enabled button */
2441 if (((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
))
2442 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2443 else if (dwFlags
& PSWIZB_NEXT
)
2444 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2445 else if (dwFlags
& PSWIZB_BACK
)
2446 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
2448 SendMessageW(hwndDlg
, DM_SETDEFID
, IDCANCEL
, 0);
2451 if (dwFlags
& PSWIZB_BACK
)
2452 EnableWindow(hwndBack
, TRUE
);
2454 if (dwFlags
& PSWIZB_NEXT
)
2455 EnableWindow(hwndNext
, TRUE
);
2457 if (!psInfo
->hasFinish
)
2459 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2461 /* Hide the Next button */
2462 ShowWindow(hwndNext
, SW_HIDE
);
2464 /* Show the Finish button */
2465 ShowWindow(hwndFinish
, SW_SHOW
);
2467 if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2468 EnableWindow(hwndFinish
, TRUE
);
2472 /* Hide the Finish button */
2473 ShowWindow(hwndFinish
, SW_HIDE
);
2474 /* Show the Next button */
2475 ShowWindow(hwndNext
, SW_SHOW
);
2478 else if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2479 EnableWindow(hwndFinish
, TRUE
);
2482 /******************************************************************************
2483 * PROPSHEET_InsertPage
2485 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2487 if (IS_INTRESOURCE(hpageInsertAfter
))
2488 FIXME("(%p, %d, %p): stub\n", hwndDlg
, LOWORD(hpageInsertAfter
), hpage
);
2490 FIXME("(%p, %p, %p): stub\n", hwndDlg
, hpageInsertAfter
, hpage
);
2494 /******************************************************************************
2495 * PROPSHEET_SetHeaderTitleW
2497 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderTitle
)
2499 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderTitle
));
2502 /******************************************************************************
2503 * PROPSHEET_SetHeaderTitleA
2505 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderTitle
)
2507 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderTitle
));
2510 /******************************************************************************
2511 * PROPSHEET_SetHeaderSubTitleW
2513 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderSubTitle
)
2515 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderSubTitle
));
2518 /******************************************************************************
2519 * PROPSHEET_SetHeaderSubTitleA
2521 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderSubTitle
)
2523 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderSubTitle
));
2526 /******************************************************************************
2527 * PROPSHEET_HwndToIndex
2529 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2532 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2534 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2536 for (index
= 0; index
< psInfo
->nPages
; index
++)
2537 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2539 WARN("%p not found\n", hPageDlg
);
2543 /******************************************************************************
2544 * PROPSHEET_IndexToHwnd
2546 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2548 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2549 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2552 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2553 WARN("%d out of range.\n", iPageIndex
);
2556 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2559 /******************************************************************************
2560 * PROPSHEET_PageToIndex
2562 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2565 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2567 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2569 for (index
= 0; index
< psInfo
->nPages
; index
++)
2570 if (psInfo
->proppage
[index
].hpage
== hPage
)
2572 WARN("%p not found\n", hPage
);
2576 /******************************************************************************
2577 * PROPSHEET_IndexToPage
2579 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2581 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2582 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2583 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2584 WARN("%d out of range.\n", iPageIndex
);
2587 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2590 /******************************************************************************
2591 * PROPSHEET_IdToIndex
2593 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2596 LPCPROPSHEETPAGEW psp
;
2597 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2598 TRACE("(%p, %d)\n", hwndDlg
, iPageId
);
2599 for (index
= 0; index
< psInfo
->nPages
; index
++) {
2600 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2601 if (psp
->u
.pszTemplate
== MAKEINTRESOURCEW(iPageId
))
2608 /******************************************************************************
2609 * PROPSHEET_IndexToId
2611 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2613 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2614 LPCPROPSHEETPAGEW psp
;
2615 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2616 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2617 WARN("%d out of range.\n", iPageIndex
);
2620 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2621 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| !IS_INTRESOURCE(psp
->u
.pszTemplate
)) {
2624 return (LRESULT
)psp
->u
.pszTemplate
;
2627 /******************************************************************************
2628 * PROPSHEET_GetResult
2630 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2632 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2633 return psInfo
->result
;
2636 /******************************************************************************
2637 * PROPSHEET_RecalcPageSizes
2639 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2641 FIXME("(%p): stub\n", hwndDlg
);
2645 /******************************************************************************
2646 * PROPSHEET_GetPageIndex
2648 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2649 * the array of PropPageInfo. If page is not found original index is used
2650 * (page takes precedence over index).
2652 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE page
, const PropSheetInfo
* psInfo
, int original_index
)
2656 TRACE("page %p index %d\n", page
, original_index
);
2658 for (index
= 0; index
< psInfo
->nPages
; index
++)
2659 if (psInfo
->proppage
[index
].hpage
== page
)
2662 return original_index
;
2665 /******************************************************************************
2668 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2671 PropSheetInfo
* psInfo
= RemovePropW(hwndDlg
, PropSheetInfoStr
);
2674 if (!psInfo
) return;
2675 if (!IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
))
2676 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2678 for (i
= 0; i
< psInfo
->nPages
; i
++)
2680 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2682 /* Unsubclass the page dialog window */
2683 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2684 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2685 (psp
->dwFlags
& PSP_HIDEHEADER
))
2687 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2688 PROPSHEET_WizardSubclassProc
, 1);
2691 if(psInfo
->proppage
[i
].hwndPage
)
2692 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2696 if (psp
->dwFlags
& PSP_USETITLE
)
2697 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2699 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2703 DeleteObject(psInfo
->hFont
);
2704 DeleteObject(psInfo
->hFontBold
);
2705 /* If we created the bitmaps, destroy them */
2706 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2707 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2708 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2709 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2710 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2711 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2713 Free(psInfo
->proppage
);
2714 Free(psInfo
->strPropertiesFor
);
2715 ImageList_Destroy(psInfo
->hImageList
);
2720 static INT
do_loop(const PropSheetInfo
*psInfo
)
2724 HWND hwnd
= psInfo
->hwnd
;
2726 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2731 if(!IsDialogMessageW(hwnd
, &msg
))
2733 TranslateMessage(&msg
);
2734 DispatchMessageW(&msg
);
2740 PostQuitMessage(msg
.wParam
);
2745 ret
= psInfo
->result
;
2747 DestroyWindow(hwnd
);
2751 /******************************************************************************
2752 * PROPSHEET_PropertySheet
2754 * Common code between PropertySheetA/W
2756 static INT_PTR
PROPSHEET_PropertySheet(PropSheetInfo
* psInfo
, BOOL unicode
)
2760 if (psInfo
->active_page
>= psInfo
->nPages
) psInfo
->active_page
= 0;
2761 TRACE("startpage: %d of %d pages\n", psInfo
->active_page
, psInfo
->nPages
);
2763 psInfo
->unicode
= unicode
;
2764 psInfo
->ended
= FALSE
;
2766 if(!psInfo
->isModeless
)
2768 parent
= psInfo
->ppshheader
.hwndParent
;
2769 if (parent
) EnableWindow(parent
, FALSE
);
2771 bRet
= PROPSHEET_CreateDialog(psInfo
);
2772 if(!psInfo
->isModeless
)
2774 bRet
= do_loop(psInfo
);
2775 if (parent
) EnableWindow(parent
, TRUE
);
2780 /******************************************************************************
2781 * PropertySheet (COMCTL32.@)
2782 * PropertySheetA (COMCTL32.@)
2784 * Creates a property sheet in the specified property sheet header.
2787 * Modal property sheets: Positive if successful or -1 otherwise.
2788 * Modeless property sheets: Property sheet handle.
2790 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2791 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2793 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2795 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2799 TRACE("(%p)\n", lppsh
);
2801 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2803 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2804 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2806 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2808 if (!psInfo
->usePropPage
)
2809 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2812 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2813 pByte
+= ((LPCPROPSHEETPAGEA
)pByte
)->dwSize
;
2816 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2819 if (psInfo
->usePropPage
)
2820 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2826 return PROPSHEET_PropertySheet(psInfo
, FALSE
);
2829 /******************************************************************************
2830 * PropertySheetW (COMCTL32.@)
2832 * See PropertySheetA.
2834 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2836 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2840 TRACE("(%p)\n", lppsh
);
2842 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2844 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2845 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2847 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2849 if (!psInfo
->usePropPage
)
2850 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2853 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2854 pByte
+= ((LPCPROPSHEETPAGEW
)pByte
)->dwSize
;
2857 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2860 if (psInfo
->usePropPage
)
2861 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2867 return PROPSHEET_PropertySheet(psInfo
, TRUE
);
2870 static LPWSTR
load_string( HINSTANCE instance
, LPCWSTR str
)
2874 if (IS_INTRESOURCE(str
))
2879 WORD i
, id
= LOWORD(str
);
2882 if (!(hrsrc
= FindResourceW( instance
, MAKEINTRESOURCEW((id
>> 4) + 1), (LPWSTR
)RT_STRING
)))
2884 if (!(hmem
= LoadResource( instance
, hrsrc
))) return NULL
;
2885 if (!(ptr
= LockResource( hmem
))) return NULL
;
2886 for (i
= id
& 0x0f; i
> 0; i
--) ptr
+= *ptr
+ 1;
2888 if (!len
) return NULL
;
2889 ret
= Alloc( (len
+ 1) * sizeof(WCHAR
) );
2892 memcpy( ret
, ptr
+ 1, len
* sizeof(WCHAR
) );
2898 int len
= (strlenW(str
) + 1) * sizeof(WCHAR
);
2900 if (ret
) memcpy( ret
, str
, len
);
2906 /******************************************************************************
2907 * CreatePropertySheetPage (COMCTL32.@)
2908 * CreatePropertySheetPageA (COMCTL32.@)
2910 * Creates a new property sheet page.
2913 * Success: Handle to new property sheet page.
2917 * An application must use the PSM_ADDPAGE message to add the new page to
2918 * an existing property sheet.
2920 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2921 LPCPROPSHEETPAGEA lpPropSheetPage
)
2923 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2925 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEA
)));
2927 ppsp
->dwFlags
&= ~ PSP_INTERNAL_UNICODE
;
2929 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2931 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
2933 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
) + 1;
2934 char *template = Alloc( len
);
2936 ppsp
->u
.pszTemplate
= (LPWSTR
)strcpy( template, lpPropSheetPage
->u
.pszTemplate
);
2940 if (ppsp
->dwFlags
& PSP_USEICONID
)
2942 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
2943 PROPSHEET_AtoW(&ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2946 if (ppsp
->dwFlags
& PSP_USETITLE
)
2948 if (!IS_INTRESOURCE( ppsp
->pszTitle
))
2949 PROPSHEET_AtoW( &ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2951 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
2954 ppsp
->pszTitle
= NULL
;
2956 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
2957 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
2959 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
2961 if (!IS_INTRESOURCE( ppsp
->pszHeaderTitle
))
2962 PROPSHEET_AtoW(&ppsp
->pszHeaderTitle
, lpPropSheetPage
->pszHeaderTitle
);
2964 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
2967 ppsp
->pszHeaderTitle
= NULL
;
2969 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
2971 if (!IS_INTRESOURCE( ppsp
->pszHeaderSubTitle
))
2972 PROPSHEET_AtoW(&ppsp
->pszHeaderSubTitle
, lpPropSheetPage
->pszHeaderSubTitle
);
2974 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
2977 ppsp
->pszHeaderSubTitle
= NULL
;
2979 return (HPROPSHEETPAGE
)ppsp
;
2982 /******************************************************************************
2983 * CreatePropertySheetPageW (COMCTL32.@)
2985 * See CreatePropertySheetA.
2987 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
2989 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2991 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEW
)));
2993 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
2995 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2997 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
2999 int len
= strlenW(lpPropSheetPage
->u
.pszTemplate
) + 1;
3000 WCHAR
*template = Alloc( len
* sizeof (WCHAR
) );
3002 ppsp
->u
.pszTemplate
= strcpyW( template, lpPropSheetPage
->u
.pszTemplate
);
3006 if ( ppsp
->dwFlags
& PSP_USEICONID
)
3008 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
3010 int len
= strlenW(lpPropSheetPage
->u2
.pszIcon
) + 1;
3011 WCHAR
*icon
= Alloc( len
* sizeof (WCHAR
) );
3013 ppsp
->u2
.pszIcon
= strcpyW( icon
, lpPropSheetPage
->u2
.pszIcon
);
3017 if (ppsp
->dwFlags
& PSP_USETITLE
)
3018 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3020 ppsp
->pszTitle
= NULL
;
3022 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3023 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3025 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3026 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3028 ppsp
->pszHeaderTitle
= NULL
;
3030 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3031 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3033 ppsp
->pszHeaderSubTitle
= NULL
;
3035 return (HPROPSHEETPAGE
)ppsp
;
3038 /******************************************************************************
3039 * DestroyPropertySheetPage (COMCTL32.@)
3041 * Destroys a property sheet page previously created with
3042 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
3049 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
3051 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3056 if (!(psp
->dwFlags
& PSP_DLGINDIRECT
) && !IS_INTRESOURCE( psp
->u
.pszTemplate
))
3057 Free ((LPVOID
)psp
->u
.pszTemplate
);
3059 if ((psp
->dwFlags
& PSP_USEICONID
) && !IS_INTRESOURCE( psp
->u2
.pszIcon
))
3060 Free ((LPVOID
)psp
->u2
.pszIcon
);
3062 if ((psp
->dwFlags
& PSP_USETITLE
) && !IS_INTRESOURCE( psp
->pszTitle
))
3063 Free ((LPVOID
)psp
->pszTitle
);
3065 if ((psp
->dwFlags
& PSP_USEHEADERTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderTitle
))
3066 Free ((LPVOID
)psp
->pszHeaderTitle
);
3068 if ((psp
->dwFlags
& PSP_USEHEADERSUBTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderSubTitle
))
3069 Free ((LPVOID
)psp
->pszHeaderSubTitle
);
3076 /******************************************************************************
3077 * PROPSHEET_IsDialogMessage
3079 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3081 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3084 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3087 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3090 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3092 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3094 switch (lpMsg
->wParam
)
3097 if (GetKeyState(VK_SHIFT
) & 0x8000)
3103 case VK_NEXT
: new_page
= 1; break;
3104 case VK_PRIOR
: new_page
= -1; break;
3110 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3112 new_page
+= psInfo
->active_page
;
3115 new_page
= psInfo
->nPages
- 1;
3116 else if (new_page
>= psInfo
->nPages
)
3119 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3126 return IsDialogMessageW(hwnd
, lpMsg
);
3129 /******************************************************************************
3130 * PROPSHEET_DoCommand
3132 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3138 case IDC_APPLY_BUTTON
:
3140 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3142 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3147 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3149 /* don't overwrite ID_PSRESTARTWINDOWS or ID_PSREBOOTSYSTEM */
3150 if (psInfo
->result
== 0)
3151 psInfo
->result
= IDOK
;
3153 if (psInfo
->isModeless
)
3154 psInfo
->activeValid
= FALSE
;
3156 psInfo
->ended
= TRUE
;
3159 EnableWindow(hwndApplyBtn
, FALSE
);
3164 case IDC_BACK_BUTTON
:
3165 PROPSHEET_Back(hwnd
);
3168 case IDC_NEXT_BUTTON
:
3169 PROPSHEET_Next(hwnd
);
3172 case IDC_FINISH_BUTTON
:
3173 PROPSHEET_Finish(hwnd
);
3177 PROPSHEET_Cancel(hwnd
, 0);
3181 PROPSHEET_Help(hwnd
);
3191 /******************************************************************************
3194 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3196 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3201 HPALETTE hOldPal
= 0;
3205 LPCPROPSHEETPAGEW ppshpage
;
3206 WCHAR szBuffer
[256];
3209 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3212 hdcSrc
= CreateCompatibleDC(0);
3214 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3215 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3217 if (psInfo
->active_page
< 0)
3220 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3222 if ( (ppshpage
&& !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3223 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3224 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3226 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3228 COLORREF clrOld
= 0;
3231 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3232 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3234 GetClientRect(hwndLineHeader
, &r
);
3235 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3236 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3238 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), &bm
);
3240 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3242 /* Fill the unoccupied part of the header with color of the
3243 * left-top pixel, but do it only when needed.
3245 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3247 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3248 CopyRect(&r
, &rzone
);
3249 if (bm
.bmWidth
< r
.right
)
3251 r
.left
= bm
.bmWidth
;
3252 FillRect(hdc
, &r
, hbr
);
3254 if (bm
.bmHeight
< r
.bottom
)
3257 r
.top
= bm
.bmHeight
;
3258 FillRect(hdc
, &r
, hbr
);
3263 /* Draw the header itself. */
3265 bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3266 hdcSrc
, 0, 0, SRCCOPY
);
3271 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3272 FillRect(hdc
, &rzone
, hbr
);
3274 /* Draw the header bitmap. It's always centered like a
3275 * common 49 x 49 bitmap. */
3276 margin
= (rzone
.bottom
- 49) / 2;
3277 BitBlt(hdc
, rzone
.right
- 49 - margin
, margin
,
3278 min(bm
.bmWidth
, 49), min(bm
.bmHeight
, 49),
3279 hdcSrc
, 0, 0, SRCCOPY
);
3281 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3282 * if its height is smaller than 49 pixels. Because the reason
3283 * for this bug is unknown the current code doesn't try to
3287 clrOld
= SetTextColor (hdc
, 0x00000000);
3288 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3290 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3291 SetRect(&r
, 20, 10, 0, 0);
3292 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3293 DrawTextW(hdc
, ppshpage
->pszHeaderTitle
, -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3296 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderTitle
,
3300 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3305 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3306 SelectObject(hdc
, psInfo
->hFont
);
3307 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3308 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3309 DrawTextW(hdc
, ppshpage
->pszHeaderSubTitle
, -1, &r
, DT_LEFT
| DT_WORDBREAK
);
3312 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderSubTitle
,
3316 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_WORDBREAK
);
3321 offsety
= rzone
.bottom
+ 2;
3323 SetTextColor(hdc
, clrOld
);
3324 SetBkMode(hdc
, oldBkMode
);
3325 SelectObject(hdc
, hOldFont
);
3326 SelectObject(hdcSrc
, hbmp
);
3329 if ( (ppshpage
&& (ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3330 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3331 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3333 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3335 GetClientRect(hwndLine
, &r
);
3336 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3340 rzone
.right
= r
.right
;
3341 rzone
.bottom
= r
.top
- 1;
3343 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3344 FillRect(hdc
, &rzone
, hbr
);
3346 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), &bm
);
3347 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3349 /* The watermark is truncated to a width of 164 pixels */
3350 r
.right
= min(r
.right
, 164);
3351 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3352 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3354 /* If the bitmap is not big enough, fill the remaining area
3355 with the color of pixel (0,0) of bitmap - see MSDN */
3356 if (r
.top
> bm
.bmHeight
) {
3357 r
.bottom
= r
.top
- 1;
3358 r
.top
= bm
.bmHeight
;
3360 r
.right
= bm
.bmWidth
;
3361 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3362 FillRect(hdc
, &r
, hbr
);
3366 SelectObject(hdcSrc
, hbmp
);
3369 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3370 SelectPalette(hdc
, hOldPal
, FALSE
);
3374 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3379 /******************************************************************************
3380 * PROPSHEET_DialogProc
3382 static INT_PTR CALLBACK
3383 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3385 TRACE("hwnd=%p msg=0x%04x wparam=%lx lparam=%lx\n",
3386 hwnd
, uMsg
, wParam
, lParam
);
3392 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3393 WCHAR
* strCaption
= Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3394 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3398 /* Using PropSheetInfoStr to store extra data doesn't match the native
3399 * common control: native uses TCM_[GS]ETITEM
3401 SetPropW(hwnd
, PropSheetInfoStr
, psInfo
);
3404 * psInfo->hwnd is not being used by WINE code - it exists
3405 * for compatibility with "real" Windoze. The same about
3406 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3409 psInfo
->hwnd
= hwnd
;
3410 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3412 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3414 /* set up the Next and Back buttons by default */
3415 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3419 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3420 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3421 logFont
.lfWeight
= FW_BOLD
;
3422 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3425 * Small icon in the title bar.
3427 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3428 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3431 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3432 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3434 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3435 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3436 psInfo
->ppshheader
.u
.pszIcon
,
3441 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3443 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3446 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3447 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3449 psInfo
->strPropertiesFor
= strCaption
;
3451 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3453 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3455 PROPSHEET_LoadWizardBitmaps(psInfo
);
3457 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3459 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3460 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3461 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3462 SetFocus(GetDlgItem(hwnd
, IDC_NEXT_BUTTON
));
3466 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3468 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3469 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3471 SetFocus(GetDlgItem(hwnd
, IDOK
));
3474 if (IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
) &&
3475 psInfo
->ppshheader
.hInstance
)
3479 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3480 (UINT_PTR
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3481 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3485 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3486 psInfo
->ppshheader
.pszCaption
);
3490 if (psInfo
->useCallback
)
3491 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
, PSCB_INITIALIZED
, 0);
3493 idx
= psInfo
->active_page
;
3494 psInfo
->active_page
= -1;
3496 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3498 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3499 * as some programs call TCM_GETCURSEL to get the current selection
3500 * from which to switch to the next page */
3501 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3503 PROPSHEET_UnChanged(hwnd
, NULL
);
3505 /* wizards set their focus during init */
3506 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3512 case WM_PRINTCLIENT
:
3514 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3518 PROPSHEET_CleanUp(hwnd
);
3522 PROPSHEET_Cancel(hwnd
, 1);
3523 return FALSE
; /* let DefDlgProc post us WM_COMMAND/IDCANCEL */
3526 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3528 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3533 /* No default handler, forward notification to active page */
3534 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3536 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3537 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3544 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3546 if (pnmh
->code
== TCN_SELCHANGE
)
3548 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3549 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3552 if(pnmh
->code
== TCN_SELCHANGING
)
3554 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3555 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3562 case WM_SYSCOLORCHANGE
:
3563 COMCTL32_RefreshSysColors();
3566 case PSM_GETCURRENTPAGEHWND
:
3568 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3574 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3575 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3577 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3583 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3587 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3590 case PSM_GETTABCONTROL
:
3592 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3594 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3603 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3604 if(msgResult
!= FALSE
)
3606 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3609 (HPROPSHEETPAGE
)lParam
);
3612 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3617 case PSM_CANCELTOCLOSE
:
3619 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3620 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3621 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3623 EnableWindow(hwndCancel
, FALSE
);
3624 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, sizeof(buf
)/sizeof(buf
[0])))
3625 SetWindowTextW(hwndOK
, buf
);
3630 case PSM_RESTARTWINDOWS
:
3632 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3637 /* reboot system takes precedence over restart windows */
3638 if (psInfo
->result
!= ID_PSREBOOTSYSTEM
)
3639 psInfo
->result
= ID_PSRESTARTWINDOWS
;
3644 case PSM_REBOOTSYSTEM
:
3646 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3651 psInfo
->result
= ID_PSREBOOTSYSTEM
;
3657 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3661 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3666 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3668 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3673 case PSM_QUERYSIBLINGS
:
3675 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3677 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3685 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3686 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3687 * on success or FALSE otherwise, as specified on MSDN Online.
3688 * Also see the MFC code for
3689 * CPropertySheet::AddPage(CPropertyPage* pPage).
3692 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3694 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3699 case PSM_REMOVEPAGE
:
3700 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3703 case PSM_ISDIALOGMESSAGE
:
3705 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3706 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3710 case PSM_PRESSBUTTON
:
3711 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3714 case PSM_SETFINISHTEXTA
:
3715 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3718 case PSM_SETWIZBUTTONS
:
3719 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3722 case PSM_SETCURSELID
:
3723 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3726 case PSM_SETFINISHTEXTW
:
3727 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3730 case PSM_INSERTPAGE
:
3732 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3733 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3737 case PSM_SETHEADERTITLEW
:
3738 PROPSHEET_SetHeaderTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3741 case PSM_SETHEADERTITLEA
:
3742 PROPSHEET_SetHeaderTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3745 case PSM_SETHEADERSUBTITLEW
:
3746 PROPSHEET_SetHeaderSubTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3749 case PSM_SETHEADERSUBTITLEA
:
3750 PROPSHEET_SetHeaderSubTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3753 case PSM_HWNDTOINDEX
:
3755 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3756 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3760 case PSM_INDEXTOHWND
:
3762 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3763 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3767 case PSM_PAGETOINDEX
:
3769 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3770 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3774 case PSM_INDEXTOPAGE
:
3776 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3777 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3783 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3784 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3790 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3791 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3797 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3798 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3802 case PSM_RECALCPAGESIZES
:
3804 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3805 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);