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
);
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]) ))
561 FIXME("Could not load resource #%04x?\n",LOWORD(lppsp
->pszTitle
));
567 pTitle
= lppsp
->pszTitle
;
569 len
= strlenW(pTitle
);
570 text
= Alloc( (len
+1)*sizeof (WCHAR
) );
571 psInfo
->proppage
[index
].pszText
= strcpyW( text
, pTitle
);
575 * Build the image list for icons
577 if ((dwFlags
& PSP_USEHICON
) || (dwFlags
& PSP_USEICONID
))
580 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
581 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
583 if (dwFlags
& PSP_USEICONID
)
584 hIcon
= LoadImageW(lppsp
->hInstance
, lppsp
->u2
.pszIcon
, IMAGE_ICON
,
585 icon_cx
, icon_cy
, LR_DEFAULTCOLOR
);
587 hIcon
= lppsp
->u2
.hIcon
;
591 if (psInfo
->hImageList
== 0 )
592 psInfo
->hImageList
= ImageList_Create(icon_cx
, icon_cy
, ILC_COLOR
, 1, 1);
594 ImageList_AddIcon(psInfo
->hImageList
, hIcon
);
602 /******************************************************************************
603 * PROPSHEET_CreateDialog
605 * Creates the actual property sheet.
607 static INT_PTR
PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
)
614 WORD resID
= IDD_PROPSHEET
;
616 TRACE("(%p)\n", psInfo
);
617 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
620 if( psInfo
->unicode
)
622 if(!(hRes
= FindResourceW(COMCTL32_hModule
,
623 MAKEINTRESOURCEW(resID
),
629 if(!(hRes
= FindResourceA(COMCTL32_hModule
,
630 MAKEINTRESOURCEA(resID
),
635 if(!(template = LoadResource(COMCTL32_hModule
, hRes
)))
639 * Make a copy of the dialog template.
641 resSize
= SizeofResource(COMCTL32_hModule
, hRes
);
643 temp
= Alloc(resSize
);
648 memcpy(temp
, template, resSize
);
650 if (psInfo
->ppshheader
.dwFlags
& PSH_NOCONTEXTHELP
)
652 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
653 ((MyDLGTEMPLATEEX
*)temp
)->style
&= ~DS_CONTEXTHELP
;
655 ((DLGTEMPLATE
*)temp
)->style
&= ~DS_CONTEXTHELP
;
657 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
658 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARDCONTEXTHELP
))
660 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
661 ((MyDLGTEMPLATEEX
*)temp
)->style
|= DS_CONTEXTHELP
;
663 ((DLGTEMPLATE
*)temp
)->style
|= DS_CONTEXTHELP
;
666 if (psInfo
->useCallback
)
667 (*(psInfo
->ppshheader
.pfnCallback
))(0, PSCB_PRECREATE
, (LPARAM
)temp
);
669 /* NOTE: MSDN states "Returns a positive value if successful, or -1
670 * otherwise for modal property sheets.", but this is wrong. The
671 * actual return value is either TRUE (success), FALSE (cancel) or
673 if( psInfo
->unicode
)
675 ret
= (INT_PTR
)CreateDialogIndirectParamW(psInfo
->ppshheader
.hInstance
,
676 temp
, psInfo
->ppshheader
.hwndParent
,
677 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
678 if ( !ret
) ret
= -1;
682 ret
= (INT_PTR
)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
683 temp
, psInfo
->ppshheader
.hwndParent
,
684 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
685 if ( !ret
) ret
= -1;
693 /******************************************************************************
694 * PROPSHEET_SizeMismatch
696 * Verify that the tab control and the "largest" property sheet page dlg. template
699 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
701 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
702 RECT rcOrigTab
, rcPage
;
707 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
708 TRACE("orig tab %s\n", wine_dbgstr_rect(&rcOrigTab
));
715 rcPage
.right
= psInfo
->width
;
716 rcPage
.bottom
= psInfo
->height
;
718 MapDialogRect(hwndDlg
, &rcPage
);
719 TRACE("biggest page %s\n", wine_dbgstr_rect(&rcPage
));
721 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
723 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
729 /******************************************************************************
730 * PROPSHEET_AdjustSize
732 * Resizes the property sheet and the tab control to fit the largest page.
734 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
736 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
737 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
740 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
744 /* Get the height of buttons */
745 GetClientRect(hwndButton
, &rc
);
746 buttonHeight
= rc
.bottom
;
753 rc
.right
= psInfo
->width
;
754 rc
.bottom
= psInfo
->height
;
756 MapDialogRect(hwndDlg
, &rc
);
758 /* retrieve the dialog units */
759 units
.left
= units
.right
= 4;
760 units
.top
= units
.bottom
= 8;
761 MapDialogRect(hwndDlg
, &units
);
764 * Resize the tab control.
766 GetClientRect(hwndTabCtrl
,&tabRect
);
768 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
770 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
772 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
773 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
776 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
778 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
779 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
782 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
786 TRACE("setting tab %p, rc (0,0)-(%d,%d)\n",
787 hwndTabCtrl
, rc
.right
, rc
.bottom
);
788 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
789 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
791 GetClientRect(hwndTabCtrl
, &rc
);
793 TRACE("tab client rc %s\n", wine_dbgstr_rect(&rc
));
795 rc
.right
+= (padding
.x
* 2);
796 rc
.bottom
+= buttonHeight
+ (3 * padding
.y
);
798 style
= GetWindowLongW(hwndDlg
, GWL_STYLE
);
799 if (!(style
& WS_CHILD
))
800 AdjustWindowRect(&rc
, style
, FALSE
);
806 * Resize the property sheet.
808 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
809 hwndDlg
, rc
.right
, rc
.bottom
);
810 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
811 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
815 /******************************************************************************
816 * PROPSHEET_AdjustSizeWizard
818 * Resizes the property sheet to fit the largest page.
820 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
822 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
823 RECT rc
, lineRect
, dialogRect
;
825 /* Biggest page size */
828 rc
.right
= psInfo
->width
;
829 rc
.bottom
= psInfo
->height
;
830 MapDialogRect(hwndDlg
, &rc
);
832 TRACE("Biggest page %s\n", wine_dbgstr_rect(&rc
));
834 /* Add space for the buttons row */
835 GetWindowRect(hwndLine
, &lineRect
);
836 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
837 GetClientRect(hwndDlg
, &dialogRect
);
838 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
840 /* Convert the client coordinates to window coordinates */
841 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
843 /* Resize the property sheet */
844 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
845 hwndDlg
, rc
.right
, rc
.bottom
);
846 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
847 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
852 /******************************************************************************
853 * PROPSHEET_AdjustButtons
855 * Adjusts the buttons' positions.
857 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, const PropSheetInfo
* psInfo
)
859 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
863 int buttonWidth
, buttonHeight
;
864 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
866 if (psInfo
->hasApply
)
873 * Obtain the size of the buttons.
875 GetClientRect(hwndButton
, &rcSheet
);
876 buttonWidth
= rcSheet
.right
;
877 buttonHeight
= rcSheet
.bottom
;
880 * Get the size of the property sheet.
882 GetClientRect(hwndParent
, &rcSheet
);
885 * All buttons will be at this y coordinate.
887 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
890 * Position OK button and make it default.
892 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
894 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
896 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
897 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
899 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
903 * Position Cancel button.
905 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
907 x
+= padding
.x
+ buttonWidth
;
909 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
910 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
913 * Position Apply button.
915 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
918 x
+= padding
.x
+ buttonWidth
;
920 ShowWindow(hwndButton
, SW_HIDE
);
922 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
923 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
924 EnableWindow(hwndButton
, FALSE
);
927 * Position Help button.
929 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
931 x
+= padding
.x
+ buttonWidth
;
932 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
933 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
936 ShowWindow(hwndButton
, SW_HIDE
);
941 /******************************************************************************
942 * PROPSHEET_AdjustButtonsWizard
944 * Adjusts the buttons' positions.
946 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
947 const PropSheetInfo
* psInfo
)
949 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
950 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
951 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
955 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
956 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
960 if (psInfo
->hasFinish
)
964 * Obtain the size of the buttons.
966 GetClientRect(hwndButton
, &rcSheet
);
967 buttonWidth
= rcSheet
.right
;
968 buttonHeight
= rcSheet
.bottom
;
970 GetClientRect(hwndLine
, &rcSheet
);
971 lineHeight
= rcSheet
.bottom
;
974 * Get the size of the property sheet.
976 GetClientRect(hwndParent
, &rcSheet
);
979 * All buttons will be at this y coordinate.
981 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
984 * Position the Back button.
986 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
988 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1)) - buttonWidth
;
990 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
991 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
994 * Position the Next button.
996 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
1000 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1001 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1004 * Position the Finish button.
1006 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
1008 if (psInfo
->hasFinish
)
1009 x
+= padding
.x
+ buttonWidth
;
1011 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1012 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1014 if (!psInfo
->hasFinish
)
1015 ShowWindow(hwndButton
, SW_HIDE
);
1018 * Position the Cancel button.
1020 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1022 x
+= padding
.x
+ buttonWidth
;
1024 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1025 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1028 * Position Help button.
1030 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1032 if (psInfo
->hasHelp
)
1034 x
+= padding
.x
+ buttonWidth
;
1036 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1037 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1040 ShowWindow(hwndButton
, SW_HIDE
);
1042 if (psInfo
->ppshheader
.dwFlags
&
1043 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1047 * Position and resize the sunken line.
1050 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1052 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1053 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1054 SWP_NOZORDER
| SWP_NOACTIVATE
);
1057 * Position and resize the header sunken line.
1060 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1061 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1062 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1063 ShowWindow(hwndLineHeader
, SW_HIDE
);
1068 /******************************************************************************
1069 * PROPSHEET_GetPaddingInfo
1071 * Returns the layout information.
1073 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1075 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1077 PADDING_INFO padding
;
1079 GetWindowRect(hwndTab
, &rcTab
);
1080 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rcTab
, 2 );
1082 padding
.x
= rcTab
.left
;
1083 padding
.y
= rcTab
.top
;
1088 /******************************************************************************
1089 * PROPSHEET_GetPaddingInfoWizard
1091 * Returns the layout information.
1092 * Vertical spacing is the distance between the line and the buttons.
1093 * Do NOT use the Help button to gather padding information when it isn't mapped
1094 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1095 * for it in this case !
1096 * FIXME: I'm not sure about any other coordinate problems with these evil
1097 * buttons. Fix it in case additional problems appear or maybe calculate
1098 * a padding in a completely different way, as this is somewhat messy.
1100 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1103 PADDING_INFO padding
;
1107 POINT ptButton
, ptLine
;
1110 if (psInfo
->hasHelp
)
1116 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1118 idButton
= IDC_NEXT_BUTTON
;
1122 /* hopefully this is ok */
1123 idButton
= IDCANCEL
;
1127 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1128 GetWindowRect(hwndControl
, &rc
);
1129 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1130 ptButton
.x
= rc
.left
;
1131 ptButton
.y
= rc
.top
;
1134 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1135 GetWindowRect(hwndControl
, &rc
);
1136 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1138 ptLine
.y
= rc
.bottom
;
1140 padding
.y
= ptButton
.y
- ptLine
.y
;
1143 ERR("padding negative ! Please report this !\n");
1145 /* this is most probably not correct, but the best we have now */
1146 padding
.x
= padding
.y
;
1150 /******************************************************************************
1151 * PROPSHEET_CreateTabControl
1153 * Insert the tabs in the tab control.
1155 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1156 const PropSheetInfo
* psInfo
)
1158 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1164 item
.mask
= TCIF_TEXT
;
1165 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1167 nTabs
= psInfo
->nPages
;
1170 * Set the image list for icons.
1172 if (psInfo
->hImageList
)
1174 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1177 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 0, 0);
1178 for (i
= 0; i
< nTabs
; i
++)
1180 if ( psInfo
->proppage
[i
].hasIcon
)
1182 item
.mask
|= TCIF_IMAGE
;
1183 item
.iImage
= iImage
++;
1187 item
.mask
&= ~TCIF_IMAGE
;
1190 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1191 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, i
, (LPARAM
)&item
);
1193 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 1, 0);
1198 /******************************************************************************
1199 * PROPSHEET_WizardSubclassProc
1201 * Subclassing window procedure for wizard exterior pages to prevent drawing
1202 * background and so drawing above the watermark.
1204 static LRESULT CALLBACK
1205 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1212 case WM_CTLCOLORSTATIC
:
1213 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1214 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1217 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1221 * Get the size of an in-memory Template
1223 *( Based on the code of PROPSHEET_CollectPageInfo)
1224 * See also dialog.c/DIALOG_ParseTemplate32().
1227 static UINT
GetTemplateSize(const DLGTEMPLATE
* pTemplate
)
1230 const WORD
* p
= (const WORD
*)pTemplate
;
1231 BOOL istemplateex
= (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1237 /* DLGTEMPLATEEX (not defined in any std. header file) */
1239 TRACE("is DLGTEMPLATEEX\n");
1241 p
++; /* signature */
1242 p
+= 2; /* help ID */
1243 p
+= 2; /* ext style */
1250 TRACE("is DLGTEMPLATE\n");
1252 p
+= 2; /* ext style */
1255 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1271 TRACE("menu %s\n",debugstr_w( p
));
1272 p
+= lstrlenW( p
) + 1;
1283 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1286 TRACE("class %s\n",debugstr_w( p
));
1287 p
+= lstrlenW( p
) + 1;
1292 TRACE("title %s\n",debugstr_w( p
));
1293 p
+= lstrlenW( p
) + 1;
1295 /* font, if DS_SETFONT set */
1296 if ((DS_SETFONT
& ((istemplateex
)? ((const MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1299 p
+=(istemplateex
)?3:1;
1300 TRACE("font %s\n",debugstr_w( p
));
1301 p
+= lstrlenW( p
) + 1; /* the font name */
1304 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1305 * that are following the DLGTEMPLATE(EX) data */
1306 TRACE("%d items\n",nrofitems
);
1307 while (nrofitems
> 0)
1309 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1312 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1321 TRACE("class ordinal 0x%08x\n",*(const DWORD
*)p
);
1325 TRACE("class %s\n",debugstr_w( p
));
1326 p
+= lstrlenW( p
) + 1;
1330 /* check title text */
1337 TRACE("text ordinal 0x%08x\n",*(const DWORD
*)p
);
1341 TRACE("text %s\n",debugstr_w( p
));
1342 p
+= lstrlenW( p
) + 1;
1345 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1349 ret
= (p
- (const WORD
*)pTemplate
) * sizeof(WORD
);
1350 TRACE("%p %p size 0x%08x\n", p
, pTemplate
, ret
);
1354 /******************************************************************************
1355 * PROPSHEET_CreatePage
1359 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1361 const PropSheetInfo
* psInfo
,
1362 LPCPROPSHEETPAGEW ppshpage
)
1364 const DLGTEMPLATE
* pTemplate
;
1367 DLGTEMPLATE
* pTemplateCopy
= NULL
;
1369 TRACE("index %d\n", index
);
1371 if (ppshpage
== NULL
)
1376 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1378 pTemplate
= ppshpage
->u
.pResource
;
1379 resSize
= GetTemplateSize(pTemplate
);
1381 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1386 hResource
= FindResourceW(ppshpage
->hInstance
,
1387 ppshpage
->u
.pszTemplate
,
1392 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1394 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1398 pTemplate
= LockResource(hTemplate
);
1400 * Make a copy of the dialog template to make it writable
1408 hResource
= FindResourceA(ppshpage
->hInstance
,
1409 (LPCSTR
)ppshpage
->u
.pszTemplate
,
1414 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1416 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1420 pTemplate
= LockResource(hTemplate
);
1422 * Make a copy of the dialog template to make it writable
1425 pTemplateCopy
= Alloc(resSize
);
1429 TRACE("copying pTemplate %p into pTemplateCopy %p (%d)\n", pTemplate
, pTemplateCopy
, resSize
);
1430 memcpy(pTemplateCopy
, pTemplate
, resSize
);
1432 if (((MyDLGTEMPLATEEX
*)pTemplateCopy
)->signature
== 0xFFFF)
1434 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1435 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~DS_MODALFRAME
;
1436 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_CAPTION
;
1437 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_SYSMENU
;
1438 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_POPUP
;
1439 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_DISABLED
;
1440 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_VISIBLE
;
1441 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_THICKFRAME
;
1443 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->exStyle
|= WS_EX_CONTROLPARENT
;
1447 pTemplateCopy
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1448 pTemplateCopy
->style
&= ~DS_MODALFRAME
;
1449 pTemplateCopy
->style
&= ~WS_CAPTION
;
1450 pTemplateCopy
->style
&= ~WS_SYSMENU
;
1451 pTemplateCopy
->style
&= ~WS_POPUP
;
1452 pTemplateCopy
->style
&= ~WS_DISABLED
;
1453 pTemplateCopy
->style
&= ~WS_VISIBLE
;
1454 pTemplateCopy
->style
&= ~WS_THICKFRAME
;
1456 pTemplateCopy
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1459 if (psInfo
->proppage
[index
].useCallback
)
1460 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1461 (LPPROPSHEETPAGEW
)ppshpage
);
1463 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1464 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1467 ppshpage
->pfnDlgProc
,
1470 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1473 ppshpage
->pfnDlgProc
,
1475 /* Free a no more needed copy */
1476 Free(pTemplateCopy
);
1481 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1483 /* Subclass exterior wizard pages */
1484 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1485 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1486 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1488 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1489 (DWORD_PTR
)ppshpage
);
1491 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1492 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1497 /******************************************************************************
1498 * PROPSHEET_LoadWizardBitmaps
1500 * Loads the watermark and header bitmaps for a wizard.
1502 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1504 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1506 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1507 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1508 considers hbmWatermark as valid. */
1509 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1510 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1512 psInfo
->ppshheader
.u4
.hbmWatermark
=
1513 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1516 /* Same behavior as for watermarks */
1517 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1518 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1520 psInfo
->ppshheader
.u5
.hbmHeader
=
1521 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1527 /******************************************************************************
1528 * PROPSHEET_ShowPage
1530 * Displays or creates the specified page.
1532 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1535 HWND hwndLineHeader
;
1537 LPCPROPSHEETPAGEW ppshpage
;
1539 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1540 if (index
== psInfo
->active_page
)
1542 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1543 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1547 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1548 if (psInfo
->proppage
[index
].hwndPage
== 0)
1550 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1553 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1555 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1556 psInfo
->proppage
[index
].pszText
);
1558 control
= GetNextDlgTabItem(psInfo
->proppage
[index
].hwndPage
, NULL
, FALSE
);
1563 if (psInfo
->active_page
!= -1)
1564 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1566 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1568 /* Synchronize current selection with tab control
1569 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1570 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1571 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1573 psInfo
->active_page
= index
;
1574 psInfo
->activeValid
= TRUE
;
1576 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1578 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1579 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1581 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1582 ShowWindow(hwndLineHeader
, SW_HIDE
);
1584 ShowWindow(hwndLineHeader
, SW_SHOW
);
1590 /******************************************************************************
1593 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1597 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1601 TRACE("active_page %d\n", psInfo
->active_page
);
1602 if (psInfo
->active_page
< 0)
1605 psn
.hdr
.code
= PSN_WIZBACK
;
1606 psn
.hdr
.hwndFrom
= hwndDlg
;
1610 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1612 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1615 else if (result
== 0)
1616 idx
= psInfo
->active_page
- 1;
1618 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1620 if (idx
>= 0 && idx
< psInfo
->nPages
)
1622 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1624 SetFocus(GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
));
1625 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
1626 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1632 /******************************************************************************
1635 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1639 LRESULT msgResult
= 0;
1640 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1643 TRACE("active_page %d\n", psInfo
->active_page
);
1644 if (psInfo
->active_page
< 0)
1647 psn
.hdr
.code
= PSN_WIZNEXT
;
1648 psn
.hdr
.hwndFrom
= hwndDlg
;
1652 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1654 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1655 if (msgResult
== -1)
1657 else if (msgResult
== 0)
1658 idx
= psInfo
->active_page
+ 1;
1660 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1662 if (idx
< psInfo
->nPages
)
1664 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1666 SetFocus(GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
));
1667 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
1668 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1675 /******************************************************************************
1678 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1682 LRESULT msgResult
= 0;
1683 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1685 TRACE("active_page %d\n", psInfo
->active_page
);
1686 if (psInfo
->active_page
< 0)
1689 psn
.hdr
.code
= PSN_WIZFINISH
;
1690 psn
.hdr
.hwndFrom
= hwndDlg
;
1694 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1696 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1698 TRACE("msg result %ld\n", msgResult
);
1703 if (psInfo
->result
== 0)
1704 psInfo
->result
= IDOK
;
1705 if (psInfo
->isModeless
)
1706 psInfo
->activeValid
= FALSE
;
1708 psInfo
->ended
= TRUE
;
1713 /******************************************************************************
1716 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1721 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1723 TRACE("active_page %d\n", psInfo
->active_page
);
1724 if (psInfo
->active_page
< 0)
1727 psn
.hdr
.hwndFrom
= hwndDlg
;
1733 * Send PSN_KILLACTIVE to the current page.
1735 psn
.hdr
.code
= PSN_KILLACTIVE
;
1737 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1739 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1743 * Send PSN_APPLY to all pages.
1745 psn
.hdr
.code
= PSN_APPLY
;
1746 psn
.lParam
= lParam
;
1748 for (i
= 0; i
< psInfo
->nPages
; i
++)
1750 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1753 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1755 case PSNRET_INVALID
:
1756 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1758 case PSNRET_INVALID_NOCHANGEPAGE
:
1766 psInfo
->activeValid
= FALSE
;
1768 else if(psInfo
->active_page
>= 0)
1770 psn
.hdr
.code
= PSN_SETACTIVE
;
1772 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1773 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1779 /******************************************************************************
1782 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1784 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1789 TRACE("active_page %d\n", psInfo
->active_page
);
1790 if (psInfo
->active_page
< 0)
1793 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1794 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1795 psn
.hdr
.hwndFrom
= hwndDlg
;
1799 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1802 psn
.hdr
.code
= PSN_RESET
;
1803 psn
.lParam
= lParam
;
1805 for (i
= 0; i
< psInfo
->nPages
; i
++)
1807 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1810 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1813 if (psInfo
->isModeless
)
1815 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1816 psInfo
->activeValid
= FALSE
;
1819 psInfo
->ended
= TRUE
;
1822 /******************************************************************************
1825 static void PROPSHEET_Help(HWND hwndDlg
)
1827 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1831 TRACE("active_page %d\n", psInfo
->active_page
);
1832 if (psInfo
->active_page
< 0)
1835 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1836 psn
.hdr
.code
= PSN_HELP
;
1837 psn
.hdr
.hwndFrom
= hwndDlg
;
1841 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1844 /******************************************************************************
1847 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1850 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1853 if (!psInfo
) return;
1855 * Set the dirty flag of this page.
1857 for (i
= 0; i
< psInfo
->nPages
; i
++)
1859 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1860 psInfo
->proppage
[i
].isDirty
= TRUE
;
1864 * Enable the Apply button.
1866 if (psInfo
->hasApply
)
1868 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1870 EnableWindow(hwndApplyBtn
, TRUE
);
1874 /******************************************************************************
1875 * PROPSHEET_UnChanged
1877 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1880 BOOL noPageDirty
= TRUE
;
1881 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1882 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1885 if ( !psInfo
) return;
1886 for (i
= 0; i
< psInfo
->nPages
; i
++)
1888 /* set the specified page as clean */
1889 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1890 psInfo
->proppage
[i
].isDirty
= FALSE
;
1892 /* look to see if there's any dirty pages */
1893 if (psInfo
->proppage
[i
].isDirty
)
1894 noPageDirty
= FALSE
;
1898 * Disable Apply button.
1901 EnableWindow(hwndApplyBtn
, FALSE
);
1904 /******************************************************************************
1905 * PROPSHEET_PressButton
1907 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1909 TRACE("buttonID %d\n", buttonID
);
1912 case PSBTN_APPLYNOW
:
1913 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1916 PROPSHEET_Back(hwndDlg
);
1919 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1922 PROPSHEET_Finish(hwndDlg
);
1925 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1928 PROPSHEET_Next(hwndDlg
);
1931 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1934 FIXME("Invalid button index %d\n", buttonID
);
1939 /*************************************************************************
1940 * BOOL PROPSHEET_CanSetCurSel [Internal]
1942 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1945 * hwndDlg [I] handle to a Dialog hWnd
1948 * TRUE if Current Selection can change
1952 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
1954 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1965 TRACE("active_page %d\n", psInfo
->active_page
);
1966 if (psInfo
->active_page
< 0)
1973 * Notify the current page.
1975 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1976 psn
.hdr
.code
= PSN_KILLACTIVE
;
1977 psn
.hdr
.hwndFrom
= hwndDlg
;
1981 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1984 TRACE("<-- %d\n", res
);
1988 /******************************************************************************
1989 * PROPSHEET_SetCurSel
1991 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
1994 HPROPSHEETPAGE hpage
1997 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1998 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
1999 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2001 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
2002 /* hpage takes precedence over index */
2004 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2006 if (index
< 0 || index
>= psInfo
->nPages
)
2008 TRACE("Could not find page to select!\n");
2012 /* unset active page while doing this transition. */
2013 if (psInfo
->active_page
!= -1)
2014 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
2015 psInfo
->active_page
= -1;
2021 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2024 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
2026 psn
.hdr
.code
= PSN_SETACTIVE
;
2027 psn
.hdr
.hwndFrom
= hwndDlg
;
2031 if (!psInfo
->proppage
[index
].hwndPage
) {
2032 if(!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
)) {
2033 PROPSHEET_RemovePage(hwndDlg
, index
, NULL
);
2034 if(index
>= psInfo
->nPages
)
2042 /* Resize the property sheet page to the fit in the Tab control
2043 * (for regular property sheets) or to fit in the client area (for
2045 * NOTE: The resizing happens every time the page is selected and
2046 * not only when it's created (some applications depend on it). */
2047 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2048 TRACE("setting page %p, rc (%s) w=%d, h=%d\n",
2049 psInfo
->proppage
[index
].hwndPage
, wine_dbgstr_rect(&rc
),
2050 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2051 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2053 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2055 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2062 WARN("Tried to skip before first property sheet page!\n");
2065 if (index
>= psInfo
->nPages
) {
2066 WARN("Tried to skip after last property sheet page!\n");
2067 index
= psInfo
->nPages
-1;
2071 else if (result
!= 0)
2073 int old_index
= index
;
2074 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2075 if(index
>= psInfo
->nPages
) {
2077 WARN("Tried to skip to nonexistent page by res id\n");
2084 /* Invalidate the header area */
2085 if ( (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
2086 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
2088 HWND hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
2091 GetClientRect(hwndLineHeader
, &r
);
2092 MapWindowPoints(hwndLineHeader
, hwndDlg
, (LPPOINT
) &r
, 2);
2093 SetRect(&r
, 0, 0, r
.right
+ 1, r
.top
- 1);
2095 InvalidateRect(hwndDlg
, &r
, TRUE
);
2099 * Display the new page.
2101 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2103 if (psInfo
->proppage
[index
].hasHelp
)
2104 EnableWindow(hwndHelp
, TRUE
);
2106 EnableWindow(hwndHelp
, FALSE
);
2111 /******************************************************************************
2112 * PROPSHEET_SetCurSelId
2114 * Selects the page, specified by resource id.
2116 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2119 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2121 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2122 if (idx
< psInfo
->nPages
)
2124 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2125 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2129 /******************************************************************************
2130 * PROPSHEET_SetTitleA
2132 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2134 if(!IS_INTRESOURCE(lpszText
))
2137 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2138 szTitle
, sizeof(szTitle
)/sizeof(WCHAR
));
2139 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2143 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2147 /******************************************************************************
2148 * PROPSHEET_SetTitleW
2150 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2152 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2155 TRACE("%s (style %08x)\n", debugstr_w(lpszText
), dwStyle
);
2156 if (IS_INTRESOURCE(lpszText
)) {
2157 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2158 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0])))
2162 if (dwStyle
& PSH_PROPTITLE
)
2165 int lentitle
= strlenW(lpszText
);
2166 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2168 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2169 wsprintfW(dest
, psInfo
->strPropertiesFor
, lpszText
);
2171 SetWindowTextW(hwndDlg
, dest
);
2175 SetWindowTextW(hwndDlg
, lpszText
);
2178 /******************************************************************************
2179 * PROPSHEET_SetFinishTextA
2181 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2183 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2184 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2186 TRACE("'%s'\n", lpszText
);
2187 /* Set text, show and enable the Finish button */
2188 SetWindowTextA(hwndButton
, lpszText
);
2189 ShowWindow(hwndButton
, SW_SHOW
);
2190 EnableWindow(hwndButton
, TRUE
);
2192 /* Make it default pushbutton */
2193 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2195 /* Hide Back button */
2196 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2197 ShowWindow(hwndButton
, SW_HIDE
);
2199 if (!psInfo
->hasFinish
)
2201 /* Hide Next button */
2202 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2203 ShowWindow(hwndButton
, SW_HIDE
);
2207 /******************************************************************************
2208 * PROPSHEET_SetFinishTextW
2210 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2212 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2213 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2215 TRACE("%s\n", debugstr_w(lpszText
));
2216 /* Set text, show and enable the Finish button */
2217 SetWindowTextW(hwndButton
, lpszText
);
2218 ShowWindow(hwndButton
, SW_SHOW
);
2219 EnableWindow(hwndButton
, TRUE
);
2221 /* Make it default pushbutton */
2222 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2224 /* Hide Back button */
2225 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2226 ShowWindow(hwndButton
, SW_HIDE
);
2228 if (!psInfo
->hasFinish
)
2230 /* Hide Next button */
2231 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2232 ShowWindow(hwndButton
, SW_HIDE
);
2236 /******************************************************************************
2237 * PROPSHEET_QuerySiblings
2239 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2240 WPARAM wParam
, LPARAM lParam
)
2244 LRESULT msgResult
= 0;
2245 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2247 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2249 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2250 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2258 /******************************************************************************
2261 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
2262 HPROPSHEETPAGE hpage
)
2265 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2266 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2268 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2270 TRACE("hpage %p\n", hpage
);
2272 * Allocate and fill in a new PropPageInfo entry.
2274 ppi
= ReAlloc(psInfo
->proppage
, sizeof(PropPageInfo
) * (psInfo
->nPages
+ 1));
2278 psInfo
->proppage
= ppi
;
2279 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, psInfo
->nPages
, FALSE
))
2282 psInfo
->proppage
[psInfo
->nPages
].hpage
= hpage
;
2284 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2286 /* Create the page but don't show it */
2287 if(!PROPSHEET_CreatePage(hwndDlg
, psInfo
->nPages
, psInfo
, ppsp
))
2292 * Add a new tab to the tab control.
2294 item
.mask
= TCIF_TEXT
;
2295 item
.pszText
= (LPWSTR
) psInfo
->proppage
[psInfo
->nPages
].pszText
;
2296 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2298 if (psInfo
->hImageList
)
2300 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2303 if ( psInfo
->proppage
[psInfo
->nPages
].hasIcon
)
2305 item
.mask
|= TCIF_IMAGE
;
2306 item
.iImage
= psInfo
->nPages
;
2309 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, psInfo
->nPages
+ 1,
2314 /* If it is the only page - show it */
2315 if(psInfo
->nPages
== 1)
2316 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2320 /******************************************************************************
2321 * PROPSHEET_RemovePage
2323 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2325 HPROPSHEETPAGE hpage
)
2327 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2328 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2329 PropPageInfo
* oldPages
;
2331 TRACE("index %d, hpage %p\n", index
, hpage
);
2336 * hpage takes precedence over index.
2340 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2343 /* Make sure that index is within range */
2344 if (index
< 0 || index
>= psInfo
->nPages
)
2346 TRACE("Could not find page to remove!\n");
2350 TRACE("total pages %d removing page %d active page %d\n",
2351 psInfo
->nPages
, index
, psInfo
->active_page
);
2353 * Check if we're removing the active page.
2355 if (index
== psInfo
->active_page
)
2357 if (psInfo
->nPages
> 1)
2361 /* activate previous page */
2362 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2366 /* activate the next page */
2367 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2368 psInfo
->active_page
= index
;
2373 psInfo
->active_page
= -1;
2374 if (!psInfo
->isModeless
)
2376 psInfo
->ended
= TRUE
;
2381 else if (index
< psInfo
->active_page
)
2382 psInfo
->active_page
--;
2384 /* Unsubclass the page dialog window */
2385 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2386 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2387 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2389 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2390 PROPSHEET_WizardSubclassProc
, 1);
2393 /* Destroy page dialog window */
2394 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2396 /* Free page resources */
2397 if(psInfo
->proppage
[index
].hpage
)
2399 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2401 if (psp
->dwFlags
& PSP_USETITLE
)
2402 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2404 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2407 /* Remove the tab */
2408 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2410 oldPages
= psInfo
->proppage
;
2412 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2415 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2417 if (index
< psInfo
->nPages
)
2418 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2419 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2426 /******************************************************************************
2427 * PROPSHEET_SetWizButtons
2429 * This code will work if (and assumes that) the Next button is on top of the
2430 * Finish button. ie. Finish comes after Next in the Z order.
2431 * This means make sure the dialog template reflects this.
2434 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2436 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2437 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2438 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2439 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2441 TRACE("%d\n", dwFlags
);
2443 EnableWindow(hwndBack
, FALSE
);
2444 EnableWindow(hwndNext
, FALSE
);
2445 EnableWindow(hwndFinish
, FALSE
);
2447 /* set the default pushbutton to an enabled button */
2448 if (((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
))
2449 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2450 else if (dwFlags
& PSWIZB_NEXT
)
2451 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2452 else if (dwFlags
& PSWIZB_BACK
)
2453 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
2455 SendMessageW(hwndDlg
, DM_SETDEFID
, IDCANCEL
, 0);
2458 if (dwFlags
& PSWIZB_BACK
)
2459 EnableWindow(hwndBack
, TRUE
);
2461 if (dwFlags
& PSWIZB_NEXT
)
2462 EnableWindow(hwndNext
, TRUE
);
2464 if (!psInfo
->hasFinish
)
2466 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2468 /* Hide the Next button */
2469 ShowWindow(hwndNext
, SW_HIDE
);
2471 /* Show the Finish button */
2472 ShowWindow(hwndFinish
, SW_SHOW
);
2474 if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2475 EnableWindow(hwndFinish
, TRUE
);
2479 /* Hide the Finish button */
2480 ShowWindow(hwndFinish
, SW_HIDE
);
2481 /* Show the Next button */
2482 ShowWindow(hwndNext
, SW_SHOW
);
2485 else if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2486 EnableWindow(hwndFinish
, TRUE
);
2489 /******************************************************************************
2490 * PROPSHEET_InsertPage
2492 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2494 if (IS_INTRESOURCE(hpageInsertAfter
))
2495 FIXME("(%p, %d, %p): stub\n", hwndDlg
, LOWORD(hpageInsertAfter
), hpage
);
2497 FIXME("(%p, %p, %p): stub\n", hwndDlg
, hpageInsertAfter
, hpage
);
2501 /******************************************************************************
2502 * PROPSHEET_SetHeaderTitleW
2504 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderTitle
)
2506 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderTitle
));
2509 /******************************************************************************
2510 * PROPSHEET_SetHeaderTitleA
2512 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderTitle
)
2514 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderTitle
));
2517 /******************************************************************************
2518 * PROPSHEET_SetHeaderSubTitleW
2520 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderSubTitle
)
2522 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderSubTitle
));
2525 /******************************************************************************
2526 * PROPSHEET_SetHeaderSubTitleA
2528 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderSubTitle
)
2530 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderSubTitle
));
2533 /******************************************************************************
2534 * PROPSHEET_HwndToIndex
2536 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2539 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2541 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2543 for (index
= 0; index
< psInfo
->nPages
; index
++)
2544 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2546 WARN("%p not found\n", hPageDlg
);
2550 /******************************************************************************
2551 * PROPSHEET_IndexToHwnd
2553 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2555 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2556 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2559 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2560 WARN("%d out of range.\n", iPageIndex
);
2563 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2566 /******************************************************************************
2567 * PROPSHEET_PageToIndex
2569 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2572 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2574 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2576 for (index
= 0; index
< psInfo
->nPages
; index
++)
2577 if (psInfo
->proppage
[index
].hpage
== hPage
)
2579 WARN("%p not found\n", hPage
);
2583 /******************************************************************************
2584 * PROPSHEET_IndexToPage
2586 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2588 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2589 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2590 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2591 WARN("%d out of range.\n", iPageIndex
);
2594 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2597 /******************************************************************************
2598 * PROPSHEET_IdToIndex
2600 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2603 LPCPROPSHEETPAGEW psp
;
2604 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2605 TRACE("(%p, %d)\n", hwndDlg
, iPageId
);
2606 for (index
= 0; index
< psInfo
->nPages
; index
++) {
2607 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2608 if (psp
->u
.pszTemplate
== MAKEINTRESOURCEW(iPageId
))
2615 /******************************************************************************
2616 * PROPSHEET_IndexToId
2618 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2620 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2621 LPCPROPSHEETPAGEW psp
;
2622 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2623 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2624 WARN("%d out of range.\n", iPageIndex
);
2627 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2628 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| !IS_INTRESOURCE(psp
->u
.pszTemplate
)) {
2631 return (LRESULT
)psp
->u
.pszTemplate
;
2634 /******************************************************************************
2635 * PROPSHEET_GetResult
2637 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2639 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2640 return psInfo
->result
;
2643 /******************************************************************************
2644 * PROPSHEET_RecalcPageSizes
2646 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2648 FIXME("(%p): stub\n", hwndDlg
);
2652 /******************************************************************************
2653 * PROPSHEET_GetPageIndex
2655 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2656 * the array of PropPageInfo.
2658 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, const PropSheetInfo
* psInfo
)
2663 TRACE("hpage %p\n", hpage
);
2664 while ((index
< psInfo
->nPages
) && (found
== FALSE
))
2666 if (psInfo
->proppage
[index
].hpage
== hpage
)
2678 /******************************************************************************
2681 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2684 PropSheetInfo
* psInfo
= RemovePropW(hwndDlg
, PropSheetInfoStr
);
2687 if (!psInfo
) return;
2688 if (!IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
))
2689 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2691 for (i
= 0; i
< psInfo
->nPages
; i
++)
2693 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2695 /* Unsubclass the page dialog window */
2696 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2697 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2698 (psp
->dwFlags
& PSP_HIDEHEADER
))
2700 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2701 PROPSHEET_WizardSubclassProc
, 1);
2704 if(psInfo
->proppage
[i
].hwndPage
)
2705 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2709 if (psp
->dwFlags
& PSP_USETITLE
)
2710 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2712 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2716 DeleteObject(psInfo
->hFont
);
2717 DeleteObject(psInfo
->hFontBold
);
2718 /* If we created the bitmaps, destroy them */
2719 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2720 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2721 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2722 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2723 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2724 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2726 Free(psInfo
->proppage
);
2727 Free(psInfo
->strPropertiesFor
);
2728 ImageList_Destroy(psInfo
->hImageList
);
2733 static INT
do_loop(const PropSheetInfo
*psInfo
)
2737 HWND hwnd
= psInfo
->hwnd
;
2739 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2744 if(!IsDialogMessageW(hwnd
, &msg
))
2746 TranslateMessage(&msg
);
2747 DispatchMessageW(&msg
);
2753 PostQuitMessage(msg
.wParam
);
2758 ret
= psInfo
->result
;
2760 DestroyWindow(hwnd
);
2764 /******************************************************************************
2765 * PROPSHEET_PropertySheet
2767 * Common code between PropertySheetA/W
2769 static INT_PTR
PROPSHEET_PropertySheet(PropSheetInfo
* psInfo
, BOOL unicode
)
2773 if (psInfo
->active_page
>= psInfo
->nPages
) psInfo
->active_page
= 0;
2774 TRACE("startpage: %d of %d pages\n", psInfo
->active_page
, psInfo
->nPages
);
2776 psInfo
->unicode
= unicode
;
2777 psInfo
->ended
= FALSE
;
2779 if(!psInfo
->isModeless
)
2781 parent
= psInfo
->ppshheader
.hwndParent
;
2782 if (parent
) EnableWindow(parent
, FALSE
);
2784 bRet
= PROPSHEET_CreateDialog(psInfo
);
2785 if(!psInfo
->isModeless
)
2787 bRet
= do_loop(psInfo
);
2788 if (parent
) EnableWindow(parent
, TRUE
);
2793 /******************************************************************************
2794 * PropertySheet (COMCTL32.@)
2795 * PropertySheetA (COMCTL32.@)
2797 * Creates a property sheet in the specified property sheet header.
2800 * Modal property sheets: Positive if successful or -1 otherwise.
2801 * Modeless property sheets: Property sheet handle.
2803 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2804 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2806 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2808 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2812 TRACE("(%p)\n", lppsh
);
2814 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2816 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2817 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2819 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2821 if (!psInfo
->usePropPage
)
2822 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2825 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2826 pByte
+= ((LPCPROPSHEETPAGEA
)pByte
)->dwSize
;
2829 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2832 if (psInfo
->usePropPage
)
2833 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2839 return PROPSHEET_PropertySheet(psInfo
, FALSE
);
2842 /******************************************************************************
2843 * PropertySheetW (COMCTL32.@)
2845 * See PropertySheetA.
2847 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2849 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2853 TRACE("(%p)\n", lppsh
);
2855 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2857 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2858 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2860 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2862 if (!psInfo
->usePropPage
)
2863 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2866 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2867 pByte
+= ((LPCPROPSHEETPAGEW
)pByte
)->dwSize
;
2870 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2873 if (psInfo
->usePropPage
)
2874 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2880 return PROPSHEET_PropertySheet(psInfo
, TRUE
);
2883 static LPWSTR
load_string( HINSTANCE instance
, LPCWSTR str
)
2887 if (IS_INTRESOURCE(str
))
2892 WORD i
, id
= LOWORD(str
);
2895 if (!(hrsrc
= FindResourceW( instance
, MAKEINTRESOURCEW((id
>> 4) + 1), (LPWSTR
)RT_STRING
)))
2897 if (!(hmem
= LoadResource( instance
, hrsrc
))) return NULL
;
2898 if (!(ptr
= LockResource( hmem
))) return NULL
;
2899 for (i
= id
& 0x0f; i
> 0; i
--) ptr
+= *ptr
+ 1;
2901 if (!len
) return NULL
;
2902 ret
= Alloc( (len
+ 1) * sizeof(WCHAR
) );
2905 memcpy( ret
, ptr
+ 1, len
* sizeof(WCHAR
) );
2911 int len
= (strlenW(str
) + 1) * sizeof(WCHAR
);
2913 if (ret
) memcpy( ret
, str
, len
);
2919 /******************************************************************************
2920 * CreatePropertySheetPage (COMCTL32.@)
2921 * CreatePropertySheetPageA (COMCTL32.@)
2923 * Creates a new property sheet page.
2926 * Success: Handle to new property sheet page.
2930 * An application must use the PSM_ADDPAGE message to add the new page to
2931 * an existing property sheet.
2933 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2934 LPCPROPSHEETPAGEA lpPropSheetPage
)
2936 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2938 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEA
)));
2940 ppsp
->dwFlags
&= ~ PSP_INTERNAL_UNICODE
;
2942 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2944 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
2946 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
) + 1;
2947 char *template = Alloc( len
);
2949 ppsp
->u
.pszTemplate
= (LPWSTR
)strcpy( template, lpPropSheetPage
->u
.pszTemplate
);
2953 if (ppsp
->dwFlags
& PSP_USEICONID
)
2955 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
2956 PROPSHEET_AtoW(&ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2959 if (ppsp
->dwFlags
& PSP_USETITLE
)
2961 if (!IS_INTRESOURCE( ppsp
->pszTitle
))
2962 PROPSHEET_AtoW( &ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2964 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
2967 ppsp
->pszTitle
= NULL
;
2969 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
2970 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
2972 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
2974 if (!IS_INTRESOURCE( ppsp
->pszHeaderTitle
))
2975 PROPSHEET_AtoW(&ppsp
->pszHeaderTitle
, lpPropSheetPage
->pszHeaderTitle
);
2977 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
2980 ppsp
->pszHeaderTitle
= NULL
;
2982 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
2984 if (!IS_INTRESOURCE( ppsp
->pszHeaderSubTitle
))
2985 PROPSHEET_AtoW(&ppsp
->pszHeaderSubTitle
, lpPropSheetPage
->pszHeaderSubTitle
);
2987 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
2990 ppsp
->pszHeaderSubTitle
= NULL
;
2992 return (HPROPSHEETPAGE
)ppsp
;
2995 /******************************************************************************
2996 * CreatePropertySheetPageW (COMCTL32.@)
2998 * See CreatePropertySheetA.
3000 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
3002 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
3004 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEW
)));
3006 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
3008 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
3010 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
3012 int len
= strlenW(lpPropSheetPage
->u
.pszTemplate
) + 1;
3013 WCHAR
*template = Alloc( len
* sizeof (WCHAR
) );
3015 ppsp
->u
.pszTemplate
= strcpyW( template, lpPropSheetPage
->u
.pszTemplate
);
3019 if ( ppsp
->dwFlags
& PSP_USEICONID
)
3021 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
3023 int len
= strlenW(lpPropSheetPage
->u2
.pszIcon
) + 1;
3024 WCHAR
*icon
= Alloc( len
* sizeof (WCHAR
) );
3026 ppsp
->u2
.pszIcon
= strcpyW( icon
, lpPropSheetPage
->u2
.pszIcon
);
3030 if (ppsp
->dwFlags
& PSP_USETITLE
)
3031 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3033 ppsp
->pszTitle
= NULL
;
3035 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3036 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3038 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3039 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3041 ppsp
->pszHeaderTitle
= NULL
;
3043 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3044 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3046 ppsp
->pszHeaderSubTitle
= NULL
;
3048 return (HPROPSHEETPAGE
)ppsp
;
3051 /******************************************************************************
3052 * DestroyPropertySheetPage (COMCTL32.@)
3054 * Destroys a property sheet page previously created with
3055 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
3062 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
3064 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3069 if (!(psp
->dwFlags
& PSP_DLGINDIRECT
) && !IS_INTRESOURCE( psp
->u
.pszTemplate
))
3070 Free ((LPVOID
)psp
->u
.pszTemplate
);
3072 if ((psp
->dwFlags
& PSP_USEICONID
) && !IS_INTRESOURCE( psp
->u2
.pszIcon
))
3073 Free ((LPVOID
)psp
->u2
.pszIcon
);
3075 if ((psp
->dwFlags
& PSP_USETITLE
) && !IS_INTRESOURCE( psp
->pszTitle
))
3076 Free ((LPVOID
)psp
->pszTitle
);
3078 if ((psp
->dwFlags
& PSP_USEHEADERTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderTitle
))
3079 Free ((LPVOID
)psp
->pszHeaderTitle
);
3081 if ((psp
->dwFlags
& PSP_USEHEADERSUBTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderSubTitle
))
3082 Free ((LPVOID
)psp
->pszHeaderSubTitle
);
3089 /******************************************************************************
3090 * PROPSHEET_IsDialogMessage
3092 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3094 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3097 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3100 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3103 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3105 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3107 switch (lpMsg
->wParam
)
3110 if (GetKeyState(VK_SHIFT
) & 0x8000)
3116 case VK_NEXT
: new_page
= 1; break;
3117 case VK_PRIOR
: new_page
= -1; break;
3123 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3125 new_page
+= psInfo
->active_page
;
3128 new_page
= psInfo
->nPages
- 1;
3129 else if (new_page
>= psInfo
->nPages
)
3132 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3139 return IsDialogMessageW(hwnd
, lpMsg
);
3142 /******************************************************************************
3143 * PROPSHEET_DoCommand
3145 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3151 case IDC_APPLY_BUTTON
:
3153 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3155 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3160 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3162 /* don't overwrite ID_PSRESTARTWINDOWS or ID_PSREBOOTSYSTEM */
3163 if (psInfo
->result
== 0)
3164 psInfo
->result
= IDOK
;
3166 if (psInfo
->isModeless
)
3167 psInfo
->activeValid
= FALSE
;
3169 psInfo
->ended
= TRUE
;
3172 EnableWindow(hwndApplyBtn
, FALSE
);
3177 case IDC_BACK_BUTTON
:
3178 PROPSHEET_Back(hwnd
);
3181 case IDC_NEXT_BUTTON
:
3182 PROPSHEET_Next(hwnd
);
3185 case IDC_FINISH_BUTTON
:
3186 PROPSHEET_Finish(hwnd
);
3190 PROPSHEET_Cancel(hwnd
, 0);
3194 PROPSHEET_Help(hwnd
);
3204 /******************************************************************************
3207 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3209 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3214 HPALETTE hOldPal
= 0;
3218 LPCPROPSHEETPAGEW ppshpage
;
3219 WCHAR szBuffer
[256];
3222 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3225 hdcSrc
= CreateCompatibleDC(0);
3227 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3228 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3230 if (psInfo
->active_page
< 0)
3233 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3235 if ( (ppshpage
&& !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3236 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3237 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3239 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3241 COLORREF clrOld
= 0;
3244 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3245 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3247 GetClientRect(hwndLineHeader
, &r
);
3248 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3249 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3251 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), &bm
);
3253 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3255 /* Fill the unoccupied part of the header with color of the
3256 * left-top pixel, but do it only when needed.
3258 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3260 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3261 CopyRect(&r
, &rzone
);
3262 if (bm
.bmWidth
< r
.right
)
3264 r
.left
= bm
.bmWidth
;
3265 FillRect(hdc
, &r
, hbr
);
3267 if (bm
.bmHeight
< r
.bottom
)
3270 r
.top
= bm
.bmHeight
;
3271 FillRect(hdc
, &r
, hbr
);
3276 /* Draw the header itself. */
3278 bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3279 hdcSrc
, 0, 0, SRCCOPY
);
3284 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3285 FillRect(hdc
, &rzone
, hbr
);
3287 /* Draw the header bitmap. It's always centered like a
3288 * common 49 x 49 bitmap. */
3289 margin
= (rzone
.bottom
- 49) / 2;
3290 BitBlt(hdc
, rzone
.right
- 49 - margin
, margin
,
3291 min(bm
.bmWidth
, 49), min(bm
.bmHeight
, 49),
3292 hdcSrc
, 0, 0, SRCCOPY
);
3294 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3295 * if its height is smaller than 49 pixels. Because the reason
3296 * for this bug is unknown the current code doesn't try to
3300 clrOld
= SetTextColor (hdc
, 0x00000000);
3301 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3303 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3304 SetRect(&r
, 20, 10, 0, 0);
3305 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3306 DrawTextW(hdc
, ppshpage
->pszHeaderTitle
, -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3309 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderTitle
,
3313 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3318 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3319 SelectObject(hdc
, psInfo
->hFont
);
3320 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3321 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3322 DrawTextW(hdc
, ppshpage
->pszHeaderSubTitle
, -1, &r
, DT_LEFT
| DT_WORDBREAK
);
3325 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderSubTitle
,
3329 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_WORDBREAK
);
3334 offsety
= rzone
.bottom
+ 2;
3336 SetTextColor(hdc
, clrOld
);
3337 SetBkMode(hdc
, oldBkMode
);
3338 SelectObject(hdc
, hOldFont
);
3339 SelectObject(hdcSrc
, hbmp
);
3342 if ( (ppshpage
&& (ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3343 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3344 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3346 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3348 GetClientRect(hwndLine
, &r
);
3349 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3353 rzone
.right
= r
.right
;
3354 rzone
.bottom
= r
.top
- 1;
3356 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3357 FillRect(hdc
, &rzone
, hbr
);
3359 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), &bm
);
3360 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3362 /* The watermark is truncated to a width of 164 pixels */
3363 r
.right
= min(r
.right
, 164);
3364 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3365 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3367 /* If the bitmap is not big enough, fill the remaining area
3368 with the color of pixel (0,0) of bitmap - see MSDN */
3369 if (r
.top
> bm
.bmHeight
) {
3370 r
.bottom
= r
.top
- 1;
3371 r
.top
= bm
.bmHeight
;
3373 r
.right
= bm
.bmWidth
;
3374 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3375 FillRect(hdc
, &r
, hbr
);
3379 SelectObject(hdcSrc
, hbmp
);
3382 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3383 SelectPalette(hdc
, hOldPal
, FALSE
);
3387 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3392 /******************************************************************************
3393 * PROPSHEET_DialogProc
3395 static INT_PTR CALLBACK
3396 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3398 TRACE("hwnd=%p msg=0x%04x wparam=%lx lparam=%lx\n",
3399 hwnd
, uMsg
, wParam
, lParam
);
3405 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3406 WCHAR
* strCaption
= Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3407 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3411 /* Using PropSheetInfoStr to store extra data doesn't match the native
3412 * common control: native uses TCM_[GS]ETITEM
3414 SetPropW(hwnd
, PropSheetInfoStr
, psInfo
);
3417 * psInfo->hwnd is not being used by WINE code - it exists
3418 * for compatibility with "real" Windoze. The same about
3419 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3422 psInfo
->hwnd
= hwnd
;
3423 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3425 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3427 /* set up the Next and Back buttons by default */
3428 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3432 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3433 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3434 logFont
.lfWeight
= FW_BOLD
;
3435 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3438 * Small icon in the title bar.
3440 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3441 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3444 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3445 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3447 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3448 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3449 psInfo
->ppshheader
.u
.pszIcon
,
3454 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3456 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3459 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3460 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3462 psInfo
->strPropertiesFor
= strCaption
;
3464 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3466 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3468 PROPSHEET_LoadWizardBitmaps(psInfo
);
3470 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3472 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3473 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3474 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3475 SetFocus(GetDlgItem(hwnd
, IDC_NEXT_BUTTON
));
3479 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3481 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3482 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3484 SetFocus(GetDlgItem(hwnd
, IDOK
));
3487 if (IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
) &&
3488 psInfo
->ppshheader
.hInstance
)
3492 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3493 (UINT_PTR
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3494 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3498 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3499 psInfo
->ppshheader
.pszCaption
);
3503 if (psInfo
->useCallback
)
3504 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
, PSCB_INITIALIZED
, 0);
3506 idx
= psInfo
->active_page
;
3507 psInfo
->active_page
= -1;
3509 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3511 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3512 * as some programs call TCM_GETCURSEL to get the current selection
3513 * from which to switch to the next page */
3514 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3516 PROPSHEET_UnChanged(hwnd
, NULL
);
3518 /* wizards set their focus during init */
3519 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3525 case WM_PRINTCLIENT
:
3527 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3531 PROPSHEET_CleanUp(hwnd
);
3535 PROPSHEET_Cancel(hwnd
, 1);
3536 return FALSE
; /* let DefDlgProc post us WM_COMMAND/IDCANCEL */
3539 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3541 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3546 /* No default handler, forward notification to active page */
3547 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3549 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3550 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3557 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3559 if (pnmh
->code
== TCN_SELCHANGE
)
3561 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3562 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3565 if(pnmh
->code
== TCN_SELCHANGING
)
3567 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3568 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3575 case WM_SYSCOLORCHANGE
:
3576 COMCTL32_RefreshSysColors();
3579 case PSM_GETCURRENTPAGEHWND
:
3581 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3587 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3588 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3590 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3596 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3600 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3603 case PSM_GETTABCONTROL
:
3605 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3607 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3616 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3617 if(msgResult
!= FALSE
)
3619 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3622 (HPROPSHEETPAGE
)lParam
);
3625 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3630 case PSM_CANCELTOCLOSE
:
3632 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3633 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3634 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3636 EnableWindow(hwndCancel
, FALSE
);
3637 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, sizeof(buf
)/sizeof(buf
[0])))
3638 SetWindowTextW(hwndOK
, buf
);
3643 case PSM_RESTARTWINDOWS
:
3645 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3650 /* reboot system takes precedence over restart windows */
3651 if (psInfo
->result
!= ID_PSREBOOTSYSTEM
)
3652 psInfo
->result
= ID_PSRESTARTWINDOWS
;
3657 case PSM_REBOOTSYSTEM
:
3659 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3664 psInfo
->result
= ID_PSREBOOTSYSTEM
;
3670 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3674 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3679 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3681 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3686 case PSM_QUERYSIBLINGS
:
3688 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3690 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3698 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3699 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3700 * on success or FALSE otherwise, as specified on MSDN Online.
3701 * Also see the MFC code for
3702 * CPropertySheet::AddPage(CPropertyPage* pPage).
3705 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3707 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3712 case PSM_REMOVEPAGE
:
3713 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3716 case PSM_ISDIALOGMESSAGE
:
3718 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3719 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3723 case PSM_PRESSBUTTON
:
3724 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3727 case PSM_SETFINISHTEXTA
:
3728 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3731 case PSM_SETWIZBUTTONS
:
3732 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3735 case PSM_SETCURSELID
:
3736 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3739 case PSM_SETFINISHTEXTW
:
3740 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3743 case PSM_INSERTPAGE
:
3745 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3746 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3750 case PSM_SETHEADERTITLEW
:
3751 PROPSHEET_SetHeaderTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3754 case PSM_SETHEADERTITLEA
:
3755 PROPSHEET_SetHeaderTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3758 case PSM_SETHEADERSUBTITLEW
:
3759 PROPSHEET_SetHeaderSubTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3762 case PSM_SETHEADERSUBTITLEA
:
3763 PROPSHEET_SetHeaderSubTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3766 case PSM_HWNDTOINDEX
:
3768 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3769 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3773 case PSM_INDEXTOHWND
:
3775 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3776 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3780 case PSM_PAGETOINDEX
:
3782 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3783 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3787 case PSM_INDEXTOPAGE
:
3789 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3790 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3796 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3797 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3803 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3804 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3810 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3811 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3815 case PSM_RECALCPAGESIZES
:
3817 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3818 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);