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
57 /******************************************************************************
81 } MyDLGITEMTEMPLATEEX
;
84 typedef struct tagPropPageInfo
86 HPROPSHEETPAGE hpage
; /* to keep track of pages not passed to PropertySheet */
95 typedef struct tagPropSheetInfo
98 PROPSHEETHEADERW ppshheader
;
100 LPWSTR strPropertiesFor
;
110 PropPageInfo
* proppage
;
115 HIMAGELIST hImageList
;
126 /******************************************************************************
127 * Defines and global variables
130 static const WCHAR PropSheetInfoStr
[] =
131 {'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0 };
133 #define PSP_INTERNAL_UNICODE 0x80000000
135 #define MAX_CAPTION_LENGTH 255
136 #define MAX_TABTEXT_LENGTH 255
137 #define MAX_BUTTONTEXT_LENGTH 64
139 #define INTRNL_ANY_WIZARD (PSH_WIZARD | PSH_WIZARD97_OLD | PSH_WIZARD97_NEW | PSH_WIZARD_LITE)
141 /* Wizard metrics specified in DLUs */
142 #define WIZARD_PADDING 7
143 #define WIZARD_HEADER_HEIGHT 36
145 /******************************************************************************
148 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
);
149 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
);
150 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
);
151 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
154 HPROPSHEETPAGE hpage
);
155 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, const PropSheetInfo
* psInfo
, int original_index
);
156 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
);
157 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
);
158 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
, int index
, HPROPSHEETPAGE hpage
);
159 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
);
161 static INT_PTR CALLBACK
162 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
164 WINE_DEFAULT_DEBUG_CHANNEL(propsheet
);
166 #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");}
167 /******************************************************************************
168 * PROPSHEET_UnImplementedFlags
170 * Document use of flags we don't implement yet.
172 static VOID
PROPSHEET_UnImplementedFlags(DWORD dwFlags
)
179 * unhandled header flags:
180 * PSH_RTLREADING 0x00000800
181 * PSH_STRETCHWATERMARK 0x00040000
182 * PSH_USEPAGELANG 0x00200000
185 add_flag(PSH_RTLREADING
);
186 add_flag(PSH_STRETCHWATERMARK
);
187 add_flag(PSH_USEPAGELANG
);
188 if (string
[0] != '\0')
189 FIXME("%s\n", string
);
193 /******************************************************************************
194 * PROPSHEET_GetPageRect
196 * Retrieve rect from tab control and map into the dialog for SetWindowPos
198 static void PROPSHEET_GetPageRect(const PropSheetInfo
* psInfo
, HWND hwndDlg
,
199 RECT
*rc
, LPCPROPSHEETPAGEW ppshpage
)
201 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) {
205 if (((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
206 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
207 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) ||
208 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
))
210 rc
->left
= rc
->top
= WIZARD_PADDING
;
214 rc
->left
= rc
->top
= 0;
216 rc
->right
= psInfo
->width
- rc
->left
;
217 rc
->bottom
= psInfo
->height
- rc
->top
;
218 MapDialogRect(hwndDlg
, rc
);
220 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
221 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
222 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
))
224 hwndChild
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
225 GetClientRect(hwndChild
, &r
);
226 MapWindowPoints(hwndChild
, hwndDlg
, (LPPOINT
) &r
, 2);
227 rc
->top
+= r
.bottom
+ 1;
230 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
231 GetClientRect(hwndTabCtrl
, rc
);
232 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)rc
);
233 MapWindowPoints(hwndTabCtrl
, hwndDlg
, (LPPOINT
)rc
, 2);
237 /******************************************************************************
238 * PROPSHEET_FindPageByResId
240 * Find page index corresponding to page resource id.
242 static INT
PROPSHEET_FindPageByResId(const PropSheetInfo
* psInfo
, LRESULT resId
)
246 for (i
= 0; i
< psInfo
->nPages
; i
++)
248 LPCPROPSHEETPAGEA lppsp
= (LPCPROPSHEETPAGEA
)psInfo
->proppage
[i
].hpage
;
250 /* Fixme: if resource ID is a string shall we use strcmp ??? */
251 if (lppsp
->u
.pszTemplate
== (LPVOID
)resId
)
258 /******************************************************************************
261 * Convert ASCII to Unicode since all data is saved as Unicode.
263 static void PROPSHEET_AtoW(LPCWSTR
*tostr
, LPCSTR frstr
)
268 TRACE("<%s>\n", frstr
);
269 len
= MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, 0, 0);
270 to
= Alloc(len
* sizeof(WCHAR
));
271 MultiByteToWideChar(CP_ACP
, 0, frstr
, -1, to
, len
);
275 /******************************************************************************
276 * PROPSHEET_CollectSheetInfoCommon
278 * Common code for PROPSHEET_CollectSheetInfoA/W
280 static void PROPSHEET_CollectSheetInfoCommon(PropSheetInfo
* psInfo
, DWORD dwFlags
)
282 PROPSHEET_UnImplementedFlags(dwFlags
);
284 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
285 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
286 psInfo
->hasFinish
= dwFlags
& PSH_WIZARDHASFINISH
;
287 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
288 psInfo
->usePropPage
= dwFlags
& PSH_PROPSHEETPAGE
;
289 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
290 psInfo
->active_page
= 0;
293 psInfo
->hImageList
= 0;
294 psInfo
->activeValid
= FALSE
;
297 /******************************************************************************
298 * PROPSHEET_CollectSheetInfoA
300 * Collect relevant data.
302 static void PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh
,
303 PropSheetInfo
* psInfo
)
305 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERA
));
306 DWORD dwFlags
= lppsh
->dwFlags
;
308 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
)&& (lppsh
->pfnCallback
);
310 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
311 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",
312 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
,
313 debugstr_a(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
315 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
316 psInfo
->ppshheader
.pszCaption
= NULL
;
319 if (!IS_INTRESOURCE(lppsh
->pszCaption
))
321 int len
= MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, NULL
, 0);
322 WCHAR
*caption
= Alloc( len
*sizeof (WCHAR
) );
324 MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, caption
, len
);
325 psInfo
->ppshheader
.pszCaption
= caption
;
328 psInfo
->nPages
= lppsh
->nPages
;
330 if (dwFlags
& PSH_USEPSTARTPAGE
)
332 TRACE("PSH_USEPSTARTPAGE is on\n");
333 psInfo
->active_page
= 0;
336 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
338 PROPSHEET_CollectSheetInfoCommon(psInfo
, dwFlags
);
341 /******************************************************************************
342 * PROPSHEET_CollectSheetInfoW
344 * Collect relevant data.
346 static void PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
347 PropSheetInfo
* psInfo
)
349 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERW
));
350 DWORD dwFlags
= lppsh
->dwFlags
;
352 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
) && (lppsh
->pfnCallback
);
354 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
355 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",
356 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
, debugstr_w(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
358 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
359 psInfo
->ppshheader
.pszCaption
= NULL
;
362 if (!IS_INTRESOURCE(lppsh
->pszCaption
))
364 int len
= strlenW(lppsh
->pszCaption
);
365 WCHAR
*caption
= Alloc( (len
+1)*sizeof(WCHAR
) );
367 psInfo
->ppshheader
.pszCaption
= strcpyW( caption
, lppsh
->pszCaption
);
370 psInfo
->nPages
= lppsh
->nPages
;
372 if (dwFlags
& PSH_USEPSTARTPAGE
)
374 TRACE("PSH_USEPSTARTPAGE is on\n");
375 psInfo
->active_page
= 0;
378 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
380 PROPSHEET_CollectSheetInfoCommon(psInfo
, dwFlags
);
383 /******************************************************************************
384 * PROPSHEET_CollectPageInfo
386 * Collect property sheet data.
387 * With code taken from DIALOG_ParseTemplate32.
389 static BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
390 PropSheetInfo
* psInfo
,
391 int index
, BOOL resize
)
393 const DLGTEMPLATE
* pTemplate
;
402 psInfo
->proppage
[index
].hpage
= (HPROPSHEETPAGE
)lppsp
;
403 psInfo
->proppage
[index
].hwndPage
= 0;
404 psInfo
->proppage
[index
].isDirty
= FALSE
;
407 * Process property page flags.
409 dwFlags
= lppsp
->dwFlags
;
410 psInfo
->proppage
[index
].useCallback
= (dwFlags
& PSP_USECALLBACK
) && (lppsp
->pfnCallback
);
411 psInfo
->proppage
[index
].hasHelp
= dwFlags
& PSP_HASHELP
;
412 psInfo
->proppage
[index
].hasIcon
= dwFlags
& (PSP_USEHICON
| PSP_USEICONID
);
414 /* as soon as we have a page with the help flag, set the sheet flag on */
415 if (psInfo
->proppage
[index
].hasHelp
)
416 psInfo
->hasHelp
= TRUE
;
419 * Process page template.
421 if (dwFlags
& PSP_DLGINDIRECT
)
422 pTemplate
= lppsp
->u
.pResource
;
423 else if(dwFlags
& PSP_INTERNAL_UNICODE
)
425 HRSRC hResource
= FindResourceW(lppsp
->hInstance
,
426 lppsp
->u
.pszTemplate
,
428 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
430 pTemplate
= LockResource(hTemplate
);
434 HRSRC hResource
= FindResourceA(lppsp
->hInstance
,
435 (LPCSTR
)lppsp
->u
.pszTemplate
,
437 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
439 pTemplate
= LockResource(hTemplate
);
443 * Extract the size of the page and the caption.
448 p
= (const WORD
*)pTemplate
;
450 if (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
452 /* DLGTEMPLATEEX (not defined in any std. header file) */
456 p
+= 2; /* help ID */
457 p
+= 2; /* ext style */
465 p
+= 2; /* ext style */
471 width
= (WORD
)*p
; p
++;
472 height
= (WORD
)*p
; p
++;
474 /* Special calculation for interior wizard pages so the largest page is
475 * calculated correctly. We need to add all the padding and space occupied
476 * by the header so the width and height sums up to the whole wizard client
478 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
479 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
480 !(dwFlags
& PSP_HIDEHEADER
))
482 height
+= 2 * WIZARD_PADDING
+ WIZARD_HEADER_HEIGHT
;
483 width
+= 2 * WIZARD_PADDING
;
485 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
)
487 height
+= 2 * WIZARD_PADDING
;
488 width
+= 2 * WIZARD_PADDING
;
491 /* remember the largest width and height */
494 if (width
> psInfo
->width
)
495 psInfo
->width
= width
;
497 if (height
> psInfo
->height
)
498 psInfo
->height
= height
;
511 p
+= lstrlenW( p
) + 1;
525 p
+= lstrlenW( p
) + 1;
529 /* Extract the caption */
530 psInfo
->proppage
[index
].pszText
= p
;
531 TRACE("Tab %d %s\n",index
,debugstr_w( p
));
533 if (dwFlags
& PSP_USETITLE
)
537 static const WCHAR pszNull
[] = { '(','n','u','l','l',')',0 };
541 if (IS_INTRESOURCE( lppsp
->pszTitle
))
543 if (LoadStringW( lppsp
->hInstance
, (DWORD_PTR
)lppsp
->pszTitle
, szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0]) ))
551 pTitle
= lppsp
->pszTitle
;
553 len
= strlenW(pTitle
);
554 text
= Alloc( (len
+1)*sizeof (WCHAR
) );
555 psInfo
->proppage
[index
].pszText
= strcpyW( text
, pTitle
);
559 * Build the image list for icons
561 if ((dwFlags
& PSP_USEHICON
) || (dwFlags
& PSP_USEICONID
))
564 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
565 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
567 if (dwFlags
& PSP_USEICONID
)
568 hIcon
= LoadImageW(lppsp
->hInstance
, lppsp
->u2
.pszIcon
, IMAGE_ICON
,
569 icon_cx
, icon_cy
, LR_DEFAULTCOLOR
);
571 hIcon
= lppsp
->u2
.hIcon
;
575 if (psInfo
->hImageList
== 0 )
576 psInfo
->hImageList
= ImageList_Create(icon_cx
, icon_cy
, ILC_COLOR
, 1, 1);
578 ImageList_AddIcon(psInfo
->hImageList
, hIcon
);
586 /******************************************************************************
587 * PROPSHEET_CreateDialog
589 * Creates the actual property sheet.
591 static INT_PTR
PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
)
598 WORD resID
= IDD_PROPSHEET
;
600 TRACE("(%p)\n", psInfo
);
601 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
604 if( psInfo
->unicode
)
606 if(!(hRes
= FindResourceW(COMCTL32_hModule
,
607 MAKEINTRESOURCEW(resID
),
613 if(!(hRes
= FindResourceA(COMCTL32_hModule
,
614 MAKEINTRESOURCEA(resID
),
619 if(!(template = LoadResource(COMCTL32_hModule
, hRes
)))
623 * Make a copy of the dialog template.
625 resSize
= SizeofResource(COMCTL32_hModule
, hRes
);
627 temp
= Alloc(resSize
);
632 memcpy(temp
, template, resSize
);
634 if (psInfo
->ppshheader
.dwFlags
& PSH_NOCONTEXTHELP
)
636 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
637 ((MyDLGTEMPLATEEX
*)temp
)->style
&= ~DS_CONTEXTHELP
;
639 ((DLGTEMPLATE
*)temp
)->style
&= ~DS_CONTEXTHELP
;
641 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
642 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARDCONTEXTHELP
))
644 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
645 ((MyDLGTEMPLATEEX
*)temp
)->style
|= DS_CONTEXTHELP
;
647 ((DLGTEMPLATE
*)temp
)->style
|= DS_CONTEXTHELP
;
650 if (psInfo
->useCallback
)
651 (*(psInfo
->ppshheader
.pfnCallback
))(0, PSCB_PRECREATE
, (LPARAM
)temp
);
653 /* NOTE: MSDN states "Returns a positive value if successful, or -1
654 * otherwise for modal property sheets.", but this is wrong. The
655 * actual return value is either TRUE (success), FALSE (cancel) or
657 if( psInfo
->unicode
)
659 ret
= (INT_PTR
)CreateDialogIndirectParamW(psInfo
->ppshheader
.hInstance
,
660 temp
, psInfo
->ppshheader
.hwndParent
,
661 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
662 if ( !ret
) ret
= -1;
666 ret
= (INT_PTR
)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
667 temp
, psInfo
->ppshheader
.hwndParent
,
668 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
669 if ( !ret
) ret
= -1;
677 /******************************************************************************
678 * PROPSHEET_SizeMismatch
680 * Verify that the tab control and the "largest" property sheet page dlg. template
683 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
685 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
686 RECT rcOrigTab
, rcPage
;
691 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
692 TRACE("orig tab %s\n", wine_dbgstr_rect(&rcOrigTab
));
697 SetRect(&rcPage
, 0, 0, psInfo
->width
, psInfo
->height
);
698 MapDialogRect(hwndDlg
, &rcPage
);
699 TRACE("biggest page %s\n", wine_dbgstr_rect(&rcPage
));
701 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
703 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
709 /******************************************************************************
710 * PROPSHEET_AdjustSize
712 * Resizes the property sheet and the tab control to fit the largest page.
714 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
716 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
717 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
720 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
724 /* Get the height of buttons */
725 GetClientRect(hwndButton
, &rc
);
726 buttonHeight
= rc
.bottom
;
731 SetRect(&rc
, 0, 0, psInfo
->width
, psInfo
->height
);
732 MapDialogRect(hwndDlg
, &rc
);
734 /* retrieve the dialog units */
735 units
.left
= units
.right
= 4;
736 units
.top
= units
.bottom
= 8;
737 MapDialogRect(hwndDlg
, &units
);
740 * Resize the tab control.
742 GetClientRect(hwndTabCtrl
,&tabRect
);
744 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
746 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
748 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
749 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
752 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
754 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
755 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
758 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
762 TRACE("setting tab %p, rc (0,0)-(%d,%d)\n",
763 hwndTabCtrl
, rc
.right
, rc
.bottom
);
764 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
765 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
767 GetClientRect(hwndTabCtrl
, &rc
);
769 TRACE("tab client rc %s\n", wine_dbgstr_rect(&rc
));
771 rc
.right
+= (padding
.x
* 2);
772 rc
.bottom
+= buttonHeight
+ (3 * padding
.y
);
774 style
= GetWindowLongW(hwndDlg
, GWL_STYLE
);
775 if (!(style
& WS_CHILD
))
776 AdjustWindowRect(&rc
, style
, FALSE
);
782 * Resize the property sheet.
784 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
785 hwndDlg
, rc
.right
, rc
.bottom
);
786 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
787 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
791 /******************************************************************************
792 * PROPSHEET_AdjustSizeWizard
794 * Resizes the property sheet to fit the largest page.
796 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
798 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
799 RECT rc
, lineRect
, dialogRect
;
801 /* Biggest page size */
802 SetRect(&rc
, 0, 0, psInfo
->width
, psInfo
->height
);
803 MapDialogRect(hwndDlg
, &rc
);
805 TRACE("Biggest page %s\n", wine_dbgstr_rect(&rc
));
807 /* Add space for the buttons row */
808 GetWindowRect(hwndLine
, &lineRect
);
809 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
810 GetClientRect(hwndDlg
, &dialogRect
);
811 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
813 /* Convert the client coordinates to window coordinates */
814 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
816 /* Resize the property sheet */
817 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
818 hwndDlg
, rc
.right
, rc
.bottom
);
819 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
820 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
825 /******************************************************************************
826 * PROPSHEET_AdjustButtons
828 * Adjusts the buttons' positions.
830 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, const PropSheetInfo
* psInfo
)
832 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
836 int buttonWidth
, buttonHeight
;
837 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
839 if (psInfo
->hasApply
)
846 * Obtain the size of the buttons.
848 GetClientRect(hwndButton
, &rcSheet
);
849 buttonWidth
= rcSheet
.right
;
850 buttonHeight
= rcSheet
.bottom
;
853 * Get the size of the property sheet.
855 GetClientRect(hwndParent
, &rcSheet
);
858 * All buttons will be at this y coordinate.
860 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
863 * Position OK button and make it default.
865 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
867 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
869 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
870 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
872 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
876 * Position Cancel button.
878 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
880 x
+= padding
.x
+ buttonWidth
;
882 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
883 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
886 * Position Apply button.
888 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
891 x
+= padding
.x
+ buttonWidth
;
893 ShowWindow(hwndButton
, SW_HIDE
);
895 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
896 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
897 EnableWindow(hwndButton
, FALSE
);
900 * Position Help button.
902 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
904 x
+= padding
.x
+ buttonWidth
;
905 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
906 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
909 ShowWindow(hwndButton
, SW_HIDE
);
914 /******************************************************************************
915 * PROPSHEET_AdjustButtonsWizard
917 * Adjusts the buttons' positions.
919 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
920 const PropSheetInfo
* psInfo
)
922 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
923 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
924 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
928 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
929 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
933 if (psInfo
->hasFinish
)
937 * Obtain the size of the buttons.
939 GetClientRect(hwndButton
, &rcSheet
);
940 buttonWidth
= rcSheet
.right
;
941 buttonHeight
= rcSheet
.bottom
;
943 GetClientRect(hwndLine
, &rcSheet
);
944 lineHeight
= rcSheet
.bottom
;
947 * Get the size of the property sheet.
949 GetClientRect(hwndParent
, &rcSheet
);
952 * All buttons will be at this y coordinate.
954 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
957 * Position the Back button.
959 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
961 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1)) - buttonWidth
;
963 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
964 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
967 * Position the Next button.
969 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
973 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
974 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
977 * Position the Finish button.
979 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
981 if (psInfo
->hasFinish
)
982 x
+= padding
.x
+ buttonWidth
;
984 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
985 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
987 if (!psInfo
->hasFinish
)
988 ShowWindow(hwndButton
, SW_HIDE
);
991 * Position the Cancel button.
993 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
995 x
+= padding
.x
+ buttonWidth
;
997 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
998 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1001 * Position Help button.
1003 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1005 if (psInfo
->hasHelp
)
1007 x
+= padding
.x
+ buttonWidth
;
1009 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1010 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1013 ShowWindow(hwndButton
, SW_HIDE
);
1015 if (psInfo
->ppshheader
.dwFlags
&
1016 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1020 * Position and resize the sunken line.
1023 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1025 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1026 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1027 SWP_NOZORDER
| SWP_NOACTIVATE
);
1030 * Position and resize the header sunken line.
1033 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1034 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1035 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1036 ShowWindow(hwndLineHeader
, SW_HIDE
);
1041 /******************************************************************************
1042 * PROPSHEET_GetPaddingInfo
1044 * Returns the layout information.
1046 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1048 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1050 PADDING_INFO padding
;
1052 GetWindowRect(hwndTab
, &rcTab
);
1053 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rcTab
, 2 );
1055 padding
.x
= rcTab
.left
;
1056 padding
.y
= rcTab
.top
;
1061 /******************************************************************************
1062 * PROPSHEET_GetPaddingInfoWizard
1064 * Returns the layout information.
1065 * Vertical spacing is the distance between the line and the buttons.
1066 * Do NOT use the Help button to gather padding information when it isn't mapped
1067 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1068 * for it in this case !
1069 * FIXME: I'm not sure about any other coordinate problems with these evil
1070 * buttons. Fix it in case additional problems appear or maybe calculate
1071 * a padding in a completely different way, as this is somewhat messy.
1073 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1076 PADDING_INFO padding
;
1080 POINT ptButton
, ptLine
;
1083 if (psInfo
->hasHelp
)
1089 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1091 idButton
= IDC_NEXT_BUTTON
;
1095 /* hopefully this is ok */
1096 idButton
= IDCANCEL
;
1100 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1101 GetWindowRect(hwndControl
, &rc
);
1102 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1103 ptButton
.x
= rc
.left
;
1104 ptButton
.y
= rc
.top
;
1107 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1108 GetWindowRect(hwndControl
, &rc
);
1109 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1111 ptLine
.y
= rc
.bottom
;
1113 padding
.y
= ptButton
.y
- ptLine
.y
;
1116 ERR("padding negative ! Please report this !\n");
1118 /* this is most probably not correct, but the best we have now */
1119 padding
.x
= padding
.y
;
1123 /******************************************************************************
1124 * PROPSHEET_CreateTabControl
1126 * Insert the tabs in the tab control.
1128 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1129 const PropSheetInfo
* psInfo
)
1131 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1137 item
.mask
= TCIF_TEXT
;
1138 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1140 nTabs
= psInfo
->nPages
;
1143 * Set the image list for icons.
1145 if (psInfo
->hImageList
)
1147 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1150 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 0, 0);
1151 for (i
= 0; i
< nTabs
; i
++)
1153 if ( psInfo
->proppage
[i
].hasIcon
)
1155 item
.mask
|= TCIF_IMAGE
;
1156 item
.iImage
= iImage
++;
1160 item
.mask
&= ~TCIF_IMAGE
;
1163 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1164 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, i
, (LPARAM
)&item
);
1166 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 1, 0);
1171 /******************************************************************************
1172 * PROPSHEET_WizardSubclassProc
1174 * Subclassing window procedure for wizard exterior pages to prevent drawing
1175 * background and so drawing above the watermark.
1177 static LRESULT CALLBACK
1178 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1185 case WM_CTLCOLORSTATIC
:
1186 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1187 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1190 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1194 * Get the size of an in-memory Template
1196 *( Based on the code of PROPSHEET_CollectPageInfo)
1197 * See also dialog.c/DIALOG_ParseTemplate32().
1200 static UINT
GetTemplateSize(const DLGTEMPLATE
* pTemplate
)
1203 const WORD
* p
= (const WORD
*)pTemplate
;
1204 BOOL istemplateex
= (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1210 /* DLGTEMPLATEEX (not defined in any std. header file) */
1212 TRACE("is DLGTEMPLATEEX\n");
1214 p
++; /* signature */
1215 p
+= 2; /* help ID */
1216 p
+= 2; /* ext style */
1223 TRACE("is DLGTEMPLATE\n");
1225 p
+= 2; /* ext style */
1228 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1244 TRACE("menu %s\n",debugstr_w( p
));
1245 p
+= lstrlenW( p
) + 1;
1256 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1259 TRACE("class %s\n",debugstr_w( p
));
1260 p
+= lstrlenW( p
) + 1;
1265 TRACE("title %s\n",debugstr_w( p
));
1266 p
+= lstrlenW( p
) + 1;
1268 /* font, if DS_SETFONT set */
1269 if ((DS_SETFONT
& ((istemplateex
)? ((const MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1272 p
+=(istemplateex
)?3:1;
1273 TRACE("font %s\n",debugstr_w( p
));
1274 p
+= lstrlenW( p
) + 1; /* the font name */
1277 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1278 * that are following the DLGTEMPLATE(EX) data */
1279 TRACE("%d items\n",nrofitems
);
1280 while (nrofitems
> 0)
1282 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1285 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1294 TRACE("class ordinal 0x%08x\n",*(const DWORD
*)p
);
1298 TRACE("class %s\n",debugstr_w( p
));
1299 p
+= lstrlenW( p
) + 1;
1303 /* check title text */
1310 TRACE("text ordinal 0x%08x\n",*(const DWORD
*)p
);
1314 TRACE("text %s\n",debugstr_w( p
));
1315 p
+= lstrlenW( p
) + 1;
1318 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1322 ret
= (p
- (const WORD
*)pTemplate
) * sizeof(WORD
);
1323 TRACE("%p %p size 0x%08x\n", p
, pTemplate
, ret
);
1327 /******************************************************************************
1328 * PROPSHEET_CreatePage
1332 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1334 const PropSheetInfo
* psInfo
,
1335 LPCPROPSHEETPAGEW ppshpage
)
1337 const DLGTEMPLATE
* pTemplate
;
1340 DLGTEMPLATE
* pTemplateCopy
= NULL
;
1342 TRACE("index %d\n", index
);
1344 if (ppshpage
== NULL
)
1349 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1351 pTemplate
= ppshpage
->u
.pResource
;
1352 resSize
= GetTemplateSize(pTemplate
);
1354 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1359 hResource
= FindResourceW(ppshpage
->hInstance
,
1360 ppshpage
->u
.pszTemplate
,
1365 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1367 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1371 pTemplate
= LockResource(hTemplate
);
1373 * Make a copy of the dialog template to make it writable
1381 hResource
= FindResourceA(ppshpage
->hInstance
,
1382 (LPCSTR
)ppshpage
->u
.pszTemplate
,
1387 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1389 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1393 pTemplate
= LockResource(hTemplate
);
1395 * Make a copy of the dialog template to make it writable
1398 pTemplateCopy
= Alloc(resSize
);
1402 TRACE("copying pTemplate %p into pTemplateCopy %p (%d)\n", pTemplate
, pTemplateCopy
, resSize
);
1403 memcpy(pTemplateCopy
, pTemplate
, resSize
);
1405 if (((MyDLGTEMPLATEEX
*)pTemplateCopy
)->signature
== 0xFFFF)
1407 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1408 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~DS_MODALFRAME
;
1409 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_CAPTION
;
1410 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_SYSMENU
;
1411 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_POPUP
;
1412 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_DISABLED
;
1413 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_VISIBLE
;
1414 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_THICKFRAME
;
1416 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->exStyle
|= WS_EX_CONTROLPARENT
;
1420 pTemplateCopy
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1421 pTemplateCopy
->style
&= ~DS_MODALFRAME
;
1422 pTemplateCopy
->style
&= ~WS_CAPTION
;
1423 pTemplateCopy
->style
&= ~WS_SYSMENU
;
1424 pTemplateCopy
->style
&= ~WS_POPUP
;
1425 pTemplateCopy
->style
&= ~WS_DISABLED
;
1426 pTemplateCopy
->style
&= ~WS_VISIBLE
;
1427 pTemplateCopy
->style
&= ~WS_THICKFRAME
;
1429 pTemplateCopy
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1432 if (psInfo
->proppage
[index
].useCallback
)
1433 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1434 (LPPROPSHEETPAGEW
)ppshpage
);
1436 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1437 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1440 ppshpage
->pfnDlgProc
,
1443 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1446 ppshpage
->pfnDlgProc
,
1448 /* Free a no more needed copy */
1449 Free(pTemplateCopy
);
1454 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1456 /* Subclass exterior wizard pages */
1457 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1458 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1459 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1461 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1462 (DWORD_PTR
)ppshpage
);
1464 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1465 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1470 /******************************************************************************
1471 * PROPSHEET_LoadWizardBitmaps
1473 * Loads the watermark and header bitmaps for a wizard.
1475 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1477 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1479 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1480 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1481 considers hbmWatermark as valid. */
1482 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1483 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1485 psInfo
->ppshheader
.u4
.hbmWatermark
=
1486 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1489 /* Same behavior as for watermarks */
1490 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1491 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1493 psInfo
->ppshheader
.u5
.hbmHeader
=
1494 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1500 /******************************************************************************
1501 * PROPSHEET_ShowPage
1503 * Displays or creates the specified page.
1505 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1508 HWND hwndLineHeader
;
1510 LPCPROPSHEETPAGEW ppshpage
;
1512 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1513 if (index
== psInfo
->active_page
)
1515 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1516 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1520 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1521 if (psInfo
->proppage
[index
].hwndPage
== 0)
1523 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1526 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1528 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1529 psInfo
->proppage
[index
].pszText
);
1531 control
= GetNextDlgTabItem(psInfo
->proppage
[index
].hwndPage
, NULL
, FALSE
);
1536 if (psInfo
->active_page
!= -1)
1537 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1539 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1541 /* Synchronize current selection with tab control
1542 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1543 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1544 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1546 psInfo
->active_page
= index
;
1547 psInfo
->activeValid
= TRUE
;
1549 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1551 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1552 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1554 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1555 ShowWindow(hwndLineHeader
, SW_HIDE
);
1557 ShowWindow(hwndLineHeader
, SW_SHOW
);
1563 /******************************************************************************
1566 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1570 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1574 TRACE("active_page %d\n", psInfo
->active_page
);
1575 if (psInfo
->active_page
< 0)
1578 psn
.hdr
.code
= PSN_WIZBACK
;
1579 psn
.hdr
.hwndFrom
= hwndDlg
;
1583 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1585 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1588 else if (result
== 0)
1589 idx
= psInfo
->active_page
- 1;
1591 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1593 if (idx
>= 0 && idx
< psInfo
->nPages
)
1595 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1597 SetFocus(GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
));
1598 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
1599 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1605 /******************************************************************************
1608 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1612 LRESULT msgResult
= 0;
1613 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1616 TRACE("active_page %d\n", psInfo
->active_page
);
1617 if (psInfo
->active_page
< 0)
1620 psn
.hdr
.code
= PSN_WIZNEXT
;
1621 psn
.hdr
.hwndFrom
= hwndDlg
;
1625 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1627 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1628 if (msgResult
== -1)
1630 else if (msgResult
== 0)
1631 idx
= psInfo
->active_page
+ 1;
1633 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1635 if (idx
< psInfo
->nPages
)
1637 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1639 SetFocus(GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
));
1640 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
1641 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1648 /******************************************************************************
1651 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1655 LRESULT msgResult
= 0;
1656 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1658 TRACE("active_page %d\n", psInfo
->active_page
);
1659 if (psInfo
->active_page
< 0)
1662 psn
.hdr
.code
= PSN_WIZFINISH
;
1663 psn
.hdr
.hwndFrom
= hwndDlg
;
1667 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1669 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1671 TRACE("msg result %ld\n", msgResult
);
1676 if (psInfo
->result
== 0)
1677 psInfo
->result
= IDOK
;
1678 if (psInfo
->isModeless
)
1679 psInfo
->activeValid
= FALSE
;
1681 psInfo
->ended
= TRUE
;
1686 /******************************************************************************
1689 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1694 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1696 TRACE("active_page %d\n", psInfo
->active_page
);
1697 if (psInfo
->active_page
< 0)
1700 psn
.hdr
.hwndFrom
= hwndDlg
;
1706 * Send PSN_KILLACTIVE to the current page.
1708 psn
.hdr
.code
= PSN_KILLACTIVE
;
1710 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1712 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1716 * Send PSN_APPLY to all pages.
1718 psn
.hdr
.code
= PSN_APPLY
;
1719 psn
.lParam
= lParam
;
1721 for (i
= 0; i
< psInfo
->nPages
; i
++)
1723 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1726 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1728 case PSNRET_INVALID
:
1729 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1731 case PSNRET_INVALID_NOCHANGEPAGE
:
1739 psInfo
->activeValid
= FALSE
;
1741 else if(psInfo
->active_page
>= 0)
1743 psn
.hdr
.code
= PSN_SETACTIVE
;
1745 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1746 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1752 /******************************************************************************
1755 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1757 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1762 TRACE("active_page %d\n", psInfo
->active_page
);
1763 if (psInfo
->active_page
< 0)
1766 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1767 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1768 psn
.hdr
.hwndFrom
= hwndDlg
;
1772 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1775 psn
.hdr
.code
= PSN_RESET
;
1776 psn
.lParam
= lParam
;
1778 for (i
= 0; i
< psInfo
->nPages
; i
++)
1780 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1783 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1786 if (psInfo
->isModeless
)
1788 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1789 psInfo
->activeValid
= FALSE
;
1792 psInfo
->ended
= TRUE
;
1795 /******************************************************************************
1798 static void PROPSHEET_Help(HWND hwndDlg
)
1800 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1804 TRACE("active_page %d\n", psInfo
->active_page
);
1805 if (psInfo
->active_page
< 0)
1808 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1809 psn
.hdr
.code
= PSN_HELP
;
1810 psn
.hdr
.hwndFrom
= hwndDlg
;
1814 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1817 /******************************************************************************
1820 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1823 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1826 if (!psInfo
) return;
1828 * Set the dirty flag of this page.
1830 for (i
= 0; i
< psInfo
->nPages
; i
++)
1832 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1833 psInfo
->proppage
[i
].isDirty
= TRUE
;
1837 * Enable the Apply button.
1839 if (psInfo
->hasApply
)
1841 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1843 EnableWindow(hwndApplyBtn
, TRUE
);
1847 /******************************************************************************
1848 * PROPSHEET_UnChanged
1850 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1853 BOOL noPageDirty
= TRUE
;
1854 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1855 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1858 if ( !psInfo
) return;
1859 for (i
= 0; i
< psInfo
->nPages
; i
++)
1861 /* set the specified page as clean */
1862 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1863 psInfo
->proppage
[i
].isDirty
= FALSE
;
1865 /* look to see if there are any dirty pages */
1866 if (psInfo
->proppage
[i
].isDirty
)
1867 noPageDirty
= FALSE
;
1871 * Disable Apply button.
1874 EnableWindow(hwndApplyBtn
, FALSE
);
1877 /******************************************************************************
1878 * PROPSHEET_PressButton
1880 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1882 TRACE("buttonID %d\n", buttonID
);
1885 case PSBTN_APPLYNOW
:
1886 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1889 PROPSHEET_Back(hwndDlg
);
1892 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1895 PROPSHEET_Finish(hwndDlg
);
1898 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1901 PROPSHEET_Next(hwndDlg
);
1904 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1907 FIXME("Invalid button index %d\n", buttonID
);
1912 /*************************************************************************
1913 * BOOL PROPSHEET_CanSetCurSel [Internal]
1915 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1918 * hwndDlg [I] handle to a Dialog hWnd
1921 * TRUE if Current Selection can change
1925 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
1927 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1938 TRACE("active_page %d\n", psInfo
->active_page
);
1939 if (psInfo
->active_page
< 0)
1946 * Notify the current page.
1948 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1949 psn
.hdr
.code
= PSN_KILLACTIVE
;
1950 psn
.hdr
.hwndFrom
= hwndDlg
;
1954 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1957 TRACE("<-- %d\n", res
);
1961 /******************************************************************************
1962 * PROPSHEET_SetCurSel
1964 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
1967 HPROPSHEETPAGE hpage
1970 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1971 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
1972 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1974 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
1976 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
1978 if (index
< 0 || index
>= psInfo
->nPages
)
1980 TRACE("Could not find page to select!\n");
1984 /* unset active page while doing this transition. */
1985 if (psInfo
->active_page
!= -1)
1986 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1987 psInfo
->active_page
= -1;
1993 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1996 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
1998 psn
.hdr
.code
= PSN_SETACTIVE
;
1999 psn
.hdr
.hwndFrom
= hwndDlg
;
2003 if (!psInfo
->proppage
[index
].hwndPage
) {
2004 if(!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
)) {
2005 PROPSHEET_RemovePage(hwndDlg
, index
, NULL
);
2006 if(index
>= psInfo
->nPages
)
2014 /* Resize the property sheet page to the fit in the Tab control
2015 * (for regular property sheets) or to fit in the client area (for
2017 * NOTE: The resizing happens every time the page is selected and
2018 * not only when it's created (some applications depend on it). */
2019 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2020 TRACE("setting page %p, rc (%s) w=%d, h=%d\n",
2021 psInfo
->proppage
[index
].hwndPage
, wine_dbgstr_rect(&rc
),
2022 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2023 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2025 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2027 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2034 WARN("Tried to skip before first property sheet page!\n");
2037 if (index
>= psInfo
->nPages
) {
2038 WARN("Tried to skip after last property sheet page!\n");
2039 index
= psInfo
->nPages
-1;
2043 else if (result
!= 0)
2045 int old_index
= index
;
2046 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2047 if(index
>= psInfo
->nPages
) {
2049 WARN("Tried to skip to nonexistent page by res id\n");
2056 /* Invalidate the header area */
2057 if ( (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
2058 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
2060 HWND hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
2063 GetClientRect(hwndLineHeader
, &r
);
2064 MapWindowPoints(hwndLineHeader
, hwndDlg
, (LPPOINT
) &r
, 2);
2065 SetRect(&r
, 0, 0, r
.right
+ 1, r
.top
- 1);
2067 InvalidateRect(hwndDlg
, &r
, TRUE
);
2071 * Display the new page.
2073 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2075 if (psInfo
->proppage
[index
].hasHelp
)
2076 EnableWindow(hwndHelp
, TRUE
);
2078 EnableWindow(hwndHelp
, FALSE
);
2083 /******************************************************************************
2084 * PROPSHEET_SetCurSelId
2086 * Selects the page, specified by resource id.
2088 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2091 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2093 idx
= PROPSHEET_FindPageByResId(psInfo
, id
);
2094 if (idx
< psInfo
->nPages
)
2096 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
2097 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
2101 /******************************************************************************
2102 * PROPSHEET_SetTitleA
2104 static void PROPSHEET_SetTitleA(HWND hwndDlg
, DWORD dwStyle
, LPCSTR lpszText
)
2106 if(!IS_INTRESOURCE(lpszText
))
2109 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1,
2110 szTitle
, sizeof(szTitle
)/sizeof(WCHAR
));
2111 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2115 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2119 /******************************************************************************
2120 * PROPSHEET_SetTitleW
2122 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2124 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2127 TRACE("%s (style %08x)\n", debugstr_w(lpszText
), dwStyle
);
2128 if (IS_INTRESOURCE(lpszText
)) {
2129 if (!LoadStringW(psInfo
->ppshheader
.hInstance
,
2130 LOWORD(lpszText
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0])))
2134 if (dwStyle
& PSH_PROPTITLE
)
2137 int lentitle
= strlenW(lpszText
);
2138 int lenprop
= strlenW(psInfo
->strPropertiesFor
);
2140 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2141 wsprintfW(dest
, psInfo
->strPropertiesFor
, lpszText
);
2143 SetWindowTextW(hwndDlg
, dest
);
2147 SetWindowTextW(hwndDlg
, lpszText
);
2150 /******************************************************************************
2151 * PROPSHEET_SetFinishTextA
2153 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2155 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2156 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2158 TRACE("'%s'\n", lpszText
);
2159 /* Set text, show and enable the Finish button */
2160 SetWindowTextA(hwndButton
, lpszText
);
2161 ShowWindow(hwndButton
, SW_SHOW
);
2162 EnableWindow(hwndButton
, TRUE
);
2164 /* Make it default pushbutton */
2165 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2167 /* Hide Back button */
2168 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2169 ShowWindow(hwndButton
, SW_HIDE
);
2171 if (!psInfo
->hasFinish
)
2173 /* Hide Next button */
2174 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2175 ShowWindow(hwndButton
, SW_HIDE
);
2179 /******************************************************************************
2180 * PROPSHEET_SetFinishTextW
2182 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2184 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2185 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2187 TRACE("%s\n", debugstr_w(lpszText
));
2188 /* Set text, show and enable the Finish button */
2189 SetWindowTextW(hwndButton
, lpszText
);
2190 ShowWindow(hwndButton
, SW_SHOW
);
2191 EnableWindow(hwndButton
, TRUE
);
2193 /* Make it default pushbutton */
2194 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2196 /* Hide Back button */
2197 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2198 ShowWindow(hwndButton
, SW_HIDE
);
2200 if (!psInfo
->hasFinish
)
2202 /* Hide Next button */
2203 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2204 ShowWindow(hwndButton
, SW_HIDE
);
2208 /******************************************************************************
2209 * PROPSHEET_QuerySiblings
2211 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2212 WPARAM wParam
, LPARAM lParam
)
2216 LRESULT msgResult
= 0;
2217 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2219 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2221 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2222 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2230 /******************************************************************************
2233 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
,
2234 HPROPSHEETPAGE hpage
)
2236 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2237 TRACE("hpage %p\n", hpage
);
2238 return PROPSHEET_InsertPage(hwndDlg
, (HPROPSHEETPAGE
)(ULONG_PTR
)psInfo
->nPages
, hpage
);
2241 /******************************************************************************
2242 * PROPSHEET_RemovePage
2244 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2246 HPROPSHEETPAGE hpage
)
2248 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2249 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2250 PropPageInfo
* oldPages
;
2252 TRACE("index %d, hpage %p\n", index
, hpage
);
2257 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
2259 /* Make sure that index is within range */
2260 if (index
< 0 || index
>= psInfo
->nPages
)
2262 TRACE("Could not find page to remove!\n");
2266 TRACE("total pages %d removing page %d active page %d\n",
2267 psInfo
->nPages
, index
, psInfo
->active_page
);
2269 * Check if we're removing the active page.
2271 if (index
== psInfo
->active_page
)
2273 if (psInfo
->nPages
> 1)
2277 /* activate previous page */
2278 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2282 /* activate the next page */
2283 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2284 psInfo
->active_page
= index
;
2289 psInfo
->active_page
= -1;
2290 if (!psInfo
->isModeless
)
2292 psInfo
->ended
= TRUE
;
2297 else if (index
< psInfo
->active_page
)
2298 psInfo
->active_page
--;
2300 /* Unsubclass the page dialog window */
2301 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2302 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2303 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2305 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2306 PROPSHEET_WizardSubclassProc
, 1);
2309 /* Destroy page dialog window */
2310 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2312 /* Free page resources */
2313 if(psInfo
->proppage
[index
].hpage
)
2315 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2317 if (psp
->dwFlags
& PSP_USETITLE
)
2318 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2320 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2323 /* Remove the tab */
2324 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2326 oldPages
= psInfo
->proppage
;
2328 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2331 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2333 if (index
< psInfo
->nPages
)
2334 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2335 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2342 /******************************************************************************
2343 * PROPSHEET_SetWizButtons
2345 * This code will work if (and assumes that) the Next button is on top of the
2346 * Finish button. ie. Finish comes after Next in the Z order.
2347 * This means make sure the dialog template reflects this.
2350 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2352 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2353 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2354 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2355 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2356 BOOL enable_finish
= ((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
);
2359 HWND hwndCancel
= GetDlgItem(hwndDlg
, IDCANCEL
);
2364 TRACE("%d\n", dwFlags
);
2366 EnableWindow(hwndBack
, dwFlags
& PSWIZB_BACK
);
2367 EnableWindow(hwndNext
, dwFlags
& PSWIZB_NEXT
);
2368 EnableWindow(hwndFinish
, enable_finish
);
2371 /* set the default pushbutton to an enabled button */
2373 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2374 else if (dwFlags
& PSWIZB_NEXT
)
2375 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2376 else if (dwFlags
& PSWIZB_BACK
)
2377 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
2379 SendMessageW(hwndDlg
, DM_SETDEFID
, IDCANCEL
, 0);
2382 if (!psInfo
->hasFinish
)
2384 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2386 /* Hide the Next button */
2387 ShowWindow(hwndNext
, SW_HIDE
);
2389 /* Show the Finish button */
2390 ShowWindow(hwndFinish
, SW_SHOW
);
2394 /* Hide the Finish button */
2395 ShowWindow(hwndFinish
, SW_HIDE
);
2396 /* Show the Next button */
2397 ShowWindow(hwndNext
, SW_SHOW
);
2402 /* set the default pushbutton to an enabled button */
2403 if (((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
))
2404 iDefItem
= IDC_FINISH_BUTTON
;
2405 else if (dwFlags
& PSWIZB_NEXT
)
2406 iDefItem
= IDC_NEXT_BUTTON
;
2407 else if (dwFlags
& PSWIZB_BACK
)
2408 iDefItem
= IDC_BACK_BUTTON
;
2410 iDefItem
= IDCANCEL
;
2411 SendMessageW(hwndDlg
, DM_SETDEFID
, iDefItem
, 0);
2413 /* Set focus if no control has it */
2414 hwndFocus
= GetFocus();
2415 if (!hwndFocus
|| hwndFocus
== hwndCancel
)
2416 SetFocus(GetDlgItem(hwndDlg
, iDefItem
));
2421 /******************************************************************************
2422 * PROPSHEET_InsertPage
2424 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2426 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2427 PropPageInfo
* ppi
, * prev_ppi
= psInfo
->proppage
;
2428 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2429 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2433 TRACE("hwndDlg %p, hpageInsertAfter %p, hpage %p\n", hwndDlg
, hpageInsertAfter
, hpage
);
2435 if (IS_INTRESOURCE(hpageInsertAfter
))
2436 index
= LOWORD(hpageInsertAfter
);
2439 index
= PROPSHEET_GetPageIndex(hpageInsertAfter
, psInfo
, -1);
2442 TRACE("Could not find page to insert after!\n");
2448 if (index
> psInfo
->nPages
)
2449 index
= psInfo
->nPages
;
2452 * Allocate a new PropPageInfo entry.
2454 ppi
= Alloc(sizeof(PropPageInfo
) * (psInfo
->nPages
+ 1));
2459 * Fill in a new PropPageInfo entry.
2462 memcpy(ppi
, prev_ppi
, index
* sizeof(PropPageInfo
));
2463 memset(&ppi
[index
], 0, sizeof(PropPageInfo
));
2464 if (index
< psInfo
->nPages
)
2465 memcpy(&ppi
[index
+ 1], &prev_ppi
[index
], (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2466 psInfo
->proppage
= ppi
;
2468 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, index
, FALSE
))
2470 psInfo
->proppage
= prev_ppi
;
2475 psInfo
->proppage
[index
].hpage
= hpage
;
2477 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2479 /* Create the page but don't show it */
2480 if(!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppsp
))
2482 psInfo
->proppage
= prev_ppi
;
2490 if (index
<= psInfo
->active_page
)
2491 psInfo
->active_page
++;
2494 * Add a new tab to the tab control.
2496 item
.mask
= TCIF_TEXT
;
2497 item
.pszText
= (LPWSTR
) psInfo
->proppage
[index
].pszText
;
2498 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2500 if (psInfo
->hImageList
)
2502 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2505 if (psInfo
->proppage
[index
].hasIcon
)
2507 item
.mask
|= TCIF_IMAGE
;
2508 item
.iImage
= index
;
2511 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, index
,
2514 /* If it is the only page - show it */
2515 if (psInfo
->nPages
== 1)
2516 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2521 /******************************************************************************
2522 * PROPSHEET_SetHeaderTitleW
2524 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderTitle
)
2526 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderTitle
));
2529 /******************************************************************************
2530 * PROPSHEET_SetHeaderTitleA
2532 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderTitle
)
2534 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderTitle
));
2537 /******************************************************************************
2538 * PROPSHEET_SetHeaderSubTitleW
2540 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, int iPageIndex
, LPCWSTR pszHeaderSubTitle
)
2542 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_w(pszHeaderSubTitle
));
2545 /******************************************************************************
2546 * PROPSHEET_SetHeaderSubTitleA
2548 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, int iPageIndex
, LPCSTR pszHeaderSubTitle
)
2550 FIXME("(%p, %d, %s): stub\n", hwndDlg
, iPageIndex
, debugstr_a(pszHeaderSubTitle
));
2553 /******************************************************************************
2554 * PROPSHEET_HwndToIndex
2556 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2559 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2561 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2563 for (index
= 0; index
< psInfo
->nPages
; index
++)
2564 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2566 WARN("%p not found\n", hPageDlg
);
2570 /******************************************************************************
2571 * PROPSHEET_IndexToHwnd
2573 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2575 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2576 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2579 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2580 WARN("%d out of range.\n", iPageIndex
);
2583 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2586 /******************************************************************************
2587 * PROPSHEET_PageToIndex
2589 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2591 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2593 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2595 return PROPSHEET_GetPageIndex(hPage
, psInfo
, -1);
2598 /******************************************************************************
2599 * PROPSHEET_IndexToPage
2601 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2603 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2604 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2605 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2606 WARN("%d out of range.\n", iPageIndex
);
2609 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2612 /******************************************************************************
2613 * PROPSHEET_IdToIndex
2615 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2618 LPCPROPSHEETPAGEW psp
;
2619 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
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
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2636 LPCPROPSHEETPAGEW psp
;
2637 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2638 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2639 WARN("%d out of range.\n", iPageIndex
);
2642 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2643 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| !IS_INTRESOURCE(psp
->u
.pszTemplate
)) {
2646 return (LRESULT
)psp
->u
.pszTemplate
;
2649 /******************************************************************************
2650 * PROPSHEET_GetResult
2652 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2654 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2655 return psInfo
->result
;
2658 /******************************************************************************
2659 * PROPSHEET_RecalcPageSizes
2661 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2663 FIXME("(%p): stub\n", hwndDlg
);
2667 /******************************************************************************
2668 * PROPSHEET_GetPageIndex
2670 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2671 * the array of PropPageInfo. If page is not found original index is used
2672 * (page takes precedence over index).
2674 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE page
, const PropSheetInfo
* psInfo
, int original_index
)
2678 TRACE("page %p index %d\n", page
, original_index
);
2680 for (index
= 0; index
< psInfo
->nPages
; index
++)
2681 if (psInfo
->proppage
[index
].hpage
== page
)
2684 return original_index
;
2687 /******************************************************************************
2690 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2693 PropSheetInfo
* psInfo
= RemovePropW(hwndDlg
, PropSheetInfoStr
);
2696 if (!psInfo
) return;
2697 if (!IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
))
2698 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2700 for (i
= 0; i
< psInfo
->nPages
; i
++)
2702 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2704 /* Unsubclass the page dialog window */
2705 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2706 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2707 (psp
->dwFlags
& PSP_HIDEHEADER
))
2709 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2710 PROPSHEET_WizardSubclassProc
, 1);
2713 if(psInfo
->proppage
[i
].hwndPage
)
2714 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2718 if (psp
->dwFlags
& PSP_USETITLE
)
2719 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2721 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2725 DeleteObject(psInfo
->hFont
);
2726 DeleteObject(psInfo
->hFontBold
);
2727 /* If we created the bitmaps, destroy them */
2728 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2729 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2730 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2731 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2732 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2733 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2735 Free(psInfo
->proppage
);
2736 Free(psInfo
->strPropertiesFor
);
2737 ImageList_Destroy(psInfo
->hImageList
);
2742 static INT
do_loop(const PropSheetInfo
*psInfo
)
2746 HWND hwnd
= psInfo
->hwnd
;
2747 HWND parent
= psInfo
->ppshheader
.hwndParent
;
2749 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2754 if(!IsDialogMessageW(hwnd
, &msg
))
2756 TranslateMessage(&msg
);
2757 DispatchMessageW(&msg
);
2763 PostQuitMessage(msg
.wParam
);
2768 ret
= psInfo
->result
;
2771 EnableWindow(parent
, TRUE
);
2773 DestroyWindow(hwnd
);
2777 /******************************************************************************
2778 * PROPSHEET_PropertySheet
2780 * Common code between PropertySheetA/W
2782 static INT_PTR
PROPSHEET_PropertySheet(PropSheetInfo
* psInfo
, BOOL unicode
)
2786 if (psInfo
->active_page
>= psInfo
->nPages
) psInfo
->active_page
= 0;
2787 TRACE("startpage: %d of %d pages\n", psInfo
->active_page
, psInfo
->nPages
);
2789 psInfo
->unicode
= unicode
;
2790 psInfo
->ended
= FALSE
;
2792 if(!psInfo
->isModeless
)
2794 parent
= psInfo
->ppshheader
.hwndParent
;
2795 if (parent
) EnableWindow(parent
, FALSE
);
2797 bRet
= PROPSHEET_CreateDialog(psInfo
);
2798 if(!psInfo
->isModeless
)
2799 bRet
= do_loop(psInfo
);
2803 /******************************************************************************
2804 * PropertySheet (COMCTL32.@)
2805 * PropertySheetA (COMCTL32.@)
2807 * Creates a property sheet in the specified property sheet header.
2810 * Modal property sheets: Positive if successful or -1 otherwise.
2811 * Modeless property sheets: Property sheet handle.
2813 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2814 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2816 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2818 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2822 TRACE("(%p)\n", lppsh
);
2824 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2826 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2827 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2829 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2831 if (!psInfo
->usePropPage
)
2832 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2835 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2836 pByte
+= ((LPCPROPSHEETPAGEA
)pByte
)->dwSize
;
2839 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2842 if (psInfo
->usePropPage
)
2843 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2849 return PROPSHEET_PropertySheet(psInfo
, FALSE
);
2852 /******************************************************************************
2853 * PropertySheetW (COMCTL32.@)
2855 * See PropertySheetA.
2857 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2859 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2863 TRACE("(%p)\n", lppsh
);
2865 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2867 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2868 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2870 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2872 if (!psInfo
->usePropPage
)
2873 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2876 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2877 pByte
+= ((LPCPROPSHEETPAGEW
)pByte
)->dwSize
;
2880 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2883 if (psInfo
->usePropPage
)
2884 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2890 return PROPSHEET_PropertySheet(psInfo
, TRUE
);
2893 static LPWSTR
load_string( HINSTANCE instance
, LPCWSTR str
)
2897 if (IS_INTRESOURCE(str
))
2902 WORD i
, id
= LOWORD(str
);
2905 if (!(hrsrc
= FindResourceW( instance
, MAKEINTRESOURCEW((id
>> 4) + 1), (LPWSTR
)RT_STRING
)))
2907 if (!(hmem
= LoadResource( instance
, hrsrc
))) return NULL
;
2908 if (!(ptr
= LockResource( hmem
))) return NULL
;
2909 for (i
= id
& 0x0f; i
> 0; i
--) ptr
+= *ptr
+ 1;
2911 if (!len
) return NULL
;
2912 ret
= Alloc( (len
+ 1) * sizeof(WCHAR
) );
2915 memcpy( ret
, ptr
+ 1, len
* sizeof(WCHAR
) );
2921 int len
= (strlenW(str
) + 1) * sizeof(WCHAR
);
2923 if (ret
) memcpy( ret
, str
, len
);
2929 /******************************************************************************
2930 * CreatePropertySheetPage (COMCTL32.@)
2931 * CreatePropertySheetPageA (COMCTL32.@)
2933 * Creates a new property sheet page.
2936 * Success: Handle to new property sheet page.
2940 * An application must use the PSM_ADDPAGE message to add the new page to
2941 * an existing property sheet.
2943 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2944 LPCPROPSHEETPAGEA lpPropSheetPage
)
2946 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
2948 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEA
)));
2950 ppsp
->dwFlags
&= ~ PSP_INTERNAL_UNICODE
;
2952 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2954 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
2956 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
) + 1;
2957 char *template = Alloc( len
);
2959 ppsp
->u
.pszTemplate
= (LPWSTR
)strcpy( template, lpPropSheetPage
->u
.pszTemplate
);
2963 if (ppsp
->dwFlags
& PSP_USEICONID
)
2965 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
2966 PROPSHEET_AtoW(&ppsp
->u2
.pszIcon
, lpPropSheetPage
->u2
.pszIcon
);
2969 if (ppsp
->dwFlags
& PSP_USETITLE
)
2971 if (!IS_INTRESOURCE( ppsp
->pszTitle
))
2972 PROPSHEET_AtoW( &ppsp
->pszTitle
, lpPropSheetPage
->pszTitle
);
2974 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
2977 ppsp
->pszTitle
= NULL
;
2979 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
2980 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
2982 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
2984 if (!IS_INTRESOURCE( ppsp
->pszHeaderTitle
))
2985 PROPSHEET_AtoW(&ppsp
->pszHeaderTitle
, lpPropSheetPage
->pszHeaderTitle
);
2987 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
2990 ppsp
->pszHeaderTitle
= NULL
;
2992 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
2994 if (!IS_INTRESOURCE( ppsp
->pszHeaderSubTitle
))
2995 PROPSHEET_AtoW(&ppsp
->pszHeaderSubTitle
, lpPropSheetPage
->pszHeaderSubTitle
);
2997 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3000 ppsp
->pszHeaderSubTitle
= NULL
;
3002 return (HPROPSHEETPAGE
)ppsp
;
3005 /******************************************************************************
3006 * CreatePropertySheetPageW (COMCTL32.@)
3008 * See CreatePropertySheetA.
3010 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
3012 PROPSHEETPAGEW
* ppsp
= Alloc(sizeof(PROPSHEETPAGEW
));
3014 memcpy(ppsp
,lpPropSheetPage
,min(lpPropSheetPage
->dwSize
,sizeof(PROPSHEETPAGEW
)));
3016 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
3018 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
3020 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
3022 int len
= strlenW(lpPropSheetPage
->u
.pszTemplate
) + 1;
3023 WCHAR
*template = Alloc( len
* sizeof (WCHAR
) );
3025 ppsp
->u
.pszTemplate
= strcpyW( template, lpPropSheetPage
->u
.pszTemplate
);
3029 if ( ppsp
->dwFlags
& PSP_USEICONID
)
3031 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
3033 int len
= strlenW(lpPropSheetPage
->u2
.pszIcon
) + 1;
3034 WCHAR
*icon
= Alloc( len
* sizeof (WCHAR
) );
3036 ppsp
->u2
.pszIcon
= strcpyW( icon
, lpPropSheetPage
->u2
.pszIcon
);
3040 if (ppsp
->dwFlags
& PSP_USETITLE
)
3041 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3043 ppsp
->pszTitle
= NULL
;
3045 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3046 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3048 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3049 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3051 ppsp
->pszHeaderTitle
= NULL
;
3053 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3054 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3056 ppsp
->pszHeaderSubTitle
= NULL
;
3058 return (HPROPSHEETPAGE
)ppsp
;
3061 /******************************************************************************
3062 * DestroyPropertySheetPage (COMCTL32.@)
3064 * Destroys a property sheet page previously created with
3065 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
3072 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
3074 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3079 if (!(psp
->dwFlags
& PSP_DLGINDIRECT
) && !IS_INTRESOURCE( psp
->u
.pszTemplate
))
3080 Free ((LPVOID
)psp
->u
.pszTemplate
);
3082 if ((psp
->dwFlags
& PSP_USEICONID
) && !IS_INTRESOURCE( psp
->u2
.pszIcon
))
3083 Free ((LPVOID
)psp
->u2
.pszIcon
);
3085 if ((psp
->dwFlags
& PSP_USETITLE
) && !IS_INTRESOURCE( psp
->pszTitle
))
3086 Free ((LPVOID
)psp
->pszTitle
);
3088 if ((psp
->dwFlags
& PSP_USEHEADERTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderTitle
))
3089 Free ((LPVOID
)psp
->pszHeaderTitle
);
3091 if ((psp
->dwFlags
& PSP_USEHEADERSUBTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderSubTitle
))
3092 Free ((LPVOID
)psp
->pszHeaderSubTitle
);
3099 /******************************************************************************
3100 * PROPSHEET_IsDialogMessage
3102 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3104 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3107 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3110 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3113 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3115 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3117 switch (lpMsg
->wParam
)
3120 if (GetKeyState(VK_SHIFT
) & 0x8000)
3126 case VK_NEXT
: new_page
= 1; break;
3127 case VK_PRIOR
: new_page
= -1; break;
3133 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3135 new_page
+= psInfo
->active_page
;
3138 new_page
= psInfo
->nPages
- 1;
3139 else if (new_page
>= psInfo
->nPages
)
3142 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3149 return IsDialogMessageW(hwnd
, lpMsg
);
3152 /******************************************************************************
3153 * PROPSHEET_DoCommand
3155 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3161 case IDC_APPLY_BUTTON
:
3163 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3165 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3170 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3172 /* don't overwrite ID_PSRESTARTWINDOWS or ID_PSREBOOTSYSTEM */
3173 if (psInfo
->result
== 0)
3174 psInfo
->result
= IDOK
;
3176 if (psInfo
->isModeless
)
3177 psInfo
->activeValid
= FALSE
;
3179 psInfo
->ended
= TRUE
;
3182 EnableWindow(hwndApplyBtn
, FALSE
);
3187 case IDC_BACK_BUTTON
:
3188 PROPSHEET_Back(hwnd
);
3191 case IDC_NEXT_BUTTON
:
3192 PROPSHEET_Next(hwnd
);
3195 case IDC_FINISH_BUTTON
:
3196 PROPSHEET_Finish(hwnd
);
3200 PROPSHEET_Cancel(hwnd
, 0);
3204 PROPSHEET_Help(hwnd
);
3214 /******************************************************************************
3217 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3219 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3224 HPALETTE hOldPal
= 0;
3228 LPCPROPSHEETPAGEW ppshpage
;
3229 WCHAR szBuffer
[256];
3232 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3235 hdcSrc
= CreateCompatibleDC(0);
3237 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3238 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3240 if (psInfo
->active_page
< 0)
3243 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3245 if ( (ppshpage
&& !(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
), &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));
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 (!IS_INTRESOURCE(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 (!IS_INTRESOURCE(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
&& (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);
3360 SetRect(&rzone
, 0, 0, r
.right
, r
.top
- 1);
3362 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3363 FillRect(hdc
, &rzone
, hbr
);
3365 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), &bm
);
3366 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3368 /* The watermark is truncated to a width of 164 pixels */
3369 r
.right
= min(r
.right
, 164);
3370 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3371 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3373 /* If the bitmap is not big enough, fill the remaining area
3374 with the color of pixel (0,0) of bitmap - see MSDN */
3375 if (r
.top
> bm
.bmHeight
) {
3376 r
.bottom
= r
.top
- 1;
3377 r
.top
= bm
.bmHeight
;
3379 r
.right
= bm
.bmWidth
;
3380 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3381 FillRect(hdc
, &r
, hbr
);
3385 SelectObject(hdcSrc
, hbmp
);
3388 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3389 SelectPalette(hdc
, hOldPal
, FALSE
);
3393 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3398 /******************************************************************************
3399 * PROPSHEET_DialogProc
3401 static INT_PTR CALLBACK
3402 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3404 TRACE("hwnd=%p msg=0x%04x wparam=%lx lparam=%lx\n",
3405 hwnd
, uMsg
, wParam
, lParam
);
3411 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3412 WCHAR
* strCaption
= Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3413 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3417 /* Using PropSheetInfoStr to store extra data doesn't match the native
3418 * common control: native uses TCM_[GS]ETITEM
3420 SetPropW(hwnd
, PropSheetInfoStr
, psInfo
);
3423 * psInfo->hwnd is not being used by WINE code - it exists
3424 * for compatibility with "real" Windoze. The same about
3425 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3428 psInfo
->hwnd
= hwnd
;
3429 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3431 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3433 /* set up the Next and Back buttons by default */
3434 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3438 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3439 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3440 logFont
.lfWeight
= FW_BOLD
;
3441 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3444 * Small icon in the title bar.
3446 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3447 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3450 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3451 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3453 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3454 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3455 psInfo
->ppshheader
.u
.pszIcon
,
3460 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3462 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3465 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3466 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3468 psInfo
->strPropertiesFor
= strCaption
;
3470 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3472 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3474 PROPSHEET_LoadWizardBitmaps(psInfo
);
3476 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3478 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3479 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3480 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3481 SetFocus(GetDlgItem(hwnd
, IDC_NEXT_BUTTON
));
3485 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3487 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3488 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3490 SetFocus(GetDlgItem(hwnd
, IDOK
));
3493 if (IS_INTRESOURCE(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
, PSCB_INITIALIZED
, 0);
3512 idx
= psInfo
->active_page
;
3513 psInfo
->active_page
= -1;
3515 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3517 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3518 * as some programs call TCM_GETCURSEL to get the current selection
3519 * from which to switch to the next page */
3520 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3522 PROPSHEET_UnChanged(hwnd
, NULL
);
3524 /* wizards set their focus during init */
3525 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3531 case WM_PRINTCLIENT
:
3533 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3537 PROPSHEET_CleanUp(hwnd
);
3541 PROPSHEET_Cancel(hwnd
, 1);
3542 return FALSE
; /* let DefDlgProc post us WM_COMMAND/IDCANCEL */
3545 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3547 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3552 /* No default handler, forward notification to active page */
3553 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3555 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3556 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3563 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3565 if (pnmh
->code
== TCN_SELCHANGE
)
3567 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3568 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3571 if(pnmh
->code
== TCN_SELCHANGING
)
3573 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3574 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3581 case WM_SYSCOLORCHANGE
:
3582 COMCTL32_RefreshSysColors();
3585 case PSM_GETCURRENTPAGEHWND
:
3587 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3593 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3594 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3596 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3602 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3606 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3609 case PSM_GETTABCONTROL
:
3611 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3613 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3622 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3623 if(msgResult
!= FALSE
)
3625 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3628 (HPROPSHEETPAGE
)lParam
);
3631 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3636 case PSM_CANCELTOCLOSE
:
3638 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3639 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3640 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3642 EnableWindow(hwndCancel
, FALSE
);
3643 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, sizeof(buf
)/sizeof(buf
[0])))
3644 SetWindowTextW(hwndOK
, buf
);
3649 case PSM_RESTARTWINDOWS
:
3651 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3656 /* reboot system takes precedence over restart windows */
3657 if (psInfo
->result
!= ID_PSREBOOTSYSTEM
)
3658 psInfo
->result
= ID_PSRESTARTWINDOWS
;
3663 case PSM_REBOOTSYSTEM
:
3665 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3670 psInfo
->result
= ID_PSREBOOTSYSTEM
;
3676 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3680 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3685 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3687 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3692 case PSM_QUERYSIBLINGS
:
3694 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3696 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3704 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3705 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3706 * on success or FALSE otherwise, as specified on MSDN Online.
3707 * Also see the MFC code for
3708 * CPropertySheet::AddPage(CPropertyPage* pPage).
3711 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3713 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3718 case PSM_REMOVEPAGE
:
3719 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3722 case PSM_ISDIALOGMESSAGE
:
3724 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3725 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3729 case PSM_PRESSBUTTON
:
3730 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3733 case PSM_SETFINISHTEXTA
:
3734 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3737 case PSM_SETWIZBUTTONS
:
3738 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3741 case PSM_SETCURSELID
:
3742 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3745 case PSM_SETFINISHTEXTW
:
3746 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3749 case PSM_INSERTPAGE
:
3751 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3752 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3756 case PSM_SETHEADERTITLEW
:
3757 PROPSHEET_SetHeaderTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3760 case PSM_SETHEADERTITLEA
:
3761 PROPSHEET_SetHeaderTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3764 case PSM_SETHEADERSUBTITLEW
:
3765 PROPSHEET_SetHeaderSubTitleW(hwnd
, (int)wParam
, (LPCWSTR
)lParam
);
3768 case PSM_SETHEADERSUBTITLEA
:
3769 PROPSHEET_SetHeaderSubTitleA(hwnd
, (int)wParam
, (LPCSTR
)lParam
);
3772 case PSM_HWNDTOINDEX
:
3774 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3775 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3779 case PSM_INDEXTOHWND
:
3781 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3782 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3786 case PSM_PAGETOINDEX
:
3788 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3789 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3793 case PSM_INDEXTOPAGE
:
3795 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3796 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3802 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3803 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3809 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3810 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3816 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3817 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3821 case PSM_RECALCPAGESIZES
:
3823 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3824 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);