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
37 * o PSM_RECALCPAGESIZES
38 * o PSM_SETHEADERSUBTITLE
39 * o PSM_SETHEADERTITLE
44 * o PSN_QUERYINITIALFOCUS
45 * o PSN_TRANSLATEACCELERATOR
48 * o PSH_STRETCHWATERMARK
52 * o PSP_USEFUSIONCONTEXT
59 #define NONAMELESSUNION
60 #define NONAMELESSSTRUCT
71 #include "wine/debug.h"
72 #include "wine/unicode.h"
74 /******************************************************************************
98 } MyDLGITEMTEMPLATEEX
;
101 typedef struct tagPropPageInfo
103 HPROPSHEETPAGE hpage
; /* to keep track of pages not passed to PropertySheet */
112 typedef struct tagPropSheetInfo
115 PROPSHEETHEADERW ppshheader
;
117 LPWSTR strPropertiesFor
;
128 PropPageInfo
* proppage
;
133 HIMAGELIST hImageList
;
143 /******************************************************************************
144 * Defines and global variables
147 static const WCHAR PropSheetInfoStr
[] =
148 {'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0 };
150 #define PSP_INTERNAL_UNICODE 0x80000000
152 #define MAX_CAPTION_LENGTH 255
153 #define MAX_TABTEXT_LENGTH 255
154 #define MAX_BUTTONTEXT_LENGTH 64
156 #define INTRNL_ANY_WIZARD (PSH_WIZARD | PSH_WIZARD97_OLD | PSH_WIZARD97_NEW | PSH_WIZARD_LITE)
158 /* Wizard metrics specified in DLUs */
159 #define WIZARD_PADDING 7
160 #define WIZARD_HEADER_HEIGHT 36
162 /******************************************************************************
165 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
);
166 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
);
167 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
);
168 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
171 HPROPSHEETPAGE hpage
);
172 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, PropSheetInfo
* psInfo
);
173 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
);
174 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
);
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(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
)
282 TRACE("<%s>\n", frstr
);
283 len
= MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, 0, 0);
284 *tostr
= Alloc(len
* sizeof(WCHAR
));
285 MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, (LPWSTR
)*tostr
, 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%ld\ndwFlags\t\t%08lx\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 psInfo
->ppshheader
.pszCaption
= Alloc( len
*sizeof (WCHAR
) );
320 MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, (LPWSTR
) psInfo
->ppshheader
.pszCaption
, len
);
323 psInfo
->nPages
= lppsh
->nPages
;
325 if (dwFlags
& PSH_USEPSTARTPAGE
)
327 TRACE("PSH_USEPSTARTPAGE is on\n");
328 psInfo
->active_page
= 0;
331 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
333 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
334 psInfo
->active_page
= 0;
336 psInfo
->restartWindows
= FALSE
;
337 psInfo
->rebootSystem
= FALSE
;
338 psInfo
->hImageList
= 0;
339 psInfo
->activeValid
= FALSE
;
344 /******************************************************************************
345 * PROPSHEET_CollectSheetInfoW
347 * Collect relevant data.
349 static BOOL
PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
350 PropSheetInfo
* psInfo
)
352 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERW
));
353 DWORD dwFlags
= lppsh
->dwFlags
;
355 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
356 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
357 psInfo
->hasFinish
= dwFlags
& PSH_WIZARDHASFINISH
;
358 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
) && (lppsh
->pfnCallback
);
359 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
361 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
362 TRACE("\n** PROPSHEETHEADER **\ndwSize\t\t%ld\ndwFlags\t\t%08lx\nhwndParent\t%p\nhInstance\t%p\npszCaption\t'%s'\nnPages\t\t%d\npfnCallback\t%p\n",
363 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
, debugstr_w(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
365 PROPSHEET_UnImplementedFlags(lppsh
->dwFlags
);
367 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
368 psInfo
->ppshheader
.pszCaption
= NULL
;
371 if (HIWORD(lppsh
->pszCaption
))
373 int len
= strlenW(lppsh
->pszCaption
);
374 psInfo
->ppshheader
.pszCaption
= Alloc( (len
+1)*sizeof(WCHAR
) );
375 strcpyW( (WCHAR
*)psInfo
->ppshheader
.pszCaption
, lppsh
->pszCaption
);
378 psInfo
->nPages
= lppsh
->nPages
;
380 if (dwFlags
& PSH_USEPSTARTPAGE
)
382 TRACE("PSH_USEPSTARTPAGE is on\n");
383 psInfo
->active_page
= 0;
386 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
388 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
389 psInfo
->active_page
= 0;
391 psInfo
->restartWindows
= FALSE
;
392 psInfo
->rebootSystem
= FALSE
;
393 psInfo
->hImageList
= 0;
394 psInfo
->activeValid
= FALSE
;
399 /******************************************************************************
400 * PROPSHEET_CollectPageInfo
402 * Collect property sheet data.
403 * With code taken from DIALOG_ParseTemplate32.
405 static BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
406 PropSheetInfo
* psInfo
,
409 DLGTEMPLATE
* pTemplate
;
418 psInfo
->proppage
[index
].hpage
= (HPROPSHEETPAGE
)lppsp
;
419 psInfo
->proppage
[index
].hwndPage
= 0;
420 psInfo
->proppage
[index
].isDirty
= FALSE
;
423 * Process property page flags.
425 dwFlags
= lppsp
->dwFlags
;
426 psInfo
->proppage
[index
].useCallback
= (dwFlags
& PSP_USECALLBACK
) && (lppsp
->pfnCallback
);
427 psInfo
->proppage
[index
].hasHelp
= dwFlags
& PSP_HASHELP
;
428 psInfo
->proppage
[index
].hasIcon
= dwFlags
& (PSP_USEHICON
| PSP_USEICONID
);
430 /* as soon as we have a page with the help flag, set the sheet flag on */
431 if (psInfo
->proppage
[index
].hasHelp
)
432 psInfo
->hasHelp
= TRUE
;
435 * Process page template.
437 if (dwFlags
& PSP_DLGINDIRECT
)
438 pTemplate
= (DLGTEMPLATE
*)lppsp
->u
.pResource
;
439 else if(dwFlags
& PSP_INTERNAL_UNICODE
)
441 HRSRC hResource
= FindResourceW(lppsp
->hInstance
,
442 lppsp
->u
.pszTemplate
,
444 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
446 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
450 HRSRC hResource
= FindResourceA(lppsp
->hInstance
,
451 (LPSTR
)lppsp
->u
.pszTemplate
,
453 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
455 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
459 * Extract the size of the page and the caption.
464 p
= (const WORD
*)pTemplate
;
466 if (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
468 /* DLGTEMPLATEEX (not defined in any std. header file) */
472 p
+= 2; /* help ID */
473 p
+= 2; /* ext style */
481 p
+= 2; /* ext style */
487 width
= (WORD
)*p
; p
++;
488 height
= (WORD
)*p
; p
++;
490 /* Special calculation for interior wizard pages so the largest page is
491 * calculated correctly. We need to add all the padding and space occupied
492 * by the header so the width and height sums up to the whole wizard client
494 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
495 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
496 !(dwFlags
& PSP_HIDEHEADER
))
498 height
+= 2 * WIZARD_PADDING
+ WIZARD_HEADER_HEIGHT
;
499 width
+= 2 * WIZARD_PADDING
;
501 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
)
503 height
+= 2 * WIZARD_PADDING
;
504 width
+= 2 * WIZARD_PADDING
;
507 /* remember the largest width and height */
508 if (width
> psInfo
->width
)
509 psInfo
->width
= width
;
511 if (height
> psInfo
->height
)
512 psInfo
->height
= height
;
524 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
538 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
542 /* Extract the caption */
543 psInfo
->proppage
[index
].pszText
= (LPCWSTR
)p
;
544 TRACE("Tab %d %s\n",index
,debugstr_w((LPCWSTR
)p
));
545 p
+= lstrlenW((LPCWSTR
)p
) + 1;
547 if (dwFlags
& PSP_USETITLE
)
551 static const WCHAR pszNull
[] = { '(','n','u','l','l',')',0 };
554 if ( !HIWORD( lppsp
->pszTitle
) )
556 if (!LoadStringW( lppsp
->hInstance
, (DWORD_PTR
)lppsp
->pszTitle
,szTitle
,sizeof(szTitle
) ))
559 FIXME("Could not load resource #%04x?\n",LOWORD(lppsp
->pszTitle
));
565 pTitle
= lppsp
->pszTitle
;
567 len
= strlenW(pTitle
);
568 psInfo
->proppage
[index
].pszText
= Alloc( (len
+1)*sizeof (WCHAR
) );
569 strcpyW( (LPWSTR
)psInfo
->proppage
[index
].pszText
,pTitle
);
573 * Build the image list for icons
575 if ((dwFlags
& PSP_USEHICON
) || (dwFlags
& PSP_USEICONID
))
578 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
579 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
581 if (dwFlags
& PSP_USEICONID
)
582 hIcon
= LoadImageW(lppsp
->hInstance
, lppsp
->u2
.pszIcon
, IMAGE_ICON
,
583 icon_cx
, icon_cy
, LR_DEFAULTCOLOR
);
585 hIcon
= lppsp
->u2
.hIcon
;
589 if (psInfo
->hImageList
== 0 )
590 psInfo
->hImageList
= ImageList_Create(icon_cx
, icon_cy
, ILC_COLOR
, 1, 1);
592 ImageList_AddIcon(psInfo
->hImageList
, hIcon
);
600 /******************************************************************************
601 * PROPSHEET_CreateDialog
603 * Creates the actual property sheet.
605 INT_PTR
PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
)
612 WORD resID
= IDD_PROPSHEET
;
615 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
618 if( psInfo
->unicode
)
620 if(!(hRes
= FindResourceW(COMCTL32_hModule
,
621 MAKEINTRESOURCEW(resID
),
627 if(!(hRes
= FindResourceA(COMCTL32_hModule
,
628 MAKEINTRESOURCEA(resID
),
633 if(!(template = (LPVOID
)LoadResource(COMCTL32_hModule
, hRes
)))
637 * Make a copy of the dialog template.
639 resSize
= SizeofResource(COMCTL32_hModule
, hRes
);
641 temp
= Alloc(resSize
);
646 memcpy(temp
, template, resSize
);
648 if (psInfo
->ppshheader
.dwFlags
& PSH_NOCONTEXTHELP
)
650 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
651 ((MyDLGTEMPLATEEX
*)temp
)->style
&= ~DS_CONTEXTHELP
;
653 ((DLGTEMPLATE
*)temp
)->style
&= ~DS_CONTEXTHELP
;
655 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
656 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARDCONTEXTHELP
))
658 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
659 ((MyDLGTEMPLATEEX
*)temp
)->style
|= DS_CONTEXTHELP
;
661 ((DLGTEMPLATE
*)temp
)->style
|= DS_CONTEXTHELP
;
664 if (psInfo
->useCallback
)
665 (*(psInfo
->ppshheader
.pfnCallback
))(0, PSCB_PRECREATE
, (LPARAM
)temp
);
667 /* NOTE: MSDN states "Returns a positive value if successful, or -1
668 * otherwise for modal property sheets.", but this is wrong. The
669 * actual return value is either TRUE (success), FALSE (cancel) or
671 if( psInfo
->unicode
)
673 ret
= (INT_PTR
)CreateDialogIndirectParamW(psInfo
->ppshheader
.hInstance
,
674 (LPDLGTEMPLATEW
) temp
,
675 psInfo
->ppshheader
.hwndParent
,
676 PROPSHEET_DialogProc
,
678 if ( !ret
) ret
= -1;
682 ret
= (INT_PTR
)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
683 (LPDLGTEMPLATEA
) temp
,
684 psInfo
->ppshheader
.hwndParent
,
685 PROPSHEET_DialogProc
,
687 if ( !ret
) ret
= -1;
695 /******************************************************************************
696 * PROPSHEET_SizeMismatch
698 * Verify that the tab control and the "largest" property sheet page dlg. template
701 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, PropSheetInfo
* psInfo
)
703 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
704 RECT rcOrigTab
, rcPage
;
709 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
710 TRACE("orig tab %ld %ld %ld %ld\n", rcOrigTab
.left
, rcOrigTab
.top
,
711 rcOrigTab
.right
, rcOrigTab
.bottom
);
718 rcPage
.right
= psInfo
->width
;
719 rcPage
.bottom
= psInfo
->height
;
721 MapDialogRect(hwndDlg
, &rcPage
);
722 TRACE("biggest page %ld %ld %ld %ld\n", rcPage
.left
, rcPage
.top
,
723 rcPage
.right
, rcPage
.bottom
);
725 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
727 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
733 /******************************************************************************
734 * PROPSHEET_AdjustSize
736 * Resizes the property sheet and the tab control to fit the largest page.
738 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
740 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
741 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
743 int tabOffsetX
, tabOffsetY
, buttonHeight
;
744 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
747 /* Get the height of buttons */
748 GetClientRect(hwndButton
, &rc
);
749 buttonHeight
= rc
.bottom
;
756 rc
.right
= psInfo
->width
;
757 rc
.bottom
= psInfo
->height
;
759 MapDialogRect(hwndDlg
, &rc
);
761 /* retrieve the dialog units */
762 units
.left
= units
.right
= 4;
763 units
.top
= units
.bottom
= 8;
764 MapDialogRect(hwndDlg
, &units
);
767 * Resize the tab control.
769 GetClientRect(hwndTabCtrl
,&tabRect
);
771 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
773 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
775 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
776 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
779 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
781 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
782 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
785 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
787 tabOffsetX
= -(rc
.left
);
788 tabOffsetY
= -(rc
.top
);
792 TRACE("setting tab %p, rc (0,0)-(%ld,%ld)\n",
793 hwndTabCtrl
, rc
.right
, rc
.bottom
);
794 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
795 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
797 GetClientRect(hwndTabCtrl
, &rc
);
799 TRACE("tab client rc %ld %ld %ld %ld\n",
800 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
802 rc
.right
+= ((padding
.x
* 2) + tabOffsetX
);
803 rc
.bottom
+= (buttonHeight
+ (3 * padding
.y
) + tabOffsetY
);
806 * Resize the property sheet.
808 TRACE("setting dialog %p, rc (0,0)-(%ld,%ld)\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
, 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 %ld %ld %ld %ld\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
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)-(%ld,%ld)\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
, 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
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1));
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
);
917 if (psInfo
->hasApply
)
920 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * 2);
922 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
924 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
925 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
927 EnableWindow(hwndButton
, FALSE
);
930 ShowWindow(hwndButton
, SW_HIDE
);
933 * Position Help button.
935 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
939 x
= rcSheet
.right
- (padding
.x
+ buttonWidth
);
941 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
942 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
945 ShowWindow(hwndButton
, SW_HIDE
);
950 /******************************************************************************
951 * PROPSHEET_AdjustButtonsWizard
953 * Adjusts the buttons' positions.
955 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
956 PropSheetInfo
* psInfo
)
958 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
959 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
960 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
964 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
965 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
969 if (psInfo
->hasFinish
)
973 * Obtain the size of the buttons.
975 GetClientRect(hwndButton
, &rcSheet
);
976 buttonWidth
= rcSheet
.right
;
977 buttonHeight
= rcSheet
.bottom
;
979 GetClientRect(hwndLine
, &rcSheet
);
980 lineHeight
= rcSheet
.bottom
;
983 * Get the size of the property sheet.
985 GetClientRect(hwndParent
, &rcSheet
);
988 * All buttons will be at this y coordinate.
990 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
993 * Position the Back button.
995 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
997 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1)) - buttonWidth
;
999 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1000 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1003 * Position the Next button.
1005 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
1009 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1010 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1013 * Position the Finish button.
1015 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
1017 if (psInfo
->hasFinish
)
1018 x
+= padding
.x
+ buttonWidth
;
1020 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1021 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1023 if (!psInfo
->hasFinish
)
1024 ShowWindow(hwndButton
, SW_HIDE
);
1027 * Position the Cancel button.
1029 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1031 x
+= padding
.x
+ buttonWidth
;
1033 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1034 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1037 * Position Help button.
1039 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1041 if (psInfo
->hasHelp
)
1043 x
+= padding
.x
+ buttonWidth
;
1045 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1046 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1049 ShowWindow(hwndButton
, SW_HIDE
);
1051 if (psInfo
->ppshheader
.dwFlags
&
1052 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1056 * Position and resize the sunken line.
1059 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1061 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1062 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1063 SWP_NOZORDER
| SWP_NOACTIVATE
);
1066 * Position and resize the header sunken line.
1069 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1070 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1071 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1072 ShowWindow(hwndLineHeader
, SW_HIDE
);
1077 /******************************************************************************
1078 * PROPSHEET_GetPaddingInfo
1080 * Returns the layout information.
1082 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1084 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1087 PADDING_INFO padding
;
1089 GetWindowRect(hwndTab
, &rcTab
);
1094 ScreenToClient(hwndDlg
, &tl
);
1102 /******************************************************************************
1103 * PROPSHEET_GetPaddingInfoWizard
1105 * Returns the layout information.
1106 * Vertical spacing is the distance between the line and the buttons.
1107 * Do NOT use the Help button to gather padding information when it isn't mapped
1108 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1109 * for it in this case !
1110 * FIXME: I'm not sure about any other coordinate problems with these evil
1111 * buttons. Fix it in case additional problems appear or maybe calculate
1112 * a padding in a completely different way, as this is somewhat messy.
1114 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1117 PADDING_INFO padding
;
1121 POINT ptButton
, ptLine
;
1124 if (psInfo
->hasHelp
)
1130 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1132 idButton
= IDC_NEXT_BUTTON
;
1136 /* hopefully this is ok */
1137 idButton
= IDCANCEL
;
1141 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1142 GetWindowRect(hwndControl
, &rc
);
1144 ptButton
.x
= rc
.left
;
1145 ptButton
.y
= rc
.top
;
1147 ScreenToClient(hwndDlg
, &ptButton
);
1150 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1151 GetWindowRect(hwndControl
, &rc
);
1154 ptLine
.y
= rc
.bottom
;
1156 ScreenToClient(hwndDlg
, &ptLine
);
1158 padding
.y
= ptButton
.y
- ptLine
.y
;
1161 ERR("padding negative ! Please report this !\n");
1163 /* this is most probably not correct, but the best we have now */
1164 padding
.x
= padding
.y
;
1168 /******************************************************************************
1169 * PROPSHEET_CreateTabControl
1171 * Insert the tabs in the tab control.
1173 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1174 PropSheetInfo
* psInfo
)
1176 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1182 item
.mask
= TCIF_TEXT
;
1183 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1185 nTabs
= psInfo
->nPages
;
1188 * Set the image list for icons.
1190 if (psInfo
->hImageList
)
1192 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1195 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 0, 0);
1196 for (i
= 0; i
< nTabs
; i
++)
1198 if ( psInfo
->proppage
[i
].hasIcon
)
1200 item
.mask
|= TCIF_IMAGE
;
1201 item
.iImage
= iImage
++;
1205 item
.mask
&= ~TCIF_IMAGE
;
1208 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1209 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, (WPARAM
)i
, (LPARAM
)&item
);
1211 SendMessageW(GetDlgItem(hwndTabCtrl
, IDC_TABCONTROL
), WM_SETREDRAW
, 1, 0);
1216 /******************************************************************************
1217 * PROPSHEET_WizardSubclassProc
1219 * Subclassing window procedure for wizard extrior pages to prevent drawing
1220 * background and so drawing above the watermark.
1222 static LRESULT CALLBACK
1223 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1230 case WM_CTLCOLORSTATIC
:
1231 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1232 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1235 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1239 * Get the size of an in-memory Template
1241 *( Based on the code of PROPSHEET_CollectPageInfo)
1242 * See also dialog.c/DIALOG_ParseTemplate32().
1245 static UINT
GetTemplateSize(DLGTEMPLATE
* pTemplate
)
1248 const WORD
* p
= (const WORD
*)pTemplate
;
1249 BOOL istemplateex
= (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1255 /* DLGTEMPLATEEX (not defined in any std. header file) */
1257 TRACE("is DLGTEMPLATEEX\n");
1259 p
++; /* signature */
1260 p
+= 2; /* help ID */
1261 p
+= 2; /* ext style */
1268 TRACE("is DLGTEMPLATE\n");
1270 p
+= 2; /* ext style */
1273 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1289 TRACE("menu %s\n",debugstr_w((LPCWSTR
)p
));
1290 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1301 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1304 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1305 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1310 TRACE("title %s\n",debugstr_w((LPCWSTR
)p
));
1311 p
+= lstrlenW((LPCWSTR
)p
) + 1;
1313 /* font, if DS_SETFONT set */
1314 if ((DS_SETFONT
& ((istemplateex
)? ((MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1317 p
+=(istemplateex
)?3:1;
1318 TRACE("font %s\n",debugstr_w((LPCWSTR
)p
));
1319 p
+= lstrlenW( (LPCWSTR
)p
) + 1; /* the font name */
1322 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1323 * that are following the DLGTEMPLATE(EX) data */
1324 TRACE("%d items\n",nrofitems
);
1325 while (nrofitems
> 0)
1327 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1330 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1339 TRACE("class ordinal 0x%08lx\n",*(DWORD
*)p
);
1343 TRACE("class %s\n",debugstr_w((LPCWSTR
)p
));
1344 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1348 /* check title text */
1355 TRACE("text ordinal 0x%08lx\n",*(DWORD
*)p
);
1359 TRACE("text %s\n",debugstr_w((LPCWSTR
)p
));
1360 p
+= lstrlenW( (LPCWSTR
)p
) + 1;
1363 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1367 ret
= (p
- (WORD
*)pTemplate
) * sizeof(WORD
);
1368 TRACE("%p %p size 0x%08x\n", p
, pTemplate
, ret
);
1372 /******************************************************************************
1373 * PROPSHEET_CreatePage
1377 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1379 const PropSheetInfo
* psInfo
,
1380 LPCPROPSHEETPAGEW ppshpage
)
1382 DLGTEMPLATE
* pTemplate
;
1387 TRACE("index %d\n", index
);
1389 if (ppshpage
== NULL
)
1394 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1396 pTemplate
= (DLGTEMPLATE
*)ppshpage
->u
.pResource
;
1397 resSize
= GetTemplateSize(pTemplate
);
1399 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1404 hResource
= FindResourceW(ppshpage
->hInstance
,
1405 ppshpage
->u
.pszTemplate
,
1410 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1412 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1416 pTemplate
= (LPDLGTEMPLATEW
)LockResource(hTemplate
);
1418 * Make a copy of the dialog template to make it writable
1426 hResource
= FindResourceA(ppshpage
->hInstance
,
1427 (LPSTR
)ppshpage
->u
.pszTemplate
,
1432 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1434 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1438 pTemplate
= (LPDLGTEMPLATEA
)LockResource(hTemplate
);
1440 * Make a copy of the dialog template to make it writable
1443 temp
= Alloc(resSize
);
1447 TRACE("copying pTemplate %p into temp %p (%ld)\n", pTemplate
, temp
, resSize
);
1448 memcpy(temp
, pTemplate
, resSize
);
1451 if (((MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
1453 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1454 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~DS_MODALFRAME
;
1455 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_CAPTION
;
1456 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_SYSMENU
;
1457 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_POPUP
;
1458 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_DISABLED
;
1459 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_VISIBLE
;
1460 ((MyDLGTEMPLATEEX
*)pTemplate
)->style
&= ~WS_THICKFRAME
;
1462 ((MyDLGTEMPLATEEX
*)pTemplate
)->exStyle
|= WS_EX_CONTROLPARENT
;
1466 pTemplate
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1467 pTemplate
->style
&= ~DS_MODALFRAME
;
1468 pTemplate
->style
&= ~WS_CAPTION
;
1469 pTemplate
->style
&= ~WS_SYSMENU
;
1470 pTemplate
->style
&= ~WS_POPUP
;
1471 pTemplate
->style
&= ~WS_DISABLED
;
1472 pTemplate
->style
&= ~WS_VISIBLE
;
1473 pTemplate
->style
&= ~WS_THICKFRAME
;
1475 pTemplate
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1478 if (psInfo
->proppage
[index
].useCallback
)
1479 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1480 (LPPROPSHEETPAGEW
)ppshpage
);
1482 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1483 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1486 ppshpage
->pfnDlgProc
,
1489 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1492 ppshpage
->pfnDlgProc
,
1494 /* Free a no more needed copy */
1498 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1500 /* Subclass exterior wizard pages */
1501 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1502 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1503 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1505 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1506 (DWORD_PTR
)ppshpage
);
1508 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1509 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1514 /******************************************************************************
1515 * PROPSHEET_LoadWizardBitmaps
1517 * Loads the watermark and header bitmaps for a wizard.
1519 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1521 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1523 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1524 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1525 considers hbmWatermark as valid. */
1526 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1527 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1529 ((PropSheetInfo
*)psInfo
)->ppshheader
.u4
.hbmWatermark
=
1530 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1533 /* Same behavior as for watermarks */
1534 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1535 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1537 ((PropSheetInfo
*)psInfo
)->ppshheader
.u5
.hbmHeader
=
1538 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1544 /******************************************************************************
1545 * PROPSHEET_ShowPage
1547 * Displays or creates the specified page.
1549 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1552 HWND hwndLineHeader
;
1553 LPCPROPSHEETPAGEW ppshpage
;
1555 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1556 if (index
== psInfo
->active_page
)
1558 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1559 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1563 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1564 if (psInfo
->proppage
[index
].hwndPage
== 0)
1566 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1569 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1571 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1572 psInfo
->proppage
[index
].pszText
);
1575 if (psInfo
->active_page
!= -1)
1576 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1578 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1580 /* Synchronize current selection with tab control
1581 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1582 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1583 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1585 psInfo
->active_page
= index
;
1586 psInfo
->activeValid
= TRUE
;
1588 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1590 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1591 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1593 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1594 ShowWindow(hwndLineHeader
, SW_HIDE
);
1596 ShowWindow(hwndLineHeader
, SW_SHOW
);
1602 /******************************************************************************
1605 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1609 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1614 TRACE("active_page %d\n", psInfo
->active_page
);
1615 if (psInfo
->active_page
< 0)
1618 psn
.hdr
.code
= PSN_WIZBACK
;
1619 psn
.hdr
.hwndFrom
= hwndDlg
;
1623 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1625 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1628 else if (result
== 0)
1629 idx
= psInfo
->active_page
- 1;
1631 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1633 if (idx
>= 0 && idx
< psInfo
->nPages
)
1635 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1636 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1641 /******************************************************************************
1644 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1648 LRESULT msgResult
= 0;
1649 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1653 TRACE("active_page %d\n", psInfo
->active_page
);
1654 if (psInfo
->active_page
< 0)
1657 psn
.hdr
.code
= PSN_WIZNEXT
;
1658 psn
.hdr
.hwndFrom
= hwndDlg
;
1662 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1664 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1665 if (msgResult
== -1)
1667 else if (msgResult
== 0)
1668 idx
= psInfo
->active_page
+ 1;
1670 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1672 if (idx
< psInfo
->nPages
)
1674 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1675 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1681 /******************************************************************************
1684 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1688 LRESULT msgResult
= 0;
1689 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1692 TRACE("active_page %d\n", psInfo
->active_page
);
1693 if (psInfo
->active_page
< 0)
1696 psn
.hdr
.code
= PSN_WIZFINISH
;
1697 psn
.hdr
.hwndFrom
= hwndDlg
;
1701 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1703 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1705 TRACE("msg result %ld\n", msgResult
);
1710 if (psInfo
->isModeless
)
1711 psInfo
->activeValid
= FALSE
;
1713 psInfo
->ended
= TRUE
;
1718 /******************************************************************************
1721 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1726 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1729 TRACE("active_page %d\n", psInfo
->active_page
);
1730 if (psInfo
->active_page
< 0)
1733 psn
.hdr
.hwndFrom
= hwndDlg
;
1739 * Send PSN_KILLACTIVE to the current page.
1741 psn
.hdr
.code
= PSN_KILLACTIVE
;
1743 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1745 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1749 * Send PSN_APPLY to all pages.
1751 psn
.hdr
.code
= PSN_APPLY
;
1752 psn
.lParam
= lParam
;
1754 for (i
= 0; i
< psInfo
->nPages
; i
++)
1756 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1759 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1761 case PSNRET_INVALID
:
1762 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1764 case PSNRET_INVALID_NOCHANGEPAGE
:
1772 psInfo
->activeValid
= FALSE
;
1774 else if(psInfo
->active_page
>= 0)
1776 psn
.hdr
.code
= PSN_SETACTIVE
;
1778 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1779 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1785 /******************************************************************************
1788 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1790 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1796 TRACE("active_page %d\n", psInfo
->active_page
);
1797 if (psInfo
->active_page
< 0)
1800 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1801 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1802 psn
.hdr
.hwndFrom
= hwndDlg
;
1806 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1809 psn
.hdr
.code
= PSN_RESET
;
1810 psn
.lParam
= lParam
;
1812 for (i
= 0; i
< psInfo
->nPages
; i
++)
1814 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1817 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1820 if (psInfo
->isModeless
)
1822 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1823 psInfo
->activeValid
= FALSE
;
1826 psInfo
->ended
= TRUE
;
1829 /******************************************************************************
1832 static void PROPSHEET_Help(HWND hwndDlg
)
1834 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1839 TRACE("active_page %d\n", psInfo
->active_page
);
1840 if (psInfo
->active_page
< 0)
1843 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1844 psn
.hdr
.code
= PSN_HELP
;
1845 psn
.hdr
.hwndFrom
= hwndDlg
;
1849 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1852 /******************************************************************************
1855 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1858 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1862 if (!psInfo
) return;
1864 * Set the dirty flag of this page.
1866 for (i
= 0; i
< psInfo
->nPages
; i
++)
1868 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1869 psInfo
->proppage
[i
].isDirty
= TRUE
;
1873 * Enable the Apply button.
1875 if (psInfo
->hasApply
)
1877 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1879 EnableWindow(hwndApplyBtn
, TRUE
);
1883 /******************************************************************************
1884 * PROPSHEET_UnChanged
1886 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1889 BOOL noPageDirty
= TRUE
;
1890 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1891 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1895 if ( !psInfo
) return;
1896 for (i
= 0; i
< psInfo
->nPages
; i
++)
1898 /* set the specified page as clean */
1899 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1900 psInfo
->proppage
[i
].isDirty
= FALSE
;
1902 /* look to see if there's any dirty pages */
1903 if (psInfo
->proppage
[i
].isDirty
)
1904 noPageDirty
= FALSE
;
1908 * Disable Apply button.
1911 EnableWindow(hwndApplyBtn
, FALSE
);
1914 /******************************************************************************
1915 * PROPSHEET_PressButton
1917 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1919 TRACE("buttonID %d\n", buttonID
);
1922 case PSBTN_APPLYNOW
:
1923 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1926 PROPSHEET_Back(hwndDlg
);
1929 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1932 PROPSHEET_Finish(hwndDlg
);
1935 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1938 PROPSHEET_Next(hwndDlg
);
1941 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1944 FIXME("Invalid button index %d\n", buttonID
);
1949 /*************************************************************************
1950 * BOOL PROPSHEET_CanSetCurSel [Internal]
1952 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1955 * hwndDlg [I] handle to a Dialog hWnd
1958 * TRUE if Current Selection can change
1962 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
1964 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
1970 TRACE("active_page %d\n", psInfo
->active_page
);
1977 if (psInfo
->active_page
< 0)
1984 * Notify the current page.
1986 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1987 psn
.hdr
.code
= PSN_KILLACTIVE
;
1988 psn
.hdr
.hwndFrom
= hwndDlg
;
1992 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1995 TRACE("<-- %d\n", res
);
1999 /******************************************************************************
2000 * PROPSHEET_SetCurSel
2002 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
2005 HPROPSHEETPAGE hpage
2008 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2009 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
2010 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2012 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
2013 /* hpage takes precedence over index */
2015 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2017 if (index
< 0 || index
>= psInfo
->nPages
)
2019 TRACE("Could not find page to select!\n");
2027 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2030 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
2032 psn
.hdr
.code
= PSN_SETACTIVE
;
2033 psn
.hdr
.hwndFrom
= hwndDlg
;
2037 if (!psInfo
->proppage
[index
].hwndPage
) {
2038 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
2041 /* Resize the property sheet page to the fit in the Tab control
2042 * (for regular property sheets) or to fit in the client area (for
2044 * NOTE: The resizing happens every time the page is selected and
2045 * not only when it's created (some applications depend on it). */
2046 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2047 TRACE("setting page %p, rc (%ld,%ld)-(%ld,%ld) w=%ld, h=%ld\n",
2048 psInfo
->proppage
[index
].hwndPage
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
2049 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2050 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2052 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2054 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2061 WARN("Tried to skip before first property sheet page!\n");
2064 if (index
>= psInfo
->nPages
) {
2065 WARN("Tried to skip after last property sheet page!\n");
2066 index
= psInfo
->nPages
-1;
2070 else if (result
!= 0)
2072 int old_index
= index
;
2073 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2074 if(index
>= psInfo
->nPages
) {
2076 WARN("Tried to skip to nonexistant page by res id\n");
2083 * Display the new page.
2085 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2087 if (psInfo
->proppage
[index
].hasHelp
)
2088 EnableWindow(hwndHelp
, TRUE
);
2090 EnableWindow(hwndHelp
, FALSE
);
2095 /******************************************************************************
2096 * PROPSHEET_SetCurSelId
2098 * Selects the page, specified by resource id.
2100 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2103 PropSheetInfo
* psInfo
=
2104 (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2106 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2107 if (idx
< psInfo
->nPages
)
2109 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2110 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2114 /******************************************************************************
2115 * PROPSHEET_SetTitleA
2117 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2119 if(HIWORD(lpszText
))
2122 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2123 szTitle
, sizeof(szTitle
)/sizeof(WCHAR
));
2124 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2128 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2132 /******************************************************************************
2133 * PROPSHEET_SetTitleW
2135 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2137 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2140 TRACE("'%s' (style %08lx)\n", debugstr_w(lpszText
), dwStyle
);
2141 if (HIWORD(lpszText
) == 0) {
2142 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2143 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)-sizeof(WCHAR
)))
2147 if (dwStyle
& PSH_PROPTITLE
)
2150 int lentitle
= strlenW(lpszText
);
2151 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2153 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2154 strcpyW(dest
, psInfo
->strPropertiesFor
);
2155 strcatW(dest
, lpszText
);
2157 SetWindowTextW(hwndDlg
, dest
);
2161 SetWindowTextW(hwndDlg
, lpszText
);
2164 /******************************************************************************
2165 * PROPSHEET_SetFinishTextA
2167 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2169 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2170 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2172 TRACE("'%s'\n", lpszText
);
2173 /* Set text, show and enable the Finish button */
2174 SetWindowTextA(hwndButton
, lpszText
);
2175 ShowWindow(hwndButton
, SW_SHOW
);
2176 EnableWindow(hwndButton
, TRUE
);
2178 /* Make it default pushbutton */
2179 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2181 /* Hide Back button */
2182 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2183 ShowWindow(hwndButton
, SW_HIDE
);
2185 if (!psInfo
->hasFinish
)
2187 /* Hide Next button */
2188 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2189 ShowWindow(hwndButton
, SW_HIDE
);
2193 /******************************************************************************
2194 * PROPSHEET_SetFinishTextW
2196 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2198 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2199 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2201 TRACE("'%s'\n", debugstr_w(lpszText
));
2202 /* Set text, show and enable the Finish button */
2203 SetWindowTextW(hwndButton
, lpszText
);
2204 ShowWindow(hwndButton
, SW_SHOW
);
2205 EnableWindow(hwndButton
, TRUE
);
2207 /* Make it default pushbutton */
2208 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2210 /* Hide Back button */
2211 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2212 ShowWindow(hwndButton
, SW_HIDE
);
2214 if (!psInfo
->hasFinish
)
2216 /* Hide Next button */
2217 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2218 ShowWindow(hwndButton
, SW_HIDE
);
2222 /******************************************************************************
2223 * PROPSHEET_QuerySiblings
2225 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2226 WPARAM wParam
, LPARAM lParam
)
2230 LRESULT msgResult
= 0;
2231 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
, PropSheetInfoStr
);
2233 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2235 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2236 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2244 /******************************************************************************
2247 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
2248 HPROPSHEETPAGE hpage
)
2251 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2253 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2255 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2257 TRACE("hpage %p\n", hpage
);
2259 * Allocate and fill in a new PropPageInfo entry.
2261 ppi
= (PropPageInfo
*) ReAlloc(psInfo
->proppage
,
2262 sizeof(PropPageInfo
) *
2263 (psInfo
->nPages
+ 1));
2267 psInfo
->proppage
= ppi
;
2268 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, psInfo
->nPages
))
2271 psInfo
->proppage
[psInfo
->nPages
].hpage
= hpage
;
2273 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2275 /* Create the page but don't show it */
2276 PROPSHEET_CreatePage(hwndDlg
, psInfo
->nPages
, psInfo
, ppsp
);
2280 * Add a new tab to the tab control.
2282 item
.mask
= TCIF_TEXT
;
2283 item
.pszText
= (LPWSTR
) psInfo
->proppage
[psInfo
->nPages
].pszText
;
2284 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2286 if (psInfo
->hImageList
)
2288 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2291 if ( psInfo
->proppage
[psInfo
->nPages
].hasIcon
)
2293 item
.mask
|= TCIF_IMAGE
;
2294 item
.iImage
= psInfo
->nPages
;
2297 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, psInfo
->nPages
+ 1,
2302 /* If it is the only page - show it */
2303 if(psInfo
->nPages
== 1)
2304 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2308 /******************************************************************************
2309 * PROPSHEET_RemovePage
2311 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2313 HPROPSHEETPAGE hpage
)
2315 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2317 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2318 PropPageInfo
* oldPages
;
2320 TRACE("index %d, hpage %p\n", index
, hpage
);
2325 * hpage takes precedence over index.
2329 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
);
2332 /* Make sure that index is within range */
2333 if (index
< 0 || index
>= psInfo
->nPages
)
2335 TRACE("Could not find page to remove!\n");
2339 TRACE("total pages %d removing page %d active page %d\n",
2340 psInfo
->nPages
, index
, psInfo
->active_page
);
2342 * Check if we're removing the active page.
2344 if (index
== psInfo
->active_page
)
2346 if (psInfo
->nPages
> 1)
2350 /* activate previous page */
2351 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2355 /* activate the next page */
2356 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2357 psInfo
->active_page
= index
;
2362 psInfo
->active_page
= -1;
2363 if (!psInfo
->isModeless
)
2365 psInfo
->ended
= TRUE
;
2370 else if (index
< psInfo
->active_page
)
2371 psInfo
->active_page
--;
2373 /* Unsubclass the page dialog window */
2374 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2375 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2376 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2378 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2379 PROPSHEET_WizardSubclassProc
, 1);
2382 /* Destroy page dialog window */
2383 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2385 /* Free page resources */
2386 if(psInfo
->proppage
[index
].hpage
)
2388 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2390 if ((psp
->dwFlags
& PSP_USETITLE
) && psInfo
->proppage
[index
].pszText
)
2391 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2393 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2396 /* Remove the tab */
2397 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2399 oldPages
= psInfo
->proppage
;
2401 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2404 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2406 if (index
< psInfo
->nPages
)
2407 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2408 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2415 /******************************************************************************
2416 * PROPSHEET_SetWizButtons
2418 * This code will work if (and assumes that) the Next button is on top of the
2419 * Finish button. ie. Finish comes after Next in the Z order.
2420 * This means make sure the dialog template reflects this.
2423 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2425 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2427 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2428 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2429 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2431 TRACE("%ld\n", dwFlags
);
2433 EnableWindow(hwndBack
, FALSE
);
2434 EnableWindow(hwndNext
, FALSE
);
2435 EnableWindow(hwndFinish
, FALSE
);
2437 /* set the default pushbutton to an enabled button */
2438 if (((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
))
2439 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2440 else if (dwFlags
& PSWIZB_NEXT
)
2441 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2442 else if (dwFlags
& PSWIZB_BACK
)
2443 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
2445 SendMessageW(hwndDlg
, DM_SETDEFID
, IDCANCEL
, 0);
2448 if (dwFlags
& PSWIZB_BACK
)
2449 EnableWindow(hwndBack
, TRUE
);
2451 if (dwFlags
& PSWIZB_NEXT
)
2452 EnableWindow(hwndNext
, TRUE
);
2454 if (!psInfo
->hasFinish
)
2456 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2458 /* Hide the Next button */
2459 ShowWindow(hwndNext
, SW_HIDE
);
2461 /* Show the Finish button */
2462 ShowWindow(hwndFinish
, SW_SHOW
);
2464 if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2465 EnableWindow(hwndFinish
, TRUE
);
2469 /* Hide the Finish button */
2470 ShowWindow(hwndFinish
, SW_HIDE
);
2471 /* Show the Next button */
2472 ShowWindow(hwndNext
, SW_SHOW
);
2475 else if (!(dwFlags
& PSWIZB_DISABLEDFINISH
))
2476 EnableWindow(hwndFinish
, TRUE
);
2479 /******************************************************************************
2480 * PROPSHEET_InsertPage
2482 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2484 if (!HIWORD(hpageInsertAfter
))
2485 FIXME("(%p, %d, %p): stub\n", hwndDlg
, LOWORD(hpageInsertAfter
), hpage
);
2487 FIXME("(%p, %p, %p): stub\n", hwndDlg
, hpageInsertAfter
, hpage
);
2491 /******************************************************************************
2492 * PROPSHEET_SetHeaderTitleW
2494 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderTitle
)
2496 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderTitle
));
2499 /******************************************************************************
2500 * PROPSHEET_SetHeaderTitleA
2502 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderTitle
)
2504 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderTitle
));
2507 /******************************************************************************
2508 * PROPSHEET_SetHeaderSubTitleW
2510 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderSubTitle
)
2512 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderSubTitle
));
2515 /******************************************************************************
2516 * PROPSHEET_SetHeaderSubTitleA
2518 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderSubTitle
)
2520 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderSubTitle
));
2523 /******************************************************************************
2524 * PROPSHEET_HwndToIndex
2526 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2529 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2532 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2534 for (index
= 0; index
< psInfo
->nPages
; index
++)
2535 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2537 WARN("%p not found\n", hPageDlg
);
2541 /******************************************************************************
2542 * PROPSHEET_IndexToHwnd
2544 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2546 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2548 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2549 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2550 WARN("%d out of range.\n", iPageIndex
);
2553 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2556 /******************************************************************************
2557 * PROPSHEET_PageToIndex
2559 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2562 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2565 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2567 for (index
= 0; index
< psInfo
->nPages
; index
++)
2568 if (psInfo
->proppage
[index
].hpage
== hPage
)
2570 WARN("%p not found\n", hPage
);
2574 /******************************************************************************
2575 * PROPSHEET_IndexToPage
2577 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2579 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2581 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2582 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2583 WARN("%d out of range.\n", iPageIndex
);
2586 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2589 /******************************************************************************
2590 * PROPSHEET_IdToIndex
2592 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2595 LPCPROPSHEETPAGEW psp
;
2596 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2598 TRACE("(%p, %d)\n", hwndDlg
, iPageId
);
2599 for (index
= 0; index
< psInfo
->nPages
; index
++) {
2600 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2601 if (psp
->u
.pszTemplate
== MAKEINTRESOURCEW(iPageId
))
2608 /******************************************************************************
2609 * PROPSHEET_IndexToId
2611 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2613 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwndDlg
,
2615 LPCPROPSHEETPAGEW psp
;
2616 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2617 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2618 WARN("%d out of range.\n", iPageIndex
);
2621 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2622 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| HIWORD(psp
->u
.pszTemplate
)) {
2625 return (LRESULT
)psp
->u
.pszTemplate
;
2628 /******************************************************************************
2629 * PROPSHEET_GetResult
2631 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2633 FIXME("(%p): stub\n", hwndDlg
);
2637 /******************************************************************************
2638 * PROPSHEET_RecalcPageSizes
2640 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2642 FIXME("(%p): stub\n", hwndDlg
);
2646 /******************************************************************************
2647 * PROPSHEET_GetPageIndex
2649 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2650 * the array of PropPageInfo.
2652 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, PropSheetInfo
* psInfo
)
2657 TRACE("hpage %p\n", hpage
);
2658 while ((index
< psInfo
->nPages
) && (found
== FALSE
))
2660 if (psInfo
->proppage
[index
].hpage
== hpage
)
2672 /******************************************************************************
2675 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2678 PropSheetInfo
* psInfo
= (PropSheetInfo
*) RemovePropW(hwndDlg
,
2682 if (!psInfo
) return;
2683 if (HIWORD(psInfo
->ppshheader
.pszCaption
))
2684 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2686 for (i
= 0; i
< psInfo
->nPages
; i
++)
2688 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2690 /* Unsubclass the page dialog window */
2691 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2692 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2693 (psp
->dwFlags
& PSP_HIDEHEADER
))
2695 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2696 PROPSHEET_WizardSubclassProc
, 1);
2699 if(psInfo
->proppage
[i
].hwndPage
)
2700 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2704 if ((psp
->dwFlags
& PSP_USETITLE
) && psInfo
->proppage
[i
].pszText
)
2705 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2707 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2711 DeleteObject(psInfo
->hFont
);
2712 DeleteObject(psInfo
->hFontBold
);
2713 /* If we created the bitmaps, destroy them */
2714 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2715 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2716 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2717 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2718 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2719 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2721 Free(psInfo
->proppage
);
2722 Free(psInfo
->strPropertiesFor
);
2723 ImageList_Destroy(psInfo
->hImageList
);
2725 GlobalFree((HGLOBAL
)psInfo
);
2728 static INT
do_loop(PropSheetInfo
*psInfo
)
2732 HWND hwnd
= psInfo
->hwnd
;
2734 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2739 if(!IsDialogMessageW(hwnd
, &msg
))
2741 TranslateMessage(&msg
);
2742 DispatchMessageW(&msg
);
2748 PostQuitMessage(msg
.wParam
);
2752 DestroyWindow(hwnd
);
2756 /******************************************************************************
2757 * PropertySheet (COMCTL32.@)
2758 * PropertySheetA (COMCTL32.@)
2760 * Creates a property sheet in the specified property sheet header.
2763 * Modal property sheets: Positive if successful or -1 otherwise.
2764 * Modeless property sheets: Property sheet handle.
2766 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2767 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2769 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2772 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2773 sizeof(PropSheetInfo
));
2777 TRACE("(%p)\n", lppsh
);
2779 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2781 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2783 pByte
= (BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2785 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2787 if (!(lppsh
->dwFlags
& PSH_PROPSHEETPAGE
))
2788 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2791 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2792 pByte
+= ((LPPROPSHEETPAGEA
)pByte
)->dwSize
;
2795 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2798 if (lppsh
->dwFlags
& PSH_PROPSHEETPAGE
)
2799 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2805 psInfo
->unicode
= FALSE
;
2806 psInfo
->ended
= FALSE
;
2808 bRet
= PROPSHEET_CreateDialog(psInfo
);
2809 if(!psInfo
->isModeless
)
2810 bRet
= do_loop(psInfo
);
2815 /******************************************************************************
2816 * PropertySheetW (COMCTL32.@)
2818 * See PropertySheetA.
2820 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2823 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GlobalAlloc(GPTR
,
2824 sizeof(PropSheetInfo
));
2828 TRACE("(%p)\n", lppsh
);
2830 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2832 psInfo
->proppage
= (PropPageInfo
*) Alloc(sizeof(PropPageInfo
) *
2834 pByte
= (BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2836 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2838 if (!(lppsh
->dwFlags
& PSH_PROPSHEETPAGE
))
2839 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2842 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2843 pByte
+= ((LPPROPSHEETPAGEW
)pByte
)->dwSize
;
2846 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2849 if (lppsh
->dwFlags
& PSH_PROPSHEETPAGE
)
2850 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2856 psInfo
->unicode
= TRUE
;
2857 psInfo
->ended
= FALSE
;
2859 bRet
= PROPSHEET_CreateDialog(psInfo
);
2860 if(!psInfo
->isModeless
)
2861 bRet
= do_loop(psInfo
);
2866 static LPWSTR
load_string( HINSTANCE instance
, LPCWSTR str
)
2871 if (IS_INTRESOURCE(str
))
2876 WORD i
, id
= LOWORD(str
);
2878 if (!(hrsrc
= FindResourceW( instance
, MAKEINTRESOURCEW((id
>> 4) + 1), (LPWSTR
)RT_STRING
)))
2880 if (!(hmem
= LoadResource( instance
, hrsrc
))) return NULL
;
2881 if (!(ptr
= LockResource( hmem
))) return NULL
;
2882 for (i
= id
& 0x0f; i
> 0; i
--) ptr
+= *ptr
+ 1;
2884 if (!len
) return NULL
;
2885 ret
= Alloc( (len
+ 1) * sizeof(WCHAR
) );
2888 memcpy( ret
, ptr
+ 1, len
* sizeof(WCHAR
) );
2894 int len
= (strlenW(str
) + 1) * sizeof(WCHAR
);
2896 if (ret
) memcpy( ret
, str
, len
);
2902 /******************************************************************************
2903 * CreatePropertySheetPage (COMCTL32.@)
2904 * CreatePropertySheetPageA (COMCTL32.@)
2906 * Creates a new property sheet page.
2909 * Success: Handle to new property sheet page.
2913 * An application must use the PSM_ADDPAGE message to add the new page to
2914 * an existing property sheet.
2916 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2917 LPCPROPSHEETPAGEA lpPropSheetPage
)
2919 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2921 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEA
)));
2923 ppsp
->dwFlags
&= ~ PSP_INTERNAL_UNICODE
;
2925 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2927 if (HIWORD( ppsp
->u
.pszTemplate
))
2929 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
) + 1;
2930 ppsp
->u
.pszTemplate
= Alloc( len
);
2931 strcpy( (LPSTR
)ppsp
->u
.pszTemplate
, lpPropSheetPage
->u
.pszTemplate
);
2935 if (ppsp
->dwFlags
& PSP_USEICONID
)
2937 if (HIWORD( ppsp
->u2
.pszIcon
))
2938 PROPSHEET_AtoW(&ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2941 if (ppsp
->dwFlags
& PSP_USETITLE
)
2943 if (HIWORD( ppsp
->pszTitle
))
2944 PROPSHEET_AtoW( &ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2946 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
2949 ppsp
->pszTitle
= NULL
;
2951 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
2952 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
2954 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
2956 if (HIWORD( ppsp
->pszHeaderTitle
))
2957 PROPSHEET_AtoW(&ppsp
->pszHeaderTitle
, lpPropSheetPage
->pszHeaderTitle
);
2959 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
2962 ppsp
->pszHeaderTitle
= NULL
;
2964 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
2966 if (HIWORD( ppsp
->pszHeaderSubTitle
))
2967 PROPSHEET_AtoW(&ppsp
->pszHeaderSubTitle
, lpPropSheetPage
->pszHeaderSubTitle
);
2969 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
2972 ppsp
->pszHeaderSubTitle
= NULL
;
2974 return (HPROPSHEETPAGE
)ppsp
;
2977 /******************************************************************************
2978 * CreatePropertySheetPageW (COMCTL32.@)
2980 * See CreatePropertySheetA.
2982 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
2984 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2986 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEW
)));
2988 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
2990 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2992 if (HIWORD( ppsp
->u
.pszTemplate
))
2994 int len
= strlenW(lpPropSheetPage
->u
.pszTemplate
) + 1;
2995 ppsp
->u
.pszTemplate
= Alloc( len
* sizeof (WCHAR
) );
2996 strcpyW( (WCHAR
*)ppsp
->u
.pszTemplate
, lpPropSheetPage
->u
.pszTemplate
);
3000 if ( ppsp
->dwFlags
& PSP_USEICONID
)
3002 if (HIWORD( ppsp
->u2
.pszIcon
))
3004 int len
= strlenW(lpPropSheetPage
->u2
.pszIcon
) + 1;
3005 ppsp
->u2
.pszIcon
= Alloc( len
* sizeof (WCHAR
) );
3006 strcpyW( (WCHAR
*)ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
3010 if (ppsp
->dwFlags
& PSP_USETITLE
)
3011 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3013 ppsp
->pszTitle
= NULL
;
3015 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3016 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3018 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3019 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3021 ppsp
->pszHeaderTitle
= NULL
;
3023 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3024 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3026 ppsp
->pszHeaderSubTitle
= NULL
;
3028 return (HPROPSHEETPAGE
)ppsp
;
3031 /******************************************************************************
3032 * DestroyPropertySheetPage (COMCTL32.@)
3034 * Destroys a property sheet page previously created with
3035 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
3042 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
3044 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3049 if ( !(psp
->dwFlags
& PSP_DLGINDIRECT
) && HIWORD( psp
->u
.pszTemplate
) )
3050 Free ((LPVOID
)psp
->u
.pszTemplate
);
3052 if ( (psp
->dwFlags
& PSP_USEICONID
) && HIWORD( psp
->u2
.pszIcon
) )
3053 Free ((LPVOID
)psp
->u2
.pszIcon
);
3055 if ((psp
->dwFlags
& PSP_USETITLE
) && HIWORD( psp
->pszTitle
))
3056 Free ((LPVOID
)psp
->pszTitle
);
3063 /******************************************************************************
3064 * PROPSHEET_IsDialogMessage
3066 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3068 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3071 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3074 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3077 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3079 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3081 switch (lpMsg
->wParam
)
3084 if (GetKeyState(VK_SHIFT
) & 0x8000)
3090 case VK_NEXT
: new_page
= 1; break;
3091 case VK_PRIOR
: new_page
= -1; break;
3097 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3099 new_page
+= psInfo
->active_page
;
3102 new_page
= psInfo
->nPages
- 1;
3103 else if (new_page
>= psInfo
->nPages
)
3106 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3113 return IsDialogMessageW(hwnd
, lpMsg
);
3116 /******************************************************************************
3117 * PROPSHEET_DoCommand
3119 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3125 case IDC_APPLY_BUTTON
:
3127 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3129 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3134 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3138 if (psInfo
->restartWindows
)
3139 result
= ID_PSRESTARTWINDOWS
;
3141 /* reboot system takes precedence over restart windows */
3142 if (psInfo
->rebootSystem
)
3143 result
= ID_PSREBOOTSYSTEM
;
3145 if (psInfo
->isModeless
)
3146 psInfo
->activeValid
= FALSE
;
3148 psInfo
->ended
= TRUE
;
3151 EnableWindow(hwndApplyBtn
, FALSE
);
3156 case IDC_BACK_BUTTON
:
3157 PROPSHEET_Back(hwnd
);
3160 case IDC_NEXT_BUTTON
:
3161 PROPSHEET_Next(hwnd
);
3164 case IDC_FINISH_BUTTON
:
3165 PROPSHEET_Finish(hwnd
);
3169 PROPSHEET_Cancel(hwnd
, 0);
3173 PROPSHEET_Help(hwnd
);
3183 /******************************************************************************
3186 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3188 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3193 HPALETTE hOldPal
= 0;
3197 LPCPROPSHEETPAGEW ppshpage
;
3198 WCHAR szBuffer
[256];
3201 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3204 hdcSrc
= CreateCompatibleDC(0);
3205 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3207 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3208 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3210 if ( (!(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3211 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3212 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3214 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3216 COLORREF clrOld
= 0;
3219 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3220 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3222 GetClientRect(hwndLineHeader
, &r
);
3223 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3224 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3226 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), (LPVOID
)&bm
);
3228 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3230 /* Fill the unoccupied part of the header with color of the
3231 * left-top pixel, but do it only when needed.
3233 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3235 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3236 CopyRect(&r
, &rzone
);
3237 if (bm
.bmWidth
< r
.right
)
3239 r
.left
= bm
.bmWidth
;
3240 FillRect(hdc
, &r
, hbr
);
3242 if (bm
.bmHeight
< r
.bottom
)
3245 r
.top
= bm
.bmHeight
;
3246 FillRect(hdc
, &r
, hbr
);
3251 /* Draw the header itself. */
3253 bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3254 hdcSrc
, 0, 0, SRCCOPY
);
3258 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3259 FillRect(hdc
, &rzone
, hbr
);
3261 /* Draw the header bitmap. It's always centered like a
3262 * common 49 x 49 bitmap. */
3263 BitBlt(hdc
, rzone
.right
- 49 - ((rzone
.bottom
- 49) / 2),
3264 (rzone
.bottom
- 49) / 2,
3265 bm
.bmWidth
, bm
.bmHeight
,
3266 hdcSrc
, 0, 0, SRCCOPY
);
3268 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3269 * if its height is smaller than 49 pixels. Because the reason
3270 * for this bug is unknown the current code doesn't try to
3274 clrOld
= SetTextColor (hdc
, 0x00000000);
3275 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3277 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3278 SetRect(&r
, 20, 10, 0, 0);
3279 if (HIWORD(ppshpage
->pszHeaderTitle
))
3281 if (psInfo
->unicode
)
3282 DrawTextW(hdc
, (LPWSTR
)ppshpage
->pszHeaderTitle
,
3283 -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3285 DrawTextA(hdc
, (LPCSTR
)ppshpage
->pszHeaderTitle
,
3286 -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3290 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderTitle
,
3294 DrawTextW(hdc
, szBuffer
, nLength
,
3295 &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3300 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3301 SelectObject(hdc
, psInfo
->hFont
);
3302 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3303 if (HIWORD(ppshpage
->pszHeaderTitle
))
3305 if (psInfo
->unicode
)
3306 DrawTextW(hdc
, (LPWSTR
)ppshpage
->pszHeaderSubTitle
,
3307 -1, &r
, DT_LEFT
| DT_SINGLELINE
);
3309 DrawTextA(hdc
, (LPCSTR
)ppshpage
->pszHeaderSubTitle
,
3310 -1, &r
, DT_LEFT
| DT_SINGLELINE
);
3314 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderSubTitle
,
3318 DrawTextW(hdc
, szBuffer
, nLength
,
3319 &r
, DT_LEFT
| DT_SINGLELINE
);
3324 offsety
= rzone
.bottom
+ 2;
3326 SetTextColor(hdc
, clrOld
);
3327 SetBkMode(hdc
, oldBkMode
);
3328 SelectObject(hdc
, hOldFont
);
3329 SelectObject(hdcSrc
, hbmp
);
3332 if ( (ppshpage
->dwFlags
& PSP_HIDEHEADER
) &&
3333 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3334 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3336 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3338 GetClientRect(hwndLine
, &r
);
3339 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3343 rzone
.right
= r
.right
;
3344 rzone
.bottom
= r
.top
- 1;
3346 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3347 FillRect(hdc
, &rzone
, hbr
);
3349 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), (LPVOID
)&bm
);
3350 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3352 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3353 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3355 /* If the bitmap is not big enough, fill the remaining area
3356 with the color of pixel (0,0) of bitmap - see MSDN */
3357 if (r
.top
> bm
.bmHeight
) {
3358 r
.bottom
= r
.top
- 1;
3359 r
.top
= bm
.bmHeight
;
3361 r
.right
= bm
.bmWidth
;
3362 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3363 FillRect(hdc
, &r
, hbr
);
3367 SelectObject(hdcSrc
, hbmp
);
3370 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3371 SelectPalette(hdc
, hOldPal
, FALSE
);
3375 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3380 /******************************************************************************
3381 * PROPSHEET_DialogProc
3383 static INT_PTR CALLBACK
3384 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3386 TRACE("hwnd=%p msg=0x%04x wparam=%x lparam=%lx\n",
3387 hwnd
, uMsg
, wParam
, lParam
);
3393 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3394 WCHAR
* strCaption
= (WCHAR
*)Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3395 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3396 LPCPROPSHEETPAGEW ppshpage
;
3400 /* Using PropSheetInfoStr to store extra data doesn't match the native
3401 * common control: native uses TCM_[GS]ETITEM
3403 SetPropW(hwnd
, PropSheetInfoStr
, (HANDLE
)psInfo
);
3406 * psInfo->hwnd is not being used by WINE code - it exists
3407 * for compatibility with "real" Windoze. The same about
3408 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3411 psInfo
->hwnd
= hwnd
;
3412 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3414 /* set up the Next and Back buttons by default */
3415 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3418 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3419 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3420 logFont
.lfWeight
= FW_BOLD
;
3421 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3424 * Small icon in the title bar.
3426 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3427 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3430 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3431 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3433 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3434 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3435 psInfo
->ppshheader
.u
.pszIcon
,
3440 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3442 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3445 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3446 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3448 psInfo
->strPropertiesFor
= strCaption
;
3450 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3452 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3454 PROPSHEET_LoadWizardBitmaps(psInfo
);
3456 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3458 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3459 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3460 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3464 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3466 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3467 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3471 if (!HIWORD(psInfo
->ppshheader
.pszCaption
) &&
3472 psInfo
->ppshheader
.hInstance
)
3476 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3477 (UINT_PTR
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3478 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3482 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3483 psInfo
->ppshheader
.pszCaption
);
3487 if (psInfo
->useCallback
)
3488 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
,
3489 PSCB_INITIALIZED
, (LPARAM
)0);
3491 idx
= psInfo
->active_page
;
3492 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[idx
].hpage
;
3493 psInfo
->active_page
= -1;
3495 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3497 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3498 * as some programs call TCM_GETCURSEL to get the current selection
3499 * from which to switch to the next page */
3500 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3505 case WM_PRINTCLIENT
:
3507 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3511 PROPSHEET_CleanUp(hwnd
);
3515 PROPSHEET_Cancel(hwnd
, 1);
3516 return FALSE
; /* let DefDlgProc post us WM_COMMAND/IDCANCEL */
3519 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3521 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
, PropSheetInfoStr
);
3526 /* No default handler, forward notification to active page */
3527 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3529 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3530 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3537 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3539 if (pnmh
->code
== TCN_SELCHANGE
)
3541 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3542 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3545 if(pnmh
->code
== TCN_SELCHANGING
)
3547 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3548 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3555 case WM_SYSCOLORCHANGE
:
3556 COMCTL32_RefreshSysColors();
3559 case PSM_GETCURRENTPAGEHWND
:
3561 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3568 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3569 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3571 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3577 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3581 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3584 case PSM_GETTABCONTROL
:
3586 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3588 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3597 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3598 if(msgResult
!= FALSE
)
3600 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3603 (HPROPSHEETPAGE
)lParam
);
3606 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3611 case PSM_CANCELTOCLOSE
:
3613 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3614 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3615 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3617 EnableWindow(hwndCancel
, FALSE
);
3618 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, sizeof(buf
)))
3619 SetWindowTextW(hwndOK
, buf
);
3624 case PSM_RESTARTWINDOWS
:
3626 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3632 psInfo
->restartWindows
= TRUE
;
3636 case PSM_REBOOTSYSTEM
:
3638 PropSheetInfo
* psInfo
= (PropSheetInfo
*) GetPropW(hwnd
,
3644 psInfo
->rebootSystem
= TRUE
;
3649 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3653 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3658 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3660 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3665 case PSM_QUERYSIBLINGS
:
3667 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3669 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3677 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3678 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3679 * on success or FALSE otherwise, as specified on MSDN Online.
3680 * Also see the MFC code for
3681 * CPropertySheet::AddPage(CPropertyPage* pPage).
3684 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3686 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3691 case PSM_REMOVEPAGE
:
3692 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3695 case PSM_ISDIALOGMESSAGE
:
3697 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3698 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3702 case PSM_PRESSBUTTON
:
3703 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3706 case PSM_SETFINISHTEXTA
:
3707 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3710 case PSM_SETWIZBUTTONS
:
3711 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3714 case PSM_SETCURSELID
:
3715 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3718 case PSM_SETFINISHTEXTW
:
3719 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3722 case PSM_INSERTPAGE
:
3724 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3725 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3729 case PSM_SETHEADERTITLEW
:
3730 PROPSHEET_SetHeaderTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3733 case PSM_SETHEADERTITLEA
:
3734 PROPSHEET_SetHeaderTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3737 case PSM_SETHEADERSUBTITLEW
:
3738 PROPSHEET_SetHeaderSubTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3741 case PSM_SETHEADERSUBTITLEA
:
3742 PROPSHEET_SetHeaderSubTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3745 case PSM_HWNDTOINDEX
:
3747 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3748 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3752 case PSM_INDEXTOHWND
:
3754 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3755 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3759 case PSM_PAGETOINDEX
:
3761 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3762 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3766 case PSM_INDEXTOPAGE
:
3768 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3769 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3775 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3776 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3782 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3783 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3789 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3790 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3794 case PSM_RECALCPAGESIZES
:
3796 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3797 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);