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
;
125 PropPageInfo
* proppage
;
130 HIMAGELIST hImageList
;
141 /******************************************************************************
142 * Defines and global variables
145 static const WCHAR PropSheetInfoStr
[] =
146 {'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0 };
148 #define PSP_INTERNAL_UNICODE 0x80000000
150 #define MAX_CAPTION_LENGTH 255
151 #define MAX_TABTEXT_LENGTH 255
152 #define MAX_BUTTONTEXT_LENGTH 64
154 #define INTRNL_ANY_WIZARD (PSH_WIZARD | PSH_WIZARD97_OLD | PSH_WIZARD97_NEW | PSH_WIZARD_LITE)
156 /* Wizard metrics specified in DLUs */
157 #define WIZARD_PADDING 7
158 #define WIZARD_HEADER_HEIGHT 36
160 /******************************************************************************
163 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
);
164 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
);
165 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
);
166 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
169 HPROPSHEETPAGE hpage
);
170 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, const PropSheetInfo
* psInfo
);
171 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
);
172 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
);
174 static INT_PTR CALLBACK
175 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
177 WINE_DEFAULT_DEBUG_CHANNEL(propsheet
);
179 #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");}
180 /******************************************************************************
181 * PROPSHEET_UnImplementedFlags
183 * Document use of flags we don't implement yet.
185 static VOID
PROPSHEET_UnImplementedFlags(DWORD dwFlags
)
192 * unhandled header flags:
193 * PSH_RTLREADING 0x00000800
194 * PSH_STRETCHWATERMARK 0x00040000
195 * PSH_USEPAGELANG 0x00200000
198 add_flag(PSH_RTLREADING
);
199 add_flag(PSH_STRETCHWATERMARK
);
200 add_flag(PSH_USEPAGELANG
);
201 if (string
[0] != '\0')
202 FIXME("%s\n", string
);
206 /******************************************************************************
207 * PROPSHEET_GetPageRect
209 * Retrieve rect from tab control and map into the dialog for SetWindowPos
211 static void PROPSHEET_GetPageRect(const PropSheetInfo
* psInfo
, HWND hwndDlg
,
212 RECT
*rc
, LPCPROPSHEETPAGEW ppshpage
)
214 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) {
218 if (((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
219 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
220 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) ||
221 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
))
223 rc
->left
= rc
->top
= WIZARD_PADDING
;
227 rc
->left
= rc
->top
= 0;
229 rc
->right
= psInfo
->width
- rc
->left
;
230 rc
->bottom
= psInfo
->height
- rc
->top
;
231 MapDialogRect(hwndDlg
, rc
);
233 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
234 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
235 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
))
237 hwndChild
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
238 GetClientRect(hwndChild
, &r
);
239 MapWindowPoints(hwndChild
, hwndDlg
, (LPPOINT
) &r
, 2);
240 rc
->top
+= r
.bottom
+ 1;
243 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
244 GetClientRect(hwndTabCtrl
, rc
);
245 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)rc
);
246 MapWindowPoints(hwndTabCtrl
, hwndDlg
, (LPPOINT
)rc
, 2);
250 /******************************************************************************
251 * PROPSHEET_FindPageByResId
253 * Find page index corresponding to page resource id.
255 static INT
PROPSHEET_FindPageByResId(const PropSheetInfo
* psInfo
, LRESULT resId
)
259 for (i
= 0; i
< psInfo
->nPages
; i
++)
261 LPCPROPSHEETPAGEA lppsp
= (LPCPROPSHEETPAGEA
)psInfo
->proppage
[i
].hpage
;
263 /* Fixme: if resource ID is a string shall we use strcmp ??? */
264 if (lppsp
->u
.pszTemplate
== (LPVOID
)resId
)
271 /******************************************************************************
274 * Convert ASCII to Unicode since all data is saved as Unicode.
276 static void PROPSHEET_AtoW(LPCWSTR
*tostr
, LPCSTR frstr
)
281 TRACE("<%s>\n", frstr
);
282 len
= MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, 0, 0);
283 to
= Alloc(len
* sizeof(WCHAR
));
284 MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, to
, len
);
288 /******************************************************************************
289 * PROPSHEET_CollectSheetInfoA
291 * Collect relevant data.
293 static BOOL
PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh
,
294 PropSheetInfo
* psInfo
)
296 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERA
));
297 DWORD dwFlags
= lppsh
->dwFlags
;
299 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
300 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
301 psInfo
->hasFinish
= dwFlags
& PSH_WIZARDHASFINISH
;
302 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
)&& (lppsh
->pfnCallback
);
303 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
305 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
306 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",
307 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
,
308 debugstr_a(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
310 PROPSHEET_UnImplementedFlags(lppsh
->dwFlags
);
312 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
313 psInfo
->ppshheader
.pszCaption
= NULL
;
316 if (HIWORD(lppsh
->pszCaption
))
318 int len
= MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, NULL
, 0);
319 WCHAR
*caption
= Alloc( len
*sizeof (WCHAR
) );
321 MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, caption
, len
);
322 psInfo
->ppshheader
.pszCaption
= caption
;
325 psInfo
->nPages
= lppsh
->nPages
;
327 if (dwFlags
& PSH_USEPSTARTPAGE
)
329 TRACE("PSH_USEPSTARTPAGE is on\n");
330 psInfo
->active_page
= 0;
333 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
335 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
336 psInfo
->active_page
= 0;
339 psInfo
->hImageList
= 0;
340 psInfo
->activeValid
= FALSE
;
345 /******************************************************************************
346 * PROPSHEET_CollectSheetInfoW
348 * Collect relevant data.
350 static BOOL
PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
351 PropSheetInfo
* psInfo
)
353 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERW
));
354 DWORD dwFlags
= lppsh
->dwFlags
;
356 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
357 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
358 psInfo
->hasFinish
= dwFlags
& PSH_WIZARDHASFINISH
;
359 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
) && (lppsh
->pfnCallback
);
360 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
362 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
363 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",
364 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
, debugstr_w(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
366 PROPSHEET_UnImplementedFlags(lppsh
->dwFlags
);
368 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
369 psInfo
->ppshheader
.pszCaption
= NULL
;
372 if (HIWORD(lppsh
->pszCaption
))
374 int len
= strlenW(lppsh
->pszCaption
);
375 WCHAR
*caption
= Alloc( (len
+1)*sizeof(WCHAR
) );
377 psInfo
->ppshheader
.pszCaption
= strcpyW( caption
, lppsh
->pszCaption
);
380 psInfo
->nPages
= lppsh
->nPages
;
382 if (dwFlags
& PSH_USEPSTARTPAGE
)
384 TRACE("PSH_USEPSTARTPAGE is on\n");
385 psInfo
->active_page
= 0;
388 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
390 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
391 psInfo
->active_page
= 0;
394 psInfo
->hImageList
= 0;
395 psInfo
->activeValid
= FALSE
;
400 /******************************************************************************
401 * PROPSHEET_CollectPageInfo
403 * Collect property sheet data.
404 * With code taken from DIALOG_ParseTemplate32.
406 static BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
407 PropSheetInfo
* psInfo
,
410 const DLGTEMPLATE
* pTemplate
;
419 psInfo
->proppage
[index
].hpage
= (HPROPSHEETPAGE
)lppsp
;
420 psInfo
->proppage
[index
].hwndPage
= 0;
421 psInfo
->proppage
[index
].isDirty
= FALSE
;
424 * Process property page flags.
426 dwFlags
= lppsp
->dwFlags
;
427 psInfo
->proppage
[index
].useCallback
= (dwFlags
& PSP_USECALLBACK
) && (lppsp
->pfnCallback
);
428 psInfo
->proppage
[index
].hasHelp
= dwFlags
& PSP_HASHELP
;
429 psInfo
->proppage
[index
].hasIcon
= dwFlags
& (PSP_USEHICON
| PSP_USEICONID
);
431 /* as soon as we have a page with the help flag, set the sheet flag on */
432 if (psInfo
->proppage
[index
].hasHelp
)
433 psInfo
->hasHelp
= TRUE
;
436 * Process page template.
438 if (dwFlags
& PSP_DLGINDIRECT
)
439 pTemplate
= lppsp
->u
.pResource
;
440 else if(dwFlags
& PSP_INTERNAL_UNICODE
)
442 HRSRC hResource
= FindResourceW(lppsp
->hInstance
,
443 lppsp
->u
.pszTemplate
,
445 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
447 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
451 HRSRC hResource
= FindResourceA(lppsp
->hInstance
,
452 (LPCSTR
)lppsp
->u
.pszTemplate
,
454 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
456 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
460 * Extract the size of the page and the caption.
465 p
= (const WORD
*)pTemplate
;
467 if (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
469 /* DLGTEMPLATEEX (not defined in any std. header file) */
473 p
+= 2; /* help ID */
474 p
+= 2; /* ext style */
482 p
+= 2; /* ext style */
488 width
= (WORD
)*p
; p
++;
489 height
= (WORD
)*p
; p
++;
491 /* Special calculation for interior wizard pages so the largest page is
492 * calculated correctly. We need to add all the padding and space occupied
493 * by the header so the width and height sums up to the whole wizard client
495 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
496 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
497 !(dwFlags
& PSP_HIDEHEADER
))
499 height
+= 2 * WIZARD_PADDING
+ WIZARD_HEADER_HEIGHT
;
500 width
+= 2 * WIZARD_PADDING
;
502 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
)
504 height
+= 2 * WIZARD_PADDING
;
505 width
+= 2 * WIZARD_PADDING
;
508 /* remember the largest width and height */
509 if (width
> psInfo
->width
)
510 psInfo
->width
= width
;
512 if (height
> psInfo
->height
)
513 psInfo
->height
= height
;
525 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
539 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
543 /* Extract the caption */
544 psInfo
->proppage
[index
].pszText
= (LPCWSTR
)p
;
545 TRACE("Tab %d %s\n",index
,debugstr_w((LPCWSTR
)p
));
546 p
+= lstrlenW((LPCWSTR
)p
) + 1;
548 if (dwFlags
& PSP_USETITLE
)
552 static const WCHAR pszNull
[] = { '(','n','u','l','l',')',0 };
556 if ( !HIWORD( lppsp
->pszTitle
) )
558 if (!LoadStringW( lppsp
->hInstance
, (DWORD_PTR
)lppsp
->pszTitle
,szTitle
,sizeof(szTitle
) ))
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
;
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 = (LPVOID
)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 (LPDLGTEMPLATEW
) temp
,
677 psInfo
->ppshheader
.hwndParent
,
678 PROPSHEET_DialogProc
,
680 if ( !ret
) ret
= -1;
684 ret
= (INT_PTR
)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
685 (LPDLGTEMPLATEA
) temp
,
686 psInfo
->ppshheader
.hwndParent
,
687 PROPSHEET_DialogProc
,
689 if ( !ret
) ret
= -1;
697 /******************************************************************************
698 * PROPSHEET_SizeMismatch
700 * Verify that the tab control and the "largest" property sheet page dlg. template
703 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
705 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
706 RECT rcOrigTab
, rcPage
;
711 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
712 TRACE("orig tab %d %d %d %d\n", rcOrigTab
.left
, rcOrigTab
.top
,
713 rcOrigTab
.right
, rcOrigTab
.bottom
);
720 rcPage
.right
= psInfo
->width
;
721 rcPage
.bottom
= psInfo
->height
;
723 MapDialogRect(hwndDlg
, &rcPage
);
724 TRACE("biggest page %d %d %d %d\n", rcPage
.left
, rcPage
.top
,
725 rcPage
.right
, rcPage
.bottom
);
727 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
729 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
735 /******************************************************************************
736 * PROPSHEET_AdjustSize
738 * Resizes the property sheet and the tab control to fit the largest page.
740 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
742 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
743 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
745 int tabOffsetX
, tabOffsetY
, buttonHeight
;
746 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
749 /* Get the height of buttons */
750 GetClientRect(hwndButton
, &rc
);
751 buttonHeight
= rc
.bottom
;
758 rc
.right
= psInfo
->width
;
759 rc
.bottom
= psInfo
->height
;
761 MapDialogRect(hwndDlg
, &rc
);
763 /* retrieve the dialog units */
764 units
.left
= units
.right
= 4;
765 units
.top
= units
.bottom
= 8;
766 MapDialogRect(hwndDlg
, &units
);
769 * Resize the tab control.
771 GetClientRect(hwndTabCtrl
,&tabRect
);
773 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
775 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
777 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
778 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
781 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
783 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
784 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
787 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
789 tabOffsetX
= -(rc
.left
);
790 tabOffsetY
= -(rc
.top
);
794 TRACE("setting tab %p, rc (0,0)-(%d,%d)\n",
795 hwndTabCtrl
, rc
.right
, rc
.bottom
);
796 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
797 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
799 GetClientRect(hwndTabCtrl
, &rc
);
801 TRACE("tab client rc %d %d %d %d\n",
802 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
804 rc
.right
+= ((padding
.x
* 2) + tabOffsetX
);
805 rc
.bottom
+= (buttonHeight
+ (3 * padding
.y
) + tabOffsetY
);
808 * Resize the property sheet.
810 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
811 hwndDlg
, rc
.right
, rc
.bottom
);
812 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
813 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
817 /******************************************************************************
818 * PROPSHEET_AdjustSizeWizard
820 * Resizes the property sheet to fit the largest page.
822 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
824 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
825 RECT rc
, lineRect
, dialogRect
;
827 /* Biggest page size */
830 rc
.right
= psInfo
->width
;
831 rc
.bottom
= psInfo
->height
;
832 MapDialogRect(hwndDlg
, &rc
);
834 TRACE("Biggest page %d %d %d %d\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
836 /* Add space for the buttons row */
837 GetWindowRect(hwndLine
, &lineRect
);
838 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
839 GetClientRect(hwndDlg
, &dialogRect
);
840 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
842 /* Convert the client coordinates to window coordinates */
843 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
845 /* Resize the property sheet */
846 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
847 hwndDlg
, rc
.right
, rc
.bottom
);
848 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
849 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
854 /******************************************************************************
855 * PROPSHEET_AdjustButtons
857 * Adjusts the buttons' positions.
859 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, const PropSheetInfo
* psInfo
)
861 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
865 int buttonWidth
, buttonHeight
;
866 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
868 if (psInfo
->hasApply
)
875 * Obtain the size of the buttons.
877 GetClientRect(hwndButton
, &rcSheet
);
878 buttonWidth
= rcSheet
.right
;
879 buttonHeight
= rcSheet
.bottom
;
882 * Get the size of the property sheet.
884 GetClientRect(hwndParent
, &rcSheet
);
887 * All buttons will be at this y coordinate.
889 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
892 * Position OK button and make it default.
894 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
896 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
898 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
899 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
901 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
905 * Position Cancel button.
907 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
909 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1));
911 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
912 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
915 * Position Apply button.
917 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
919 if (psInfo
->hasApply
)
922 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * 2);
924 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
926 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
927 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
929 EnableWindow(hwndButton
, FALSE
);
932 ShowWindow(hwndButton
, SW_HIDE
);
935 * Position Help button.
937 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
941 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
943 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
944 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
947 ShowWindow(hwndButton
, SW_HIDE
);
952 /******************************************************************************
953 * PROPSHEET_AdjustButtonsWizard
955 * Adjusts the buttons' positions.
957 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
958 const PropSheetInfo
* psInfo
)
960 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
961 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
962 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
966 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
967 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
971 if (psInfo
->hasFinish
)
975 * Obtain the size of the buttons.
977 GetClientRect(hwndButton
, &rcSheet
);
978 buttonWidth
= rcSheet
.right
;
979 buttonHeight
= rcSheet
.bottom
;
981 GetClientRect(hwndLine
, &rcSheet
);
982 lineHeight
= rcSheet
.bottom
;
985 * Get the size of the property sheet.
987 GetClientRect(hwndParent
, &rcSheet
);
990 * All buttons will be at this y coordinate.
992 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
995 * Position the Back button.
997 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
999 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1)) - buttonWidth
;
1001 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1002 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1005 * Position the Next button.
1007 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
1011 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1012 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1015 * Position the Finish button.
1017 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
1019 if (psInfo
->hasFinish
)
1020 x
+= padding
.x
+ buttonWidth
;
1022 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1023 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1025 if (!psInfo
->hasFinish
)
1026 ShowWindow(hwndButton
, SW_HIDE
);
1029 * Position the Cancel button.
1031 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1033 x
+= padding
.x
+ buttonWidth
;
1035 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1036 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1039 * Position Help button.
1041 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1043 if (psInfo
->hasHelp
)
1045 x
+= padding
.x
+ buttonWidth
;
1047 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1048 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1051 ShowWindow(hwndButton
, SW_HIDE
);
1053 if (psInfo
->ppshheader
.dwFlags
&
1054 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1058 * Position and resize the sunken line.
1061 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1063 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1064 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1065 SWP_NOZORDER
| SWP_NOACTIVATE
);
1068 * Position and resize the header sunken line.
1071 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1072 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1073 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1074 ShowWindow(hwndLineHeader
, SW_HIDE
);
1079 /******************************************************************************
1080 * PROPSHEET_GetPaddingInfo
1082 * Returns the layout information.
1084 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1086 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1089 PADDING_INFO padding
;
1091 GetWindowRect(hwndTab
, &rcTab
);
1096 ScreenToClient(hwndDlg
, &tl
);
1104 /******************************************************************************
1105 * PROPSHEET_GetPaddingInfoWizard
1107 * Returns the layout information.
1108 * Vertical spacing is the distance between the line and the buttons.
1109 * Do NOT use the Help button to gather padding information when it isn't mapped
1110 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1111 * for it in this case !
1112 * FIXME: I'm not sure about any other coordinate problems with these evil
1113 * buttons. Fix it in case additional problems appear or maybe calculate
1114 * a padding in a completely different way, as this is somewhat messy.
1116 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1119 PADDING_INFO padding
;
1123 POINT ptButton
, ptLine
;
1126 if (psInfo
->hasHelp
)
1132 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1134 idButton
= IDC_NEXT_BUTTON
;
1138 /* hopefully this is ok */
1139 idButton
= IDCANCEL
;
1143 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1144 GetWindowRect(hwndControl
, &rc
);
1146 ptButton
.x
= rc
.left
;
1147 ptButton
.y
= rc
.top
;
1149 ScreenToClient(hwndDlg
, &ptButton
);
1152 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1153 GetWindowRect(hwndControl
, &rc
);
1156 ptLine
.y
= rc
.bottom
;
1158 ScreenToClient(hwndDlg
, &ptLine
);
1160 padding
.y
= ptButton
.y
- ptLine
.y
;
1163 ERR("padding negative ! Please report this !\n");
1165 /* this is most probably not correct, but the best we have now */
1166 padding
.x
= padding
.y
;
1170 /******************************************************************************
1171 * PROPSHEET_CreateTabControl
1173 * Insert the tabs in the tab control.
1175 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1176 const PropSheetInfo
* psInfo
)
1178 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1184 item
.mask
= TCIF_TEXT
;
1185 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1187 nTabs
= psInfo
->nPages
;
1190 * Set the image list for icons.
1192 if (psInfo
->hImageList
)
1194 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1197 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 0, 0);
1198 for (i
= 0; i
< nTabs
; i
++)
1200 if ( psInfo
->proppage
[i
].hasIcon
)
1202 item
.mask
|= TCIF_IMAGE
;
1203 item
.iImage
= iImage
++;
1207 item
.mask
&= ~TCIF_IMAGE
;
1210 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1211 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, (WPARAM
)i
, (LPARAM
)&item
);
1213 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 1, 0);
1218 /******************************************************************************
1219 * PROPSHEET_WizardSubclassProc
1221 * Subclassing window procedure for wizard extrior pages to prevent drawing
1222 * background and so drawing above the watermark.
1224 static LRESULT CALLBACK
1225 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1232 case WM_CTLCOLORSTATIC
:
1233 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1234 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1237 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1241 * Get the size of an in-memory Template
1243 *( Based on the code of PROPSHEET_CollectPageInfo)
1244 * See also dialog.c/DIALOG_ParseTemplate32().
1247 static UINT
GetTemplateSize(const DLGTEMPLATE
* pTemplate
)
1250 const WORD
* p
= (const WORD
*)pTemplate
;
1251 BOOL istemplateex
= (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1257 /* DLGTEMPLATEEX (not defined in any std. header file) */
1259 TRACE("is DLGTEMPLATEEX\n");
1261 p
++; /* signature */
1262 p
+= 2; /* help ID */
1263 p
+= 2; /* ext style */
1270 TRACE("is DLGTEMPLATE\n");
1272 p
+= 2; /* ext style */
1275 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1291 TRACE("menu %s\n",debugstr_w((LPCWSTR
)p
));
1292 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1303 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1306 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1307 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1312 TRACE("title %s\n",debugstr_w((LPCWSTR
)p
));
1313 p
+= lstrlenW((LPCWSTR
)p
) + 1;
1315 /* font, if DS_SETFONT set */
1316 if ((DS_SETFONT
& ((istemplateex
)? ((const MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1319 p
+=(istemplateex
)?3:1;
1320 TRACE("font %s\n",debugstr_w((LPCWSTR
)p
));
1321 p
+= lstrlenW( (LPCWSTR
)p
) + 1; /* the font name */
1324 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1325 * that are following the DLGTEMPLATE(EX) data */
1326 TRACE("%d items\n",nrofitems
);
1327 while (nrofitems
> 0)
1329 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1332 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1341 TRACE("class ordinal 0x%08x\n",*(const DWORD
*)p
);
1345 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1346 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1350 /* check title text */
1357 TRACE("text ordinal 0x%08x\n",*(const DWORD
*)p
);
1361 TRACE("text %s\n",debugstr_w((LPCWSTR
)p
));
1362 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1365 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1369 ret
= (p
- (const WORD
*)pTemplate
) * sizeof(WORD
);
1370 TRACE("%p %p size 0x%08x\n", p
, pTemplate
, ret
);
1374 /******************************************************************************
1375 * PROPSHEET_CreatePage
1379 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1381 const PropSheetInfo
* psInfo
,
1382 LPCPROPSHEETPAGEW ppshpage
)
1384 DLGTEMPLATE
* pTemplate
;
1389 TRACE("index %d\n", index
);
1391 if (ppshpage
== NULL
)
1396 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1398 pTemplate
= (DLGTEMPLATE
*)ppshpage
->u
.pResource
;
1399 resSize
= GetTemplateSize(pTemplate
);
1401 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1406 hResource
= FindResourceW(ppshpage
->hInstance
,
1407 ppshpage
->u
.pszTemplate
,
1412 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1414 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1418 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
1420 * Make a copy of the dialog template to make it writable
1428 hResource
= FindResourceA(ppshpage
->hInstance
,
1429 (LPCSTR
)ppshpage
->u
.pszTemplate
,
1434 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1436 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1440 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
1442 * Make a copy of the dialog template to make it writable
1445 temp
= Alloc(resSize
);
1449 TRACE("copying pTemplate %p into temp %p (%d)\n", pTemplate
, temp
, resSize
);
1450 memcpy(temp
, pTemplate
, resSize
);
1453 if (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
1455 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1456 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~DS_MODALFRAME
;
1457 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_CAPTION
;
1458 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_SYSMENU
;
1459 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_POPUP
;
1460 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_DISABLED
;
1461 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_VISIBLE
;
1462 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_THICKFRAME
;
1464 ((MyDLGTEMPLATEEX
*)pTemplate
)->exStyle
|= WS_EX_CONTROLPARENT
;
1468 pTemplate
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1469 pTemplate
->style
&= ~DS_MODALFRAME
;
1470 pTemplate
->style
&= ~WS_CAPTION
;
1471 pTemplate
->style
&= ~WS_SYSMENU
;
1472 pTemplate
->style
&= ~WS_POPUP
;
1473 pTemplate
->style
&= ~WS_DISABLED
;
1474 pTemplate
->style
&= ~WS_VISIBLE
;
1475 pTemplate
->style
&= ~WS_THICKFRAME
;
1477 pTemplate
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1480 if (psInfo
->proppage
[index
].useCallback
)
1481 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1482 (LPPROPSHEETPAGEW
)ppshpage
);
1484 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1485 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1488 ppshpage
->pfnDlgProc
,
1491 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1494 ppshpage
->pfnDlgProc
,
1496 /* Free a no more needed copy */
1499 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1501 /* Subclass exterior wizard pages */
1502 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1503 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1504 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1506 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1507 (DWORD_PTR
)ppshpage
);
1509 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1510 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1515 /******************************************************************************
1516 * PROPSHEET_LoadWizardBitmaps
1518 * Loads the watermark and header bitmaps for a wizard.
1520 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1522 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1524 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1525 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1526 considers hbmWatermark as valid. */
1527 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1528 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1530 ((PropSheetInfo
*)psInfo
)->ppshheader
.u4
.hbmWatermark
=
1531 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1534 /* Same behavior as for watermarks */
1535 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1536 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1538 ((PropSheetInfo
*)psInfo
)->ppshheader
.u5
.hbmHeader
=
1539 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1545 /******************************************************************************
1546 * PROPSHEET_ShowPage
1548 * Displays or creates the specified page.
1550 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1553 HWND hwndLineHeader
;
1554 LPCPROPSHEETPAGEW ppshpage
;
1556 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1557 if (index
== psInfo
->active_page
)
1559 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1560 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1564 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1565 if (psInfo
->proppage
[index
].hwndPage
== 0)
1567 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1570 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1572 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1573 psInfo
->proppage
[index
].pszText
);
1576 if (psInfo
->active_page
!= -1)
1577 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1579 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1581 /* Synchronize current selection with tab control
1582 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1583 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1584 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1586 psInfo
->active_page
= index
;
1587 psInfo
->activeValid
= TRUE
;
1589 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1591 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1592 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1594 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1595 ShowWindow(hwndLineHeader
, SW_HIDE
);
1597 ShowWindow(hwndLineHeader
, SW_SHOW
);
1603 /******************************************************************************
1606 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1610 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1615 TRACE("active_page %d\n", psInfo
->active_page
);
1616 if (psInfo
->active_page
< 0)
1619 psn
.hdr
.code
= PSN_WIZBACK
;
1620 psn
.hdr
.hwndFrom
= hwndDlg
;
1624 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1626 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1629 else if (result
== 0)
1630 idx
= psInfo
->active_page
- 1;
1632 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1634 if (idx
>= 0 && idx
< psInfo
->nPages
)
1636 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1637 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1642 /******************************************************************************
1645 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1649 LRESULT msgResult
= 0;
1650 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1654 TRACE("active_page %d\n", psInfo
->active_page
);
1655 if (psInfo
->active_page
< 0)
1658 psn
.hdr
.code
= PSN_WIZNEXT
;
1659 psn
.hdr
.hwndFrom
= hwndDlg
;
1663 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1665 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1666 if (msgResult
== -1)
1668 else if (msgResult
== 0)
1669 idx
= psInfo
->active_page
+ 1;
1671 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1673 if (idx
< psInfo
->nPages
)
1675 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1676 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1682 /******************************************************************************
1685 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1689 LRESULT msgResult
= 0;
1690 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1693 TRACE("active_page %d\n", psInfo
->active_page
);
1694 if (psInfo
->active_page
< 0)
1697 psn
.hdr
.code
= PSN_WIZFINISH
;
1698 psn
.hdr
.hwndFrom
= hwndDlg
;
1702 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1704 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1706 TRACE("msg result %ld\n", msgResult
);
1711 if (psInfo
->result
== 0)
1712 psInfo
->result
= IDOK
;
1713 if (psInfo
->isModeless
)
1714 psInfo
->activeValid
= FALSE
;
1716 psInfo
->ended
= TRUE
;
1721 /******************************************************************************
1724 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1729 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1732 TRACE("active_page %d\n", psInfo
->active_page
);
1733 if (psInfo
->active_page
< 0)
1736 psn
.hdr
.hwndFrom
= hwndDlg
;
1742 * Send PSN_KILLACTIVE to the current page.
1744 psn
.hdr
.code
= PSN_KILLACTIVE
;
1746 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1748 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1752 * Send PSN_APPLY to all pages.
1754 psn
.hdr
.code
= PSN_APPLY
;
1755 psn
.lParam
= lParam
;
1757 for (i
= 0; i
< psInfo
->nPages
; i
++)
1759 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1762 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1764 case PSNRET_INVALID
:
1765 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1767 case PSNRET_INVALID_NOCHANGEPAGE
:
1775 psInfo
->activeValid
= FALSE
;
1777 else if(psInfo
->active_page
>= 0)
1779 psn
.hdr
.code
= PSN_SETACTIVE
;
1781 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1782 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1788 /******************************************************************************
1791 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1793 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1799 TRACE("active_page %d\n", psInfo
->active_page
);
1800 if (psInfo
->active_page
< 0)
1803 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1804 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1805 psn
.hdr
.hwndFrom
= hwndDlg
;
1809 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1812 psn
.hdr
.code
= PSN_RESET
;
1813 psn
.lParam
= lParam
;
1815 for (i
= 0; i
< psInfo
->nPages
; i
++)
1817 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1820 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1823 if (psInfo
->isModeless
)
1825 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1826 psInfo
->activeValid
= FALSE
;
1829 psInfo
->ended
= TRUE
;
1832 /******************************************************************************
1835 static void PROPSHEET_Help(HWND hwndDlg
)
1837 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1842 TRACE("active_page %d\n", psInfo
->active_page
);
1843 if (psInfo
->active_page
< 0)
1846 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1847 psn
.hdr
.code
= PSN_HELP
;
1848 psn
.hdr
.hwndFrom
= hwndDlg
;
1852 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1855 /******************************************************************************
1858 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1861 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1865 if (!psInfo
) return;
1867 * Set the dirty flag of this page.
1869 for (i
= 0; i
< psInfo
->nPages
; i
++)
1871 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1872 psInfo
->proppage
[i
].isDirty
= TRUE
;
1876 * Enable the Apply button.
1878 if (psInfo
->hasApply
)
1880 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1882 EnableWindow(hwndApplyBtn
, TRUE
);
1886 /******************************************************************************
1887 * PROPSHEET_UnChanged
1889 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1892 BOOL noPageDirty
= TRUE
;
1893 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1894 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1898 if ( !psInfo
) return;
1899 for (i
= 0; i
< psInfo
->nPages
; i
++)
1901 /* set the specified page as clean */
1902 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1903 psInfo
->proppage
[i
].isDirty
= FALSE
;
1905 /* look to see if there's any dirty pages */
1906 if (psInfo
->proppage
[i
].isDirty
)
1907 noPageDirty
= FALSE
;
1911 * Disable Apply button.
1914 EnableWindow(hwndApplyBtn
, FALSE
);
1917 /******************************************************************************
1918 * PROPSHEET_PressButton
1920 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1922 TRACE("buttonID %d\n", buttonID
);
1925 case PSBTN_APPLYNOW
:
1926 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1929 PROPSHEET_Back(hwndDlg
);
1932 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1935 PROPSHEET_Finish(hwndDlg
);
1938 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1941 PROPSHEET_Next(hwndDlg
);
1944 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1947 FIXME("Invalid button index %d\n", buttonID
);
1952 /*************************************************************************
1953 * BOOL PROPSHEET_CanSetCurSel [Internal]
1955 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1958 * hwndDlg [I] handle to a Dialog hWnd
1961 * TRUE if Current Selection can change
1965 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
1967 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1973 TRACE("active_page %d\n", psInfo
->active_page
);
1980 if (psInfo
->active_page
< 0)
1987 * Notify the current page.
1989 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1990 psn
.hdr
.code
= PSN_KILLACTIVE
;
1991 psn
.hdr
.hwndFrom
= hwndDlg
;
1995 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1998 TRACE("<-- %d\n", res
);
2002 /******************************************************************************
2003 * PROPSHEET_SetCurSel
2005 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
2008 HPROPSHEETPAGE hpage
2011 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2012 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
2013 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2015 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
2016 /* hpage takes precedence over index */
2018 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2020 if (index
< 0 || index
>= psInfo
->nPages
)
2022 TRACE("Could not find page to select!\n");
2026 /* unset active page while doing this transition. */
2027 if (psInfo
->active_page
!= -1)
2028 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
2029 psInfo
->active_page
= -1;
2035 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2038 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
2040 psn
.hdr
.code
= PSN_SETACTIVE
;
2041 psn
.hdr
.hwndFrom
= hwndDlg
;
2045 if (!psInfo
->proppage
[index
].hwndPage
) {
2046 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
2049 /* Resize the property sheet page to the fit in the Tab control
2050 * (for regular property sheets) or to fit in the client area (for
2052 * NOTE: The resizing happens every time the page is selected and
2053 * not only when it's created (some applications depend on it). */
2054 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2055 TRACE("setting page %p, rc (%d,%d)-(%d,%d) w=%d, h=%d\n",
2056 psInfo
->proppage
[index
].hwndPage
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
2057 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2058 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2060 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2062 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2069 WARN("Tried to skip before first property sheet page!\n");
2072 if (index
>= psInfo
->nPages
) {
2073 WARN("Tried to skip after last property sheet page!\n");
2074 index
= psInfo
->nPages
-1;
2078 else if (result
!= 0)
2080 int old_index
= index
;
2081 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2082 if(index
>= psInfo
->nPages
) {
2084 WARN("Tried to skip to nonexistant page by res id\n");
2091 /* Invalidate the header area */
2092 if ( (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
2093 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
2095 HWND hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
2098 GetClientRect(hwndLineHeader
, &r
);
2099 MapWindowPoints(hwndLineHeader
, hwndDlg
, (LPPOINT
) &r
, 2);
2100 SetRect(&r
, 0, 0, r
.right
+ 1, r
.top
- 1);
2102 InvalidateRect(hwndDlg
, &r
, TRUE
);
2106 * Display the new page.
2108 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2110 if (psInfo
->proppage
[index
].hasHelp
)
2111 EnableWindow(hwndHelp
, TRUE
);
2113 EnableWindow(hwndHelp
, FALSE
);
2118 /******************************************************************************
2119 * PROPSHEET_SetCurSelId
2121 * Selects the page, specified by resource id.
2123 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2126 PropSheetInfo
* psInfo
=
2127 (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2129 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2130 if (idx
< psInfo
->nPages
)
2132 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2133 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2137 /******************************************************************************
2138 * PROPSHEET_SetTitleA
2140 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2142 if(HIWORD(lpszText
))
2145 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2146 szTitle
, sizeof(szTitle
)/sizeof(WCHAR
));
2147 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2151 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2155 /******************************************************************************
2156 * PROPSHEET_SetTitleW
2158 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2160 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2163 TRACE("%s (style %08x)\n", debugstr_w(lpszText
), dwStyle
);
2164 if (HIWORD(lpszText
) == 0) {
2165 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2166 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)-sizeof(WCHAR
)))
2170 if (dwStyle
& PSH_PROPTITLE
)
2173 int lentitle
= strlenW(lpszText
);
2174 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2176 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2177 wsprintfW(dest
, psInfo
->strPropertiesFor
, lpszText
);
2179 SetWindowTextW(hwndDlg
, dest
);
2183 SetWindowTextW(hwndDlg
, lpszText
);
2186 /******************************************************************************
2187 * PROPSHEET_SetFinishTextA
2189 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2191 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2192 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2194 TRACE("'%s'\n", lpszText
);
2195 /* Set text, show and enable the Finish button */
2196 SetWindowTextA(hwndButton
, lpszText
);
2197 ShowWindow(hwndButton
, SW_SHOW
);
2198 EnableWindow(hwndButton
, TRUE
);
2200 /* Make it default pushbutton */
2201 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2203 /* Hide Back button */
2204 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2205 ShowWindow(hwndButton
, SW_HIDE
);
2207 if (!psInfo
->hasFinish
)
2209 /* Hide Next button */
2210 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2211 ShowWindow(hwndButton
, SW_HIDE
);
2215 /******************************************************************************
2216 * PROPSHEET_SetFinishTextW
2218 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2220 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2221 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2223 TRACE("%s\n", debugstr_w(lpszText
));
2224 /* Set text, show and enable the Finish button */
2225 SetWindowTextW(hwndButton
, lpszText
);
2226 ShowWindow(hwndButton
, SW_SHOW
);
2227 EnableWindow(hwndButton
, TRUE
);
2229 /* Make it default pushbutton */
2230 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2232 /* Hide Back button */
2233 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2234 ShowWindow(hwndButton
, SW_HIDE
);
2236 if (!psInfo
->hasFinish
)
2238 /* Hide Next button */
2239 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2240 ShowWindow(hwndButton
, SW_HIDE
);
2244 /******************************************************************************
2245 * PROPSHEET_QuerySiblings
2247 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2248 WPARAM wParam
, LPARAM lParam
)
2252 LRESULT msgResult
= 0;
2253 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2255 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2257 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2258 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2266 /******************************************************************************
2269 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
2270 HPROPSHEETPAGE hpage
)
2273 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2275 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2277 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2279 TRACE("hpage %p\n", hpage
);
2281 * Allocate and fill in a new PropPageInfo entry.
2283 ppi
= (PropPageInfo
*) ReAlloc(psInfo
->proppage
,
2284 sizeof(PropPageInfo
) *
2285 (psInfo
->nPages
+ 1));
2289 psInfo
->proppage
= ppi
;
2290 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, psInfo
->nPages
))
2293 psInfo
->proppage
[psInfo
->nPages
].hpage
= hpage
;
2295 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2297 /* Create the page but don't show it */
2298 PROPSHEET_CreatePage(hwndDlg
, psInfo
->nPages
, psInfo
, ppsp
);
2302 * Add a new tab to the tab control.
2304 item
.mask
= TCIF_TEXT
;
2305 item
.pszText
= (LPWSTR
) psInfo
->proppage
[psInfo
->nPages
].pszText
;
2306 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2308 if (psInfo
->hImageList
)
2310 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2313 if ( psInfo
->proppage
[psInfo
->nPages
].hasIcon
)
2315 item
.mask
|= TCIF_IMAGE
;
2316 item
.iImage
= psInfo
->nPages
;
2319 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, psInfo
->nPages
+ 1,
2324 /* If it is the only page - show it */
2325 if(psInfo
->nPages
== 1)
2326 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2330 /******************************************************************************
2331 * PROPSHEET_RemovePage
2333 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2335 HPROPSHEETPAGE hpage
)
2337 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2339 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2340 PropPageInfo
* oldPages
;
2342 TRACE("index %d, hpage %p\n", index
, hpage
);
2347 * hpage takes precedence over index.
2351 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2354 /* Make sure that index is within range */
2355 if (index
< 0 || index
>= psInfo
->nPages
)
2357 TRACE("Could not find page to remove!\n");
2361 TRACE("total pages %d removing page %d active page %d\n",
2362 psInfo
->nPages
, index
, psInfo
->active_page
);
2364 * Check if we're removing the active page.
2366 if (index
== psInfo
->active_page
)
2368 if (psInfo
->nPages
> 1)
2372 /* activate previous page */
2373 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2377 /* activate the next page */
2378 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2379 psInfo
->active_page
= index
;
2384 psInfo
->active_page
= -1;
2385 if (!psInfo
->isModeless
)
2387 psInfo
->ended
= TRUE
;
2392 else if (index
< psInfo
->active_page
)
2393 psInfo
->active_page
--;
2395 /* Unsubclass the page dialog window */
2396 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2397 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2398 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2400 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2401 PROPSHEET_WizardSubclassProc
, 1);
2404 /* Destroy page dialog window */
2405 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2407 /* Free page resources */
2408 if(psInfo
->proppage
[index
].hpage
)
2410 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2412 if (psp
->dwFlags
& PSP_USETITLE
)
2413 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2415 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2418 /* Remove the tab */
2419 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2421 oldPages
= psInfo
->proppage
;
2423 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2426 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2428 if (index
< psInfo
->nPages
)
2429 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2430 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2437 /******************************************************************************
2438 * PROPSHEET_SetWizButtons
2440 * This code will work if (and assumes that) the Next button is on top of the
2441 * Finish button. ie. Finish comes after Next in the Z order.
2442 * This means make sure the dialog template reflects this.
2445 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2447 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2449 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2450 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2451 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2453 TRACE("%d\n", dwFlags
);
2455 EnableWindow(hwndBack
, FALSE
);
2456 EnableWindow(hwndNext
, FALSE
);
2457 EnableWindow(hwndFinish
, FALSE
);
2459 /* set the default pushbutton to an enabled button */
2460 if (((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
))
2461 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2462 else if (dwFlags
& PSWIZB_NEXT
)
2463 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2464 else if (dwFlags
& PSWIZB_BACK
)
2465 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
2467 SendMessageW(hwndDlg
, DM_SETDEFID
, IDCANCEL
, 0);
2470 if (dwFlags
& PSWIZB_BACK
)
2471 EnableWindow(hwndBack
, TRUE
);
2473 if (dwFlags
& PSWIZB_NEXT
)
2474 EnableWindow(hwndNext
, TRUE
);
2476 if (!psInfo
->hasFinish
)
2478 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2480 /* Hide the Next button */
2481 ShowWindow(hwndNext
, SW_HIDE
);
2483 /* Show the Finish button */
2484 ShowWindow(hwndFinish
, SW_SHOW
);
2486 if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2487 EnableWindow(hwndFinish
, TRUE
);
2491 /* Hide the Finish button */
2492 ShowWindow(hwndFinish
, SW_HIDE
);
2493 /* Show the Next button */
2494 ShowWindow(hwndNext
, SW_SHOW
);
2497 else if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2498 EnableWindow(hwndFinish
, TRUE
);
2501 /******************************************************************************
2502 * PROPSHEET_InsertPage
2504 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2506 if (!HIWORD(hpageInsertAfter
))
2507 FIXME("(%p, %d, %p): stub\n", hwndDlg
, LOWORD(hpageInsertAfter
), hpage
);
2509 FIXME("(%p, %p, %p): stub\n", hwndDlg
, hpageInsertAfter
, hpage
);
2513 /******************************************************************************
2514 * PROPSHEET_SetHeaderTitleW
2516 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderTitle
)
2518 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderTitle
));
2521 /******************************************************************************
2522 * PROPSHEET_SetHeaderTitleA
2524 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderTitle
)
2526 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderTitle
));
2529 /******************************************************************************
2530 * PROPSHEET_SetHeaderSubTitleW
2532 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderSubTitle
)
2534 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderSubTitle
));
2537 /******************************************************************************
2538 * PROPSHEET_SetHeaderSubTitleA
2540 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderSubTitle
)
2542 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderSubTitle
));
2545 /******************************************************************************
2546 * PROPSHEET_HwndToIndex
2548 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2551 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2554 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2556 for (index
= 0; index
< psInfo
->nPages
; index
++)
2557 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2559 WARN("%p not found\n", hPageDlg
);
2563 /******************************************************************************
2564 * PROPSHEET_IndexToHwnd
2566 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2568 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2570 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2571 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2572 WARN("%d out of range.\n", iPageIndex
);
2575 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2578 /******************************************************************************
2579 * PROPSHEET_PageToIndex
2581 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2584 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2587 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2589 for (index
= 0; index
< psInfo
->nPages
; index
++)
2590 if (psInfo
->proppage
[index
].hpage
== hPage
)
2592 WARN("%p not found\n", hPage
);
2596 /******************************************************************************
2597 * PROPSHEET_IndexToPage
2599 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2601 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2603 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2604 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2605 WARN("%d out of range.\n", iPageIndex
);
2608 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2611 /******************************************************************************
2612 * PROPSHEET_IdToIndex
2614 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2617 LPCPROPSHEETPAGEW psp
;
2618 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2620 TRACE("(%p, %d)\n", hwndDlg
, iPageId
);
2621 for (index
= 0; index
< psInfo
->nPages
; index
++) {
2622 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2623 if (psp
->u
.pszTemplate
== MAKEINTRESOURCEW(iPageId
))
2630 /******************************************************************************
2631 * PROPSHEET_IndexToId
2633 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2635 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2637 LPCPROPSHEETPAGEW psp
;
2638 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2639 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2640 WARN("%d out of range.\n", iPageIndex
);
2643 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2644 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| HIWORD(psp
->u
.pszTemplate
)) {
2647 return (LRESULT
)psp
->u
.pszTemplate
;
2650 /******************************************************************************
2651 * PROPSHEET_GetResult
2653 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2655 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2657 return psInfo
->result
;
2660 /******************************************************************************
2661 * PROPSHEET_RecalcPageSizes
2663 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2665 FIXME("(%p): stub\n", hwndDlg
);
2669 /******************************************************************************
2670 * PROPSHEET_GetPageIndex
2672 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2673 * the array of PropPageInfo.
2675 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, const PropSheetInfo
* psInfo
)
2680 TRACE("hpage %p\n", hpage
);
2681 while ((index
< psInfo
->nPages
) && (found
== FALSE
))
2683 if (psInfo
->proppage
[index
].hpage
== hpage
)
2695 /******************************************************************************
2698 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2701 PropSheetInfo
* psInfo
= (PropSheetInfo
*) RemovePropW(hwndDlg
,
2705 if (!psInfo
) return;
2706 if (HIWORD(psInfo
->ppshheader
.pszCaption
))
2707 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2709 for (i
= 0; i
< psInfo
->nPages
; i
++)
2711 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2713 /* Unsubclass the page dialog window */
2714 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2715 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2716 (psp
->dwFlags
& PSP_HIDEHEADER
))
2718 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2719 PROPSHEET_WizardSubclassProc
, 1);
2722 if(psInfo
->proppage
[i
].hwndPage
)
2723 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2727 if (psp
->dwFlags
& PSP_USETITLE
)
2728 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2730 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2734 DeleteObject(psInfo
->hFont
);
2735 DeleteObject(psInfo
->hFontBold
);
2736 /* If we created the bitmaps, destroy them */
2737 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2738 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2739 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2740 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2741 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2742 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2744 Free(psInfo
->proppage
);
2745 Free(psInfo
->strPropertiesFor
);
2746 ImageList_Destroy(psInfo
->hImageList
);
2748 GlobalFree((HGLOBAL
)psInfo
);
2751 static INT
do_loop(const PropSheetInfo
*psInfo
)
2755 HWND hwnd
= psInfo
->hwnd
;
2757 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2762 if(!IsDialogMessageW(hwnd
, &msg
))
2764 TranslateMessage(&msg
);
2765 DispatchMessageW(&msg
);
2771 PostQuitMessage(msg
.wParam
);
2776 ret
= psInfo
->result
;
2778 DestroyWindow(hwnd
);
2782 /******************************************************************************
2783 * PROPSHEET_PropertySheet
2785 * Common code between PropertySheetA/W
2787 static INT_PTR
PROPSHEET_PropertySheet(PropSheetInfo
* psInfo
, BOOL unicode
)
2790 if (psInfo
->active_page
>= psInfo
->nPages
) psInfo
->active_page
= 0;
2791 TRACE("startpage: %d of %d pages\n", psInfo
->active_page
, psInfo
->nPages
);
2793 psInfo
->unicode
= unicode
;
2794 psInfo
->ended
= FALSE
;
2796 bRet
= PROPSHEET_CreateDialog(psInfo
);
2797 if(!psInfo
->isModeless
)
2799 HWND parent
= GetParent(psInfo
->hwnd
);
2800 if (parent
) EnableWindow(parent
, FALSE
);
2801 bRet
= do_loop(psInfo
);
2802 if (parent
) EnableWindow(parent
, TRUE
);
2807 /******************************************************************************
2808 * PropertySheet (COMCTL32.@)
2809 * PropertySheetA (COMCTL32.@)
2811 * Creates a property sheet in the specified property sheet header.
2814 * Modal property sheets: Positive if successful or -1 otherwise.
2815 * Modeless property sheets: Property sheet handle.
2817 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2818 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2820 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2822 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2823 sizeof(PropSheetInfo
));
2827 TRACE("(%p)\n", lppsh
);
2829 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2831 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2833 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2835 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2837 if (!(lppsh
->dwFlags
& PSH_PROPSHEETPAGE
))
2838 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2841 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2842 pByte
+= ((LPCPROPSHEETPAGEA
)pByte
)->dwSize
;
2845 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2848 if (lppsh
->dwFlags
& PSH_PROPSHEETPAGE
)
2849 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2855 return PROPSHEET_PropertySheet(psInfo
, FALSE
);
2858 /******************************************************************************
2859 * PropertySheetW (COMCTL32.@)
2861 * See PropertySheetA.
2863 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2865 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2866 sizeof(PropSheetInfo
));
2870 TRACE("(%p)\n", lppsh
);
2872 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2874 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2876 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2878 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2880 if (!(lppsh
->dwFlags
& PSH_PROPSHEETPAGE
))
2881 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2884 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2885 pByte
+= ((LPCPROPSHEETPAGEW
)pByte
)->dwSize
;
2888 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2891 if (lppsh
->dwFlags
& PSH_PROPSHEETPAGE
)
2892 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2898 return PROPSHEET_PropertySheet(psInfo
, TRUE
);
2901 static LPWSTR
load_string( HINSTANCE instance
, LPCWSTR str
)
2906 if (IS_INTRESOURCE(str
))
2911 WORD i
, id
= LOWORD(str
);
2913 if (!(hrsrc
= FindResourceW( instance
, MAKEINTRESOURCEW((id
>> 4) + 1), (LPWSTR
)RT_STRING
)))
2915 if (!(hmem
= LoadResource( instance
, hrsrc
))) return NULL
;
2916 if (!(ptr
= LockResource( hmem
))) return NULL
;
2917 for (i
= id
& 0x0f; i
> 0; i
--) ptr
+= *ptr
+ 1;
2919 if (!len
) return NULL
;
2920 ret
= Alloc( (len
+ 1) * sizeof(WCHAR
) );
2923 memcpy( ret
, ptr
+ 1, len
* sizeof(WCHAR
) );
2929 int len
= (strlenW(str
) + 1) * sizeof(WCHAR
);
2931 if (ret
) memcpy( ret
, str
, len
);
2937 /******************************************************************************
2938 * CreatePropertySheetPage (COMCTL32.@)
2939 * CreatePropertySheetPageA (COMCTL32.@)
2941 * Creates a new property sheet page.
2944 * Success: Handle to new property sheet page.
2948 * An application must use the PSM_ADDPAGE message to add the new page to
2949 * an existing property sheet.
2951 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2952 LPCPROPSHEETPAGEA lpPropSheetPage
)
2954 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2956 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEA
)));
2958 ppsp
->dwFlags
&= ~ PSP_INTERNAL_UNICODE
;
2960 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2962 if (HIWORD( ppsp
->u
.pszTemplate
))
2964 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
) + 1;
2965 char *template = Alloc( len
);
2967 ppsp
->u
.pszTemplate
= (LPWSTR
)strcpy( template, lpPropSheetPage
->u
.pszTemplate
);
2971 if (ppsp
->dwFlags
& PSP_USEICONID
)
2973 if (HIWORD( ppsp
->u2
.pszIcon
))
2974 PROPSHEET_AtoW(&ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2977 if (ppsp
->dwFlags
& PSP_USETITLE
)
2979 if (HIWORD( ppsp
->pszTitle
))
2980 PROPSHEET_AtoW( &ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2982 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
2985 ppsp
->pszTitle
= NULL
;
2987 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
2988 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
2990 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
2992 if (HIWORD( ppsp
->pszHeaderTitle
))
2993 PROPSHEET_AtoW(&ppsp
->pszHeaderTitle
, lpPropSheetPage
->pszHeaderTitle
);
2995 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
2998 ppsp
->pszHeaderTitle
= NULL
;
3000 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3002 if (HIWORD( ppsp
->pszHeaderSubTitle
))
3003 PROPSHEET_AtoW(&ppsp
->pszHeaderSubTitle
, lpPropSheetPage
->pszHeaderSubTitle
);
3005 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3008 ppsp
->pszHeaderSubTitle
= NULL
;
3010 return (HPROPSHEETPAGE
)ppsp
;
3013 /******************************************************************************
3014 * CreatePropertySheetPageW (COMCTL32.@)
3016 * See CreatePropertySheetA.
3018 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
3020 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
3022 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEW
)));
3024 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
3026 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
3028 if (HIWORD( ppsp
->u
.pszTemplate
))
3030 int len
= strlenW(lpPropSheetPage
->u
.pszTemplate
) + 1;
3031 WCHAR
*template = Alloc( len
* sizeof (WCHAR
) );
3033 ppsp
->u
.pszTemplate
= strcpyW( template, lpPropSheetPage
->u
.pszTemplate
);
3037 if ( ppsp
->dwFlags
& PSP_USEICONID
)
3039 if (HIWORD( ppsp
->u2
.pszIcon
))
3041 int len
= strlenW(lpPropSheetPage
->u2
.pszIcon
) + 1;
3042 WCHAR
*icon
= Alloc( len
* sizeof (WCHAR
) );
3044 ppsp
->u2
.pszIcon
= strcpyW( icon
, lpPropSheetPage
->u2
.pszIcon
);
3048 if (ppsp
->dwFlags
& PSP_USETITLE
)
3049 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3051 ppsp
->pszTitle
= NULL
;
3053 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3054 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3056 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3057 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3059 ppsp
->pszHeaderTitle
= NULL
;
3061 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3062 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3064 ppsp
->pszHeaderSubTitle
= NULL
;
3066 return (HPROPSHEETPAGE
)ppsp
;
3069 /******************************************************************************
3070 * DestroyPropertySheetPage (COMCTL32.@)
3072 * Destroys a property sheet page previously created with
3073 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
3080 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
3082 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3087 if ( !(psp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( psp
->u
.pszTemplate
) )
3088 Free ((LPVOID
)psp
->u
.pszTemplate
);
3090 if ( (psp
->dwFlags
& PSP_USEICONID
) && HIWORD( psp
->u2
.pszIcon
) )
3091 Free ((LPVOID
)psp
->u2
.pszIcon
);
3093 if ((psp
->dwFlags
& PSP_USETITLE
) && HIWORD( psp
->pszTitle
))
3094 Free ((LPVOID
)psp
->pszTitle
);
3101 /******************************************************************************
3102 * PROPSHEET_IsDialogMessage
3104 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3106 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3109 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3112 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3115 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3117 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3119 switch (lpMsg
->wParam
)
3122 if (GetKeyState(VK_SHIFT
) & 0x8000)
3128 case VK_NEXT
: new_page
= 1; break;
3129 case VK_PRIOR
: new_page
= -1; break;
3135 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3137 new_page
+= psInfo
->active_page
;
3140 new_page
= psInfo
->nPages
- 1;
3141 else if (new_page
>= psInfo
->nPages
)
3144 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3151 return IsDialogMessageW(hwnd
, lpMsg
);
3154 /******************************************************************************
3155 * PROPSHEET_DoCommand
3157 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3163 case IDC_APPLY_BUTTON
:
3165 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3167 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3172 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3175 /* don't overwrite ID_PSRESTARTWINDOWS or ID_PSREBOOTSYSTEM */
3176 if (psInfo
->result
== 0)
3177 psInfo
->result
= IDOK
;
3179 if (psInfo
->isModeless
)
3180 psInfo
->activeValid
= FALSE
;
3182 psInfo
->ended
= TRUE
;
3185 EnableWindow(hwndApplyBtn
, FALSE
);
3190 case IDC_BACK_BUTTON
:
3191 PROPSHEET_Back(hwnd
);
3194 case IDC_NEXT_BUTTON
:
3195 PROPSHEET_Next(hwnd
);
3198 case IDC_FINISH_BUTTON
:
3199 PROPSHEET_Finish(hwnd
);
3203 PROPSHEET_Cancel(hwnd
, 0);
3207 PROPSHEET_Help(hwnd
);
3217 /******************************************************************************
3220 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3222 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3227 HPALETTE hOldPal
= 0;
3231 LPCPROPSHEETPAGEW ppshpage
;
3232 WCHAR szBuffer
[256];
3235 if (psInfo
->active_page
< 0) return 1;
3236 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3239 hdcSrc
= CreateCompatibleDC(0);
3240 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3242 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3243 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3245 if ( (!(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3246 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3247 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3249 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3251 COLORREF clrOld
= 0;
3254 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3255 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3257 GetClientRect(hwndLineHeader
, &r
);
3258 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3259 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3261 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), (LPVOID
)&bm
);
3263 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3265 /* Fill the unoccupied part of the header with color of the
3266 * left-top pixel, but do it only when needed.
3268 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3270 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3271 CopyRect(&r
, &rzone
);
3272 if (bm
.bmWidth
< r
.right
)
3274 r
.left
= bm
.bmWidth
;
3275 FillRect(hdc
, &r
, hbr
);
3277 if (bm
.bmHeight
< r
.bottom
)
3280 r
.top
= bm
.bmHeight
;
3281 FillRect(hdc
, &r
, hbr
);
3286 /* Draw the header itself. */
3288 bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3289 hdcSrc
, 0, 0, SRCCOPY
);
3294 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3295 FillRect(hdc
, &rzone
, hbr
);
3297 /* Draw the header bitmap. It's always centered like a
3298 * common 49 x 49 bitmap. */
3299 margin
= (rzone
.bottom
- 49) / 2;
3300 BitBlt(hdc
, rzone
.right
- 49 - margin
, margin
,
3301 min(bm
.bmWidth
, 49), min(bm
.bmHeight
, 49),
3302 hdcSrc
, 0, 0, SRCCOPY
);
3304 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3305 * if its height is smaller than 49 pixels. Because the reason
3306 * for this bug is unknown the current code doesn't try to
3310 clrOld
= SetTextColor (hdc
, 0x00000000);
3311 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3313 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3314 SetRect(&r
, 20, 10, 0, 0);
3315 if (HIWORD(ppshpage
->pszHeaderTitle
))
3316 DrawTextW(hdc
, ppshpage
->pszHeaderTitle
, -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3319 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderTitle
,
3323 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3328 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3329 SelectObject(hdc
, psInfo
->hFont
);
3330 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3331 if (HIWORD(ppshpage
->pszHeaderTitle
))
3332 DrawTextW(hdc
, ppshpage
->pszHeaderSubTitle
, -1, &r
, DT_LEFT
| DT_WORDBREAK
);
3335 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderSubTitle
,
3339 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_WORDBREAK
);
3344 offsety
= rzone
.bottom
+ 2;
3346 SetTextColor(hdc
, clrOld
);
3347 SetBkMode(hdc
, oldBkMode
);
3348 SelectObject(hdc
, hOldFont
);
3349 SelectObject(hdcSrc
, hbmp
);
3352 if ( (ppshpage
->dwFlags
& PSP_HIDEHEADER
) &&
3353 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3354 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3356 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3358 GetClientRect(hwndLine
, &r
);
3359 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3363 rzone
.right
= r
.right
;
3364 rzone
.bottom
= r
.top
- 1;
3366 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3367 FillRect(hdc
, &rzone
, hbr
);
3369 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), (LPVOID
)&bm
);
3370 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3372 /* The watermark is truncated to a width of 164 pixels */
3373 r
.right
= min(r
.right
, 164);
3374 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3375 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3377 /* If the bitmap is not big enough, fill the remaining area
3378 with the color of pixel (0,0) of bitmap - see MSDN */
3379 if (r
.top
> bm
.bmHeight
) {
3380 r
.bottom
= r
.top
- 1;
3381 r
.top
= bm
.bmHeight
;
3383 r
.right
= bm
.bmWidth
;
3384 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3385 FillRect(hdc
, &r
, hbr
);
3389 SelectObject(hdcSrc
, hbmp
);
3392 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3393 SelectPalette(hdc
, hOldPal
, FALSE
);
3397 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3402 /******************************************************************************
3403 * PROPSHEET_DialogProc
3405 static INT_PTR CALLBACK
3406 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3408 TRACE("hwnd=%p msg=0x%04x wparam=%lx lparam=%lx\n",
3409 hwnd
, uMsg
, wParam
, lParam
);
3415 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3416 WCHAR
* strCaption
= (WCHAR
*)Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3417 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3418 LPCPROPSHEETPAGEW ppshpage
;
3422 /* Using PropSheetInfoStr to store extra data doesn't match the native
3423 * common control: native uses TCM_[GS]ETITEM
3425 SetPropW(hwnd
, PropSheetInfoStr
, (HANDLE
)psInfo
);
3428 * psInfo->hwnd is not being used by WINE code - it exists
3429 * for compatibility with "real" Windoze. The same about
3430 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3433 psInfo
->hwnd
= hwnd
;
3434 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3436 /* set up the Next and Back buttons by default */
3437 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3440 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3441 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3442 logFont
.lfWeight
= FW_BOLD
;
3443 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3446 * Small icon in the title bar.
3448 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3449 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3452 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3453 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3455 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3456 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3457 psInfo
->ppshheader
.u
.pszIcon
,
3462 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3464 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3467 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3468 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3470 psInfo
->strPropertiesFor
= strCaption
;
3472 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3474 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3476 PROPSHEET_LoadWizardBitmaps(psInfo
);
3478 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3480 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3481 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3482 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3486 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3488 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3489 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3493 if (!HIWORD(psInfo
->ppshheader
.pszCaption
) &&
3494 psInfo
->ppshheader
.hInstance
)
3498 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3499 (UINT_PTR
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3500 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3504 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3505 psInfo
->ppshheader
.pszCaption
);
3509 if (psInfo
->useCallback
)
3510 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
,
3511 PSCB_INITIALIZED
, (LPARAM
)0);
3513 idx
= psInfo
->active_page
;
3514 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[idx
].hpage
;
3515 psInfo
->active_page
= -1;
3517 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3519 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3520 * as some programs call TCM_GETCURSEL to get the current selection
3521 * from which to switch to the next page */
3522 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3527 case WM_PRINTCLIENT
:
3529 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3533 PROPSHEET_CleanUp(hwnd
);
3537 PROPSHEET_Cancel(hwnd
, 1);
3538 return FALSE
; /* let DefDlgProc post us WM_COMMAND/IDCANCEL */
3541 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3543 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3548 /* No default handler, forward notification to active page */
3549 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3551 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3552 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3559 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3561 if (pnmh
->code
== TCN_SELCHANGE
)
3563 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3564 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3567 if(pnmh
->code
== TCN_SELCHANGING
)
3569 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3570 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3577 case WM_SYSCOLORCHANGE
:
3578 COMCTL32_RefreshSysColors();
3581 case PSM_GETCURRENTPAGEHWND
:
3583 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3590 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3591 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3593 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3599 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3603 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3606 case PSM_GETTABCONTROL
:
3608 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3610 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3619 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3620 if(msgResult
!= FALSE
)
3622 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3625 (HPROPSHEETPAGE
)lParam
);
3628 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3633 case PSM_CANCELTOCLOSE
:
3635 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3636 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3637 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3639 EnableWindow(hwndCancel
, FALSE
);
3640 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, sizeof(buf
)))
3641 SetWindowTextW(hwndOK
, buf
);
3646 case PSM_RESTARTWINDOWS
:
3648 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3654 /* reboot system takes precedence over restart windows */
3655 if (psInfo
->result
!= ID_PSREBOOTSYSTEM
)
3656 psInfo
->result
= ID_PSRESTARTWINDOWS
;
3661 case PSM_REBOOTSYSTEM
:
3663 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3669 psInfo
->result
= ID_PSREBOOTSYSTEM
;
3675 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3679 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3684 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3686 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3691 case PSM_QUERYSIBLINGS
:
3693 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3695 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3703 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3704 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3705 * on success or FALSE otherwise, as specified on MSDN Online.
3706 * Also see the MFC code for
3707 * CPropertySheet::AddPage(CPropertyPage* pPage).
3710 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3712 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3717 case PSM_REMOVEPAGE
:
3718 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3721 case PSM_ISDIALOGMESSAGE
:
3723 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3724 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3728 case PSM_PRESSBUTTON
:
3729 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3732 case PSM_SETFINISHTEXTA
:
3733 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3736 case PSM_SETWIZBUTTONS
:
3737 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3740 case PSM_SETCURSELID
:
3741 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3744 case PSM_SETFINISHTEXTW
:
3745 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3748 case PSM_INSERTPAGE
:
3750 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3751 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3755 case PSM_SETHEADERTITLEW
:
3756 PROPSHEET_SetHeaderTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3759 case PSM_SETHEADERTITLEA
:
3760 PROPSHEET_SetHeaderTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3763 case PSM_SETHEADERSUBTITLEW
:
3764 PROPSHEET_SetHeaderSubTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3767 case PSM_SETHEADERSUBTITLEA
:
3768 PROPSHEET_SetHeaderSubTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3771 case PSM_HWNDTOINDEX
:
3773 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3774 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3778 case PSM_INDEXTOHWND
:
3780 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3781 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3785 case PSM_PAGETOINDEX
:
3787 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3788 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3792 case PSM_INDEXTOPAGE
:
3794 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3795 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3801 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3802 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3808 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3809 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3815 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3816 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3820 case PSM_RECALCPAGESIZES
:
3822 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3823 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);