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
35 * o PSM_RECALCPAGESIZES
40 * o PSN_QUERYINITIALFOCUS
41 * o PSN_TRANSLATEACCELERATOR
44 * o PSH_STRETCHWATERMARK
48 * o PSP_USEFUSIONCONTEXT
55 #define NONAMELESSUNION
67 #include "wine/debug.h"
69 /******************************************************************************
93 } MyDLGITEMTEMPLATEEX
;
96 typedef struct tagPropPageInfo
98 HPROPSHEETPAGE hpage
; /* to keep track of pages not passed to PropertySheet */
107 typedef struct tagPropSheetInfo
110 PROPSHEETHEADERW ppshheader
;
112 LPWSTR strPropertiesFor
;
122 PropPageInfo
* proppage
;
127 HIMAGELIST hImageList
;
138 /******************************************************************************
139 * Defines and global variables
142 static const WCHAR PropSheetInfoStr
[] = L
"PropertySheetInfo";
144 #define PSP_INTERNAL_UNICODE 0x80000000
146 #define MAX_CAPTION_LENGTH 255
147 #define MAX_TABTEXT_LENGTH 255
148 #define MAX_BUTTONTEXT_LENGTH 64
150 #define INTRNL_ANY_WIZARD (PSH_WIZARD | PSH_WIZARD97_OLD | PSH_WIZARD97_NEW | PSH_WIZARD_LITE)
152 /* Wizard metrics specified in DLUs */
153 #define WIZARD_PADDING 7
154 #define WIZARD_HEADER_HEIGHT 36
156 /******************************************************************************
159 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
);
160 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
);
161 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
);
162 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
165 HPROPSHEETPAGE hpage
);
166 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage
, const PropSheetInfo
* psInfo
, int original_index
);
167 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
);
168 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
);
169 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
, int index
, HPROPSHEETPAGE hpage
);
171 static INT_PTR CALLBACK
172 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
174 WINE_DEFAULT_DEBUG_CHANNEL(propsheet
);
176 static WCHAR
*heap_strdupW(const WCHAR
*str
)
178 int len
= lstrlenW(str
) + 1;
179 WCHAR
*ret
= Alloc(len
* sizeof(WCHAR
));
184 static WCHAR
*heap_strdupAtoW(const char *str
)
189 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, 0, 0);
190 ret
= Alloc(len
* sizeof(WCHAR
));
191 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
196 #define add_flag(a) if (dwFlags & a) {strcat(string, #a );strcat(string," ");}
197 /******************************************************************************
198 * PROPSHEET_UnImplementedFlags
200 * Document use of flags we don't implement yet.
202 static VOID
PROPSHEET_UnImplementedFlags(DWORD dwFlags
)
209 * unhandled header flags:
210 * PSH_RTLREADING 0x00000800
211 * PSH_STRETCHWATERMARK 0x00040000
212 * PSH_USEPAGELANG 0x00200000
215 add_flag(PSH_RTLREADING
);
216 add_flag(PSH_STRETCHWATERMARK
);
217 add_flag(PSH_USEPAGELANG
);
218 if (string
[0] != '\0')
219 FIXME("%s\n", string
);
223 /******************************************************************************
224 * PROPSHEET_GetPageRect
226 * Retrieve rect from tab control and map into the dialog for SetWindowPos
228 static void PROPSHEET_GetPageRect(const PropSheetInfo
* psInfo
, HWND hwndDlg
,
229 RECT
*rc
, LPCPROPSHEETPAGEW ppshpage
)
231 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) {
235 if (((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
236 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
237 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) ||
238 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
))
240 rc
->left
= rc
->top
= WIZARD_PADDING
;
244 rc
->left
= rc
->top
= 0;
246 rc
->right
= psInfo
->width
- rc
->left
;
247 rc
->bottom
= psInfo
->height
- rc
->top
;
248 MapDialogRect(hwndDlg
, rc
);
250 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
251 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
252 !(ppshpage
->dwFlags
& PSP_HIDEHEADER
))
254 hwndChild
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
255 GetClientRect(hwndChild
, &r
);
256 MapWindowPoints(hwndChild
, hwndDlg
, (LPPOINT
) &r
, 2);
257 rc
->top
+= r
.bottom
+ 1;
260 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
261 GetClientRect(hwndTabCtrl
, rc
);
262 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)rc
);
263 MapWindowPoints(hwndTabCtrl
, hwndDlg
, (LPPOINT
)rc
, 2);
267 /******************************************************************************
268 * PROPSHEET_FindPageByResId
270 * Find page index corresponding to page resource id.
272 static INT
PROPSHEET_FindPageByResId(const PropSheetInfo
* psInfo
, LRESULT resId
)
276 for (i
= 0; i
< psInfo
->nPages
; i
++)
278 LPCPROPSHEETPAGEA lppsp
= (LPCPROPSHEETPAGEA
)psInfo
->proppage
[i
].hpage
;
280 /* Fixme: if resource ID is a string shall we use strcmp ??? */
281 if (lppsp
->u
.pszTemplate
== (LPVOID
)resId
)
288 /******************************************************************************
289 * PROPSHEET_CollectSheetInfoCommon
291 * Common code for PROPSHEET_CollectSheetInfoA/W
293 static void PROPSHEET_CollectSheetInfoCommon(PropSheetInfo
* psInfo
, DWORD dwFlags
)
295 PROPSHEET_UnImplementedFlags(dwFlags
);
297 psInfo
->hasHelp
= dwFlags
& PSH_HASHELP
;
298 psInfo
->hasApply
= !(dwFlags
& PSH_NOAPPLYNOW
);
299 psInfo
->hasFinish
= dwFlags
& PSH_WIZARDHASFINISH
;
300 psInfo
->isModeless
= dwFlags
& PSH_MODELESS
;
301 psInfo
->usePropPage
= dwFlags
& PSH_PROPSHEETPAGE
;
302 if (psInfo
->active_page
< 0 || psInfo
->active_page
>= psInfo
->nPages
)
303 psInfo
->active_page
= 0;
306 psInfo
->hImageList
= 0;
307 psInfo
->activeValid
= FALSE
;
310 /******************************************************************************
311 * PROPSHEET_CollectSheetInfoA
313 * Collect relevant data.
315 static void PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh
,
316 PropSheetInfo
* psInfo
)
318 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERA
));
319 DWORD dwFlags
= lppsh
->dwFlags
;
321 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
)&& (lppsh
->pfnCallback
);
323 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
324 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",
325 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
,
326 debugstr_a(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
328 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
329 psInfo
->ppshheader
.pszCaption
= NULL
;
332 if (!IS_INTRESOURCE(lppsh
->pszCaption
))
334 int len
= MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, NULL
, 0);
335 WCHAR
*caption
= Alloc( len
*sizeof (WCHAR
) );
337 MultiByteToWideChar(CP_ACP
, 0, lppsh
->pszCaption
, -1, caption
, len
);
338 psInfo
->ppshheader
.pszCaption
= caption
;
341 psInfo
->nPages
= lppsh
->nPages
;
343 if (dwFlags
& PSH_USEPSTARTPAGE
)
345 TRACE("PSH_USEPSTARTPAGE is on\n");
346 psInfo
->active_page
= 0;
349 psInfo
->active_page
= lppsh
->u2
.nStartPage
;
351 PROPSHEET_CollectSheetInfoCommon(psInfo
, dwFlags
);
354 /******************************************************************************
355 * PROPSHEET_CollectSheetInfoW
357 * Collect relevant data.
359 static void PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh
,
360 PropSheetInfo
* psInfo
)
362 DWORD dwSize
= min(lppsh
->dwSize
,sizeof(PROPSHEETHEADERW
));
363 DWORD dwFlags
= lppsh
->dwFlags
;
365 psInfo
->useCallback
= (dwFlags
& PSH_USECALLBACK
) && (lppsh
->pfnCallback
);
367 memcpy(&psInfo
->ppshheader
,lppsh
,dwSize
);
368 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",
369 lppsh
->dwSize
, lppsh
->dwFlags
, lppsh
->hwndParent
, lppsh
->hInstance
, debugstr_w(lppsh
->pszCaption
), lppsh
->nPages
, lppsh
->pfnCallback
);
371 if (lppsh
->dwFlags
& INTRNL_ANY_WIZARD
)
372 psInfo
->ppshheader
.pszCaption
= NULL
;
375 if (!IS_INTRESOURCE(lppsh
->pszCaption
))
376 psInfo
->ppshheader
.pszCaption
= heap_strdupW( 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 PROPSHEET_CollectSheetInfoCommon(psInfo
, dwFlags
);
391 /******************************************************************************
392 * PROPSHEET_CollectPageInfo
394 * Collect property sheet data.
395 * With code taken from DIALOG_ParseTemplate32.
397 static BOOL
PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEW lppsp
,
398 PropSheetInfo
* psInfo
,
399 int index
, BOOL resize
)
401 const DLGTEMPLATE
* pTemplate
;
410 psInfo
->proppage
[index
].hpage
= (HPROPSHEETPAGE
)lppsp
;
411 psInfo
->proppage
[index
].hwndPage
= 0;
412 psInfo
->proppage
[index
].isDirty
= FALSE
;
415 * Process property page flags.
417 dwFlags
= lppsp
->dwFlags
;
418 psInfo
->proppage
[index
].useCallback
= (dwFlags
& PSP_USECALLBACK
) && (lppsp
->pfnCallback
);
419 psInfo
->proppage
[index
].hasHelp
= dwFlags
& PSP_HASHELP
;
420 psInfo
->proppage
[index
].hasIcon
= dwFlags
& (PSP_USEHICON
| PSP_USEICONID
);
422 /* as soon as we have a page with the help flag, set the sheet flag on */
423 if (psInfo
->proppage
[index
].hasHelp
)
424 psInfo
->hasHelp
= TRUE
;
427 * Process page template.
429 if (dwFlags
& PSP_DLGINDIRECT
)
430 pTemplate
= lppsp
->u
.pResource
;
431 else if(dwFlags
& PSP_INTERNAL_UNICODE
)
433 HRSRC hResource
= FindResourceW(lppsp
->hInstance
,
434 lppsp
->u
.pszTemplate
,
436 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
438 pTemplate
= LockResource(hTemplate
);
442 HRSRC hResource
= FindResourceA(lppsp
->hInstance
,
443 (LPCSTR
)lppsp
->u
.pszTemplate
,
445 HGLOBAL hTemplate
= LoadResource(lppsp
->hInstance
,
447 pTemplate
= LockResource(hTemplate
);
451 * Extract the size of the page and the caption.
456 p
= (const WORD
*)pTemplate
;
458 if (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF)
460 /* DLGTEMPLATEEX (not defined in any std. header file) */
464 p
+= 2; /* help ID */
465 p
+= 2; /* ext style */
473 p
+= 2; /* ext style */
479 width
= (WORD
)*p
; p
++;
480 height
= (WORD
)*p
; p
++;
482 if (lppsp
->dwFlags
& (PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
))
483 psInfo
->ppshheader
.dwFlags
|= PSH_HEADER
;
485 /* Special calculation for interior wizard pages so the largest page is
486 * calculated correctly. We need to add all the padding and space occupied
487 * by the header so the width and height sums up to the whole wizard client
489 if ((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
490 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
491 !(dwFlags
& PSP_HIDEHEADER
))
493 height
+= 2 * WIZARD_PADDING
+ WIZARD_HEADER_HEIGHT
;
494 width
+= 2 * WIZARD_PADDING
;
496 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD
)
498 height
+= 2 * WIZARD_PADDING
;
499 width
+= 2 * WIZARD_PADDING
;
502 /* remember the largest width and height */
505 if (width
> psInfo
->width
)
506 psInfo
->width
= width
;
508 if (height
> psInfo
->height
)
509 psInfo
->height
= height
;
522 p
+= lstrlenW( p
) + 1;
536 p
+= lstrlenW( p
) + 1;
540 /* Extract the caption */
541 psInfo
->proppage
[index
].pszText
= p
;
542 TRACE("Tab %d %s\n",index
,debugstr_w( p
));
544 if (dwFlags
& PSP_USETITLE
)
549 if (IS_INTRESOURCE( lppsp
->pszTitle
))
551 if (LoadStringW( lppsp
->hInstance
, (DWORD_PTR
)lppsp
->pszTitle
, szTitle
, ARRAY_SIZE(szTitle
)))
559 pTitle
= lppsp
->pszTitle
;
561 psInfo
->proppage
[index
].pszText
= heap_strdupW( pTitle
);
565 * Build the image list for icons
567 if ((dwFlags
& PSP_USEHICON
) || (dwFlags
& PSP_USEICONID
))
570 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
571 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
573 if (dwFlags
& PSP_USEICONID
)
574 hIcon
= LoadImageW(lppsp
->hInstance
, lppsp
->u2
.pszIcon
, IMAGE_ICON
,
575 icon_cx
, icon_cy
, LR_DEFAULTCOLOR
);
577 hIcon
= lppsp
->u2
.hIcon
;
581 if (psInfo
->hImageList
== 0 )
582 psInfo
->hImageList
= ImageList_Create(icon_cx
, icon_cy
, ILC_COLOR
, 1, 1);
584 ImageList_AddIcon(psInfo
->hImageList
, hIcon
);
592 /******************************************************************************
593 * PROPSHEET_CreateDialog
595 * Creates the actual property sheet.
597 static INT_PTR
PROPSHEET_CreateDialog(PropSheetInfo
* psInfo
)
604 WORD resID
= IDD_PROPSHEET
;
606 TRACE("(%p)\n", psInfo
);
607 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
610 if( psInfo
->unicode
)
612 if(!(hRes
= FindResourceW(COMCTL32_hModule
,
613 MAKEINTRESOURCEW(resID
),
619 if(!(hRes
= FindResourceA(COMCTL32_hModule
,
620 MAKEINTRESOURCEA(resID
),
625 if(!(template = LoadResource(COMCTL32_hModule
, hRes
)))
629 * Make a copy of the dialog template.
631 resSize
= SizeofResource(COMCTL32_hModule
, hRes
);
633 temp
= Alloc(2 * resSize
);
638 memcpy(temp
, template, resSize
);
640 if (psInfo
->ppshheader
.dwFlags
& PSH_NOCONTEXTHELP
)
642 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
643 ((MyDLGTEMPLATEEX
*)temp
)->style
&= ~DS_CONTEXTHELP
;
645 ((DLGTEMPLATE
*)temp
)->style
&= ~DS_CONTEXTHELP
;
647 if ((psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
) &&
648 (psInfo
->ppshheader
.dwFlags
& PSH_WIZARDCONTEXTHELP
))
650 if (((MyDLGTEMPLATEEX
*)temp
)->signature
== 0xFFFF)
651 ((MyDLGTEMPLATEEX
*)temp
)->style
|= DS_CONTEXTHELP
;
653 ((DLGTEMPLATE
*)temp
)->style
|= DS_CONTEXTHELP
;
656 if (psInfo
->useCallback
)
657 (*(psInfo
->ppshheader
.pfnCallback
))(0, PSCB_PRECREATE
, (LPARAM
)temp
);
659 /* NOTE: MSDN states "Returns a positive value if successful, or -1
660 * otherwise for modal property sheets.", but this is wrong. The
661 * actual return value is either TRUE (success), FALSE (cancel) or
663 if( psInfo
->unicode
)
665 ret
= (INT_PTR
)CreateDialogIndirectParamW(psInfo
->ppshheader
.hInstance
,
666 temp
, psInfo
->ppshheader
.hwndParent
,
667 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
668 if ( !ret
) ret
= -1;
672 ret
= (INT_PTR
)CreateDialogIndirectParamA(psInfo
->ppshheader
.hInstance
,
673 temp
, psInfo
->ppshheader
.hwndParent
,
674 PROPSHEET_DialogProc
, (LPARAM
)psInfo
);
675 if ( !ret
) ret
= -1;
683 /******************************************************************************
684 * PROPSHEET_SizeMismatch
686 * Verify that the tab control and the "largest" property sheet page dlg. template
689 static BOOL
PROPSHEET_SizeMismatch(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
691 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
692 RECT rcOrigTab
, rcPage
;
697 GetClientRect(hwndTabCtrl
, &rcOrigTab
);
698 TRACE("orig tab %s\n", wine_dbgstr_rect(&rcOrigTab
));
703 SetRect(&rcPage
, 0, 0, psInfo
->width
, psInfo
->height
);
704 MapDialogRect(hwndDlg
, &rcPage
);
705 TRACE("biggest page %s\n", wine_dbgstr_rect(&rcPage
));
707 if ( (rcPage
.right
- rcPage
.left
) != (rcOrigTab
.right
- rcOrigTab
.left
) )
709 if ( (rcPage
.bottom
- rcPage
.top
) != (rcOrigTab
.bottom
- rcOrigTab
.top
) )
715 /******************************************************************************
716 * PROPSHEET_AdjustSize
718 * Resizes the property sheet and the tab control to fit the largest page.
720 static BOOL
PROPSHEET_AdjustSize(HWND hwndDlg
, PropSheetInfo
* psInfo
)
722 HWND hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
723 HWND hwndButton
= GetDlgItem(hwndDlg
, IDOK
);
726 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndDlg
);
730 /* Get the height of buttons */
731 GetClientRect(hwndButton
, &rc
);
732 buttonHeight
= rc
.bottom
;
737 SetRect(&rc
, 0, 0, psInfo
->width
, psInfo
->height
);
738 MapDialogRect(hwndDlg
, &rc
);
740 /* retrieve the dialog units */
741 units
.left
= units
.right
= 4;
742 units
.top
= units
.bottom
= 8;
743 MapDialogRect(hwndDlg
, &units
);
746 * Resize the tab control.
748 GetClientRect(hwndTabCtrl
,&tabRect
);
750 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, FALSE
, (LPARAM
)&tabRect
);
752 if ((rc
.bottom
- rc
.top
) < (tabRect
.bottom
- tabRect
.top
))
754 rc
.bottom
= rc
.top
+ tabRect
.bottom
- tabRect
.top
;
755 psInfo
->height
= MulDiv((rc
.bottom
- rc
.top
),8,units
.top
);
758 if ((rc
.right
- rc
.left
) < (tabRect
.right
- tabRect
.left
))
760 rc
.right
= rc
.left
+ tabRect
.right
- tabRect
.left
;
761 psInfo
->width
= MulDiv((rc
.right
- rc
.left
),4,units
.left
);
764 SendMessageW(hwndTabCtrl
, TCM_ADJUSTRECT
, TRUE
, (LPARAM
)&rc
);
768 TRACE("setting tab %p, rc (0,0)-(%d,%d)\n",
769 hwndTabCtrl
, rc
.right
, rc
.bottom
);
770 SetWindowPos(hwndTabCtrl
, 0, 0, 0, rc
.right
, rc
.bottom
,
771 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
773 GetClientRect(hwndTabCtrl
, &rc
);
775 TRACE("tab client rc %s\n", wine_dbgstr_rect(&rc
));
777 rc
.right
+= (padding
.x
* 2);
778 rc
.bottom
+= buttonHeight
+ (3 * padding
.y
);
780 style
= GetWindowLongW(hwndDlg
, GWL_STYLE
);
781 if (!(style
& WS_CHILD
))
782 AdjustWindowRect(&rc
, style
, FALSE
);
788 * Resize the property sheet.
790 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
791 hwndDlg
, rc
.right
, rc
.bottom
);
792 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
, rc
.bottom
,
793 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
797 /******************************************************************************
798 * PROPSHEET_AdjustSizeWizard
800 * Resizes the property sheet to fit the largest page.
802 static BOOL
PROPSHEET_AdjustSizeWizard(HWND hwndDlg
, const PropSheetInfo
* psInfo
)
804 HWND hwndLine
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
805 RECT rc
, lineRect
, dialogRect
;
807 /* Biggest page size */
808 SetRect(&rc
, 0, 0, psInfo
->width
, psInfo
->height
);
809 MapDialogRect(hwndDlg
, &rc
);
811 TRACE("Biggest page %s\n", wine_dbgstr_rect(&rc
));
813 /* Add space for the buttons row */
814 GetWindowRect(hwndLine
, &lineRect
);
815 MapWindowPoints(NULL
, hwndDlg
, (LPPOINT
)&lineRect
, 2);
816 GetClientRect(hwndDlg
, &dialogRect
);
817 rc
.bottom
+= dialogRect
.bottom
- lineRect
.top
- 1;
819 /* Convert the client coordinates to window coordinates */
820 AdjustWindowRect(&rc
, GetWindowLongW(hwndDlg
, GWL_STYLE
), FALSE
);
822 /* Resize the property sheet */
823 TRACE("setting dialog %p, rc (0,0)-(%d,%d)\n",
824 hwndDlg
, rc
.right
, rc
.bottom
);
825 SetWindowPos(hwndDlg
, 0, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
826 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
831 /******************************************************************************
832 * PROPSHEET_AdjustButtons
834 * Adjusts the buttons' positions.
836 static BOOL
PROPSHEET_AdjustButtons(HWND hwndParent
, const PropSheetInfo
* psInfo
)
838 HWND hwndButton
= GetDlgItem(hwndParent
, IDOK
);
842 int buttonWidth
, buttonHeight
;
843 PADDING_INFO padding
= PROPSHEET_GetPaddingInfo(hwndParent
);
845 if (psInfo
->hasApply
)
852 * Obtain the size of the buttons.
854 GetClientRect(hwndButton
, &rcSheet
);
855 buttonWidth
= rcSheet
.right
;
856 buttonHeight
= rcSheet
.bottom
;
859 * Get the size of the property sheet.
861 GetClientRect(hwndParent
, &rcSheet
);
864 * All buttons will be at this y coordinate.
866 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
869 * Position OK button and make it default.
871 hwndButton
= GetDlgItem(hwndParent
, IDOK
);
873 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * num_buttons
);
875 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
876 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
878 SendMessageW(hwndParent
, DM_SETDEFID
, IDOK
, 0);
882 * Position Cancel button.
884 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
886 x
+= padding
.x
+ buttonWidth
;
888 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
889 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
892 * Position Apply button.
894 hwndButton
= GetDlgItem(hwndParent
, IDC_APPLY_BUTTON
);
897 x
+= padding
.x
+ buttonWidth
;
899 ShowWindow(hwndButton
, SW_HIDE
);
901 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
902 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
903 EnableWindow(hwndButton
, FALSE
);
906 * Position Help button.
908 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
910 x
+= padding
.x
+ buttonWidth
;
911 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
912 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
915 ShowWindow(hwndButton
, SW_HIDE
);
920 /******************************************************************************
921 * PROPSHEET_AdjustButtonsWizard
923 * Adjusts the buttons' positions.
925 static BOOL
PROPSHEET_AdjustButtonsWizard(HWND hwndParent
,
926 const PropSheetInfo
* psInfo
)
928 HWND hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
929 HWND hwndLine
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINE
);
930 HWND hwndLineHeader
= GetDlgItem(hwndParent
, IDC_SUNKEN_LINEHEADER
);
934 int buttonWidth
, buttonHeight
, lineHeight
, lineWidth
;
935 PADDING_INFO padding
= PROPSHEET_GetPaddingInfoWizard(hwndParent
, psInfo
);
939 if (psInfo
->hasFinish
)
943 * Obtain the size of the buttons.
945 GetClientRect(hwndButton
, &rcSheet
);
946 buttonWidth
= rcSheet
.right
;
947 buttonHeight
= rcSheet
.bottom
;
949 GetClientRect(hwndLine
, &rcSheet
);
950 lineHeight
= rcSheet
.bottom
;
953 * Get the size of the property sheet.
955 GetClientRect(hwndParent
, &rcSheet
);
958 * All buttons will be at this y coordinate.
960 y
= rcSheet
.bottom
- (padding
.y
+ buttonHeight
);
963 * Position the Back button.
965 hwndButton
= GetDlgItem(hwndParent
, IDC_BACK_BUTTON
);
967 x
= rcSheet
.right
- ((padding
.x
+ buttonWidth
) * (num_buttons
- 1)) - buttonWidth
;
969 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
970 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
973 * Position the Next button.
975 hwndButton
= GetDlgItem(hwndParent
, IDC_NEXT_BUTTON
);
979 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
980 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
983 * Position the Finish button.
985 hwndButton
= GetDlgItem(hwndParent
, IDC_FINISH_BUTTON
);
987 if (psInfo
->hasFinish
)
988 x
+= padding
.x
+ buttonWidth
;
990 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
991 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
993 if (!psInfo
->hasFinish
)
994 ShowWindow(hwndButton
, SW_HIDE
);
997 * Position the Cancel button.
999 hwndButton
= GetDlgItem(hwndParent
, IDCANCEL
);
1001 x
+= padding
.x
+ buttonWidth
;
1003 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1004 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1007 * Position Help button.
1009 hwndButton
= GetDlgItem(hwndParent
, IDHELP
);
1011 if (psInfo
->hasHelp
)
1013 x
+= padding
.x
+ buttonWidth
;
1015 SetWindowPos(hwndButton
, 0, x
, y
, 0, 0,
1016 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
1019 ShowWindow(hwndButton
, SW_HIDE
);
1021 if (psInfo
->ppshheader
.dwFlags
&
1022 (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
| PSH_WIZARD_LITE
))
1026 * Position and resize the sunken line.
1029 y
= rcSheet
.bottom
- ((padding
.y
* 2) + buttonHeight
+ lineHeight
);
1031 lineWidth
= rcSheet
.right
- (padding
.x
* 2);
1032 SetWindowPos(hwndLine
, 0, x
, y
, lineWidth
, 2,
1033 SWP_NOZORDER
| SWP_NOACTIVATE
);
1036 * Position and resize the header sunken line.
1039 SetWindowPos(hwndLineHeader
, 0, 0, 0, rcSheet
.right
, 2,
1040 SWP_NOZORDER
| SWP_NOMOVE
| SWP_NOACTIVATE
);
1041 if (!(psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)))
1042 ShowWindow(hwndLineHeader
, SW_HIDE
);
1047 /******************************************************************************
1048 * PROPSHEET_GetPaddingInfo
1050 * Returns the layout information.
1052 static PADDING_INFO
PROPSHEET_GetPaddingInfo(HWND hwndDlg
)
1054 HWND hwndTab
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1056 PADDING_INFO padding
;
1058 GetWindowRect(hwndTab
, &rcTab
);
1059 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rcTab
, 2 );
1061 padding
.x
= rcTab
.left
;
1062 padding
.y
= rcTab
.top
;
1067 /******************************************************************************
1068 * PROPSHEET_GetPaddingInfoWizard
1070 * Returns the layout information.
1071 * Vertical spacing is the distance between the line and the buttons.
1072 * Do NOT use the Help button to gather padding information when it isn't mapped
1073 * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
1074 * for it in this case !
1075 * FIXME: I'm not sure about any other coordinate problems with these evil
1076 * buttons. Fix it in case additional problems appear or maybe calculate
1077 * a padding in a completely different way, as this is somewhat messy.
1079 static PADDING_INFO
PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg
, const PropSheetInfo
*
1082 PADDING_INFO padding
;
1086 POINT ptButton
, ptLine
;
1089 if (psInfo
->hasHelp
)
1095 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1097 idButton
= IDC_NEXT_BUTTON
;
1101 /* hopefully this is ok */
1102 idButton
= IDCANCEL
;
1106 hwndControl
= GetDlgItem(hwndDlg
, idButton
);
1107 GetWindowRect(hwndControl
, &rc
);
1108 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1109 ptButton
.x
= rc
.left
;
1110 ptButton
.y
= rc
.top
;
1113 hwndControl
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINE
);
1114 GetWindowRect(hwndControl
, &rc
);
1115 MapWindowPoints( 0, hwndDlg
, (POINT
*)&rc
, 2 );
1117 ptLine
.y
= rc
.bottom
;
1119 padding
.y
= ptButton
.y
- ptLine
.y
;
1122 ERR("padding negative ! Please report this !\n");
1124 /* this is most probably not correct, but the best we have now */
1125 padding
.x
= padding
.y
;
1129 /******************************************************************************
1130 * PROPSHEET_CreateTabControl
1132 * Insert the tabs in the tab control.
1134 static BOOL
PROPSHEET_CreateTabControl(HWND hwndParent
,
1135 const PropSheetInfo
* psInfo
)
1137 HWND hwndTabCtrl
= GetDlgItem(hwndParent
, IDC_TABCONTROL
);
1143 item
.mask
= TCIF_TEXT
;
1144 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
1146 nTabs
= psInfo
->nPages
;
1149 * Set the image list for icons.
1151 if (psInfo
->hImageList
)
1153 SendMessageW(hwndTabCtrl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
1156 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 0, 0);
1157 for (i
= 0; i
< nTabs
; i
++)
1159 if ( psInfo
->proppage
[i
].hasIcon
)
1161 item
.mask
|= TCIF_IMAGE
;
1162 item
.iImage
= iImage
++;
1166 item
.mask
&= ~TCIF_IMAGE
;
1169 item
.pszText
= (LPWSTR
) psInfo
->proppage
[i
].pszText
;
1170 SendMessageW(hwndTabCtrl
, TCM_INSERTITEMW
, i
, (LPARAM
)&item
);
1172 SendMessageW(hwndTabCtrl
, WM_SETREDRAW
, 1, 0);
1177 /******************************************************************************
1178 * PROPSHEET_WizardSubclassProc
1180 * Subclassing window procedure for wizard exterior pages to prevent drawing
1181 * background and so drawing above the watermark.
1183 static LRESULT CALLBACK
1184 PROPSHEET_WizardSubclassProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
1191 case WM_CTLCOLORSTATIC
:
1192 SetBkColor((HDC
)wParam
, GetSysColor(COLOR_WINDOW
));
1193 return (INT_PTR
)GetSysColorBrush(COLOR_WINDOW
);
1196 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
1200 * Get the size of an in-memory Template
1202 *( Based on the code of PROPSHEET_CollectPageInfo)
1203 * See also dialog.c/DIALOG_ParseTemplate32().
1206 static UINT
GetTemplateSize(const DLGTEMPLATE
* pTemplate
)
1209 const WORD
* p
= (const WORD
*)pTemplate
;
1210 BOOL istemplateex
= (((const MyDLGTEMPLATEEX
*)pTemplate
)->signature
== 0xFFFF);
1216 /* DLGTEMPLATEEX (not defined in any std. header file) */
1218 TRACE("is DLGTEMPLATEEX\n");
1220 p
++; /* signature */
1221 p
+= 2; /* help ID */
1222 p
+= 2; /* ext style */
1229 TRACE("is DLGTEMPLATE\n");
1231 p
+= 2; /* ext style */
1234 nrofitems
= (WORD
)*p
; p
++; /* nb items */
1250 TRACE("menu %s\n",debugstr_w( p
));
1251 p
+= lstrlenW( p
) + 1;
1262 p
+= 2; /* 0xffff plus predefined window class ordinal value */
1265 TRACE("class %s\n",debugstr_w( p
));
1266 p
+= lstrlenW( p
) + 1;
1271 TRACE("title %s\n",debugstr_w( p
));
1272 p
+= lstrlenW( p
) + 1;
1274 /* font, if DS_SETFONT set */
1275 if ((DS_SETFONT
& ((istemplateex
)? ((const MyDLGTEMPLATEEX
*)pTemplate
)->style
:
1278 p
+=(istemplateex
)?3:1;
1279 TRACE("font %s\n",debugstr_w( p
));
1280 p
+= lstrlenW( p
) + 1; /* the font name */
1283 /* now process the DLGITEMTEMPLATE(EX) structs (plus custom data)
1284 * that are following the DLGTEMPLATE(EX) data */
1285 TRACE("%d items\n",nrofitems
);
1286 while (nrofitems
> 0)
1288 p
= (WORD
*)(((DWORD_PTR
)p
+ 3) & ~3); /* DWORD align */
1291 p
+= (istemplateex
? sizeof(MyDLGITEMTEMPLATEEX
) : sizeof(DLGITEMTEMPLATE
))/sizeof(WORD
);
1300 TRACE("class ordinal 0x%08x\n",*(const DWORD
*)p
);
1304 TRACE("class %s\n",debugstr_w( p
));
1305 p
+= lstrlenW( p
) + 1;
1309 /* check title text */
1316 TRACE("text ordinal 0x%08x\n",*(const DWORD
*)p
);
1320 TRACE("text %s\n",debugstr_w( p
));
1321 p
+= lstrlenW( p
) + 1;
1324 p
+= *p
/ sizeof(WORD
) + 1; /* Skip extra data */
1328 ret
= (p
- (const WORD
*)pTemplate
) * sizeof(WORD
);
1329 TRACE("%p %p size 0x%08x\n", p
, pTemplate
, ret
);
1333 /******************************************************************************
1334 * PROPSHEET_CreatePage
1338 static BOOL
PROPSHEET_CreatePage(HWND hwndParent
,
1340 const PropSheetInfo
* psInfo
,
1341 LPCPROPSHEETPAGEW ppshpage
)
1343 const DLGTEMPLATE
* pTemplate
;
1346 DLGTEMPLATE
* pTemplateCopy
= NULL
;
1348 TRACE("index %d\n", index
);
1350 if (ppshpage
== NULL
)
1355 if (ppshpage
->dwFlags
& PSP_DLGINDIRECT
)
1357 pTemplate
= ppshpage
->u
.pResource
;
1358 resSize
= GetTemplateSize(pTemplate
);
1360 else if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1365 hResource
= FindResourceW(ppshpage
->hInstance
,
1366 ppshpage
->u
.pszTemplate
,
1371 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1373 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1377 pTemplate
= LockResource(hTemplate
);
1379 * Make a copy of the dialog template to make it writable
1387 hResource
= FindResourceA(ppshpage
->hInstance
,
1388 (LPCSTR
)ppshpage
->u
.pszTemplate
,
1393 resSize
= SizeofResource(ppshpage
->hInstance
, hResource
);
1395 hTemplate
= LoadResource(ppshpage
->hInstance
, hResource
);
1399 pTemplate
= LockResource(hTemplate
);
1401 * Make a copy of the dialog template to make it writable
1404 pTemplateCopy
= Alloc(resSize
);
1408 TRACE("copying pTemplate %p into pTemplateCopy %p (%d)\n", pTemplate
, pTemplateCopy
, resSize
);
1409 memcpy(pTemplateCopy
, pTemplate
, resSize
);
1411 if (((MyDLGTEMPLATEEX
*)pTemplateCopy
)->signature
== 0xFFFF)
1413 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1414 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~DS_MODALFRAME
;
1415 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_CAPTION
;
1416 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_SYSMENU
;
1417 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_POPUP
;
1418 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_DISABLED
;
1419 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_VISIBLE
;
1420 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->style
&= ~WS_THICKFRAME
;
1422 ((MyDLGTEMPLATEEX
*)pTemplateCopy
)->exStyle
|= WS_EX_CONTROLPARENT
;
1426 pTemplateCopy
->style
|= WS_CHILD
| WS_TABSTOP
| DS_CONTROL
;
1427 pTemplateCopy
->style
&= ~DS_MODALFRAME
;
1428 pTemplateCopy
->style
&= ~WS_CAPTION
;
1429 pTemplateCopy
->style
&= ~WS_SYSMENU
;
1430 pTemplateCopy
->style
&= ~WS_POPUP
;
1431 pTemplateCopy
->style
&= ~WS_DISABLED
;
1432 pTemplateCopy
->style
&= ~WS_VISIBLE
;
1433 pTemplateCopy
->style
&= ~WS_THICKFRAME
;
1435 pTemplateCopy
->dwExtendedStyle
|= WS_EX_CONTROLPARENT
;
1438 if (psInfo
->proppage
[index
].useCallback
)
1439 (*(ppshpage
->pfnCallback
))(0, PSPCB_CREATE
,
1440 (LPPROPSHEETPAGEW
)ppshpage
);
1442 if(ppshpage
->dwFlags
& PSP_INTERNAL_UNICODE
)
1443 hwndPage
= CreateDialogIndirectParamW(ppshpage
->hInstance
,
1446 ppshpage
->pfnDlgProc
,
1449 hwndPage
= CreateDialogIndirectParamA(ppshpage
->hInstance
,
1452 ppshpage
->pfnDlgProc
,
1454 /* Free a no more needed copy */
1455 Free(pTemplateCopy
);
1460 psInfo
->proppage
[index
].hwndPage
= hwndPage
;
1462 /* Subclass exterior wizard pages */
1463 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
1464 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1465 (ppshpage
->dwFlags
& PSP_HIDEHEADER
))
1467 SetWindowSubclass(hwndPage
, PROPSHEET_WizardSubclassProc
, 1,
1468 (DWORD_PTR
)ppshpage
);
1470 if (!(psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
))
1471 EnableThemeDialogTexture (hwndPage
, ETDT_ENABLETAB
);
1476 /******************************************************************************
1477 * PROPSHEET_LoadWizardBitmaps
1479 * Loads the watermark and header bitmaps for a wizard.
1481 static VOID
PROPSHEET_LoadWizardBitmaps(PropSheetInfo
*psInfo
)
1483 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
))
1485 /* if PSH_USEHBMWATERMARK is not set, load the resource from pszbmWatermark
1486 and put the HBITMAP in hbmWatermark. Thus all the rest of the code always
1487 considers hbmWatermark as valid. */
1488 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
1489 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
))
1491 psInfo
->ppshheader
.u4
.hbmWatermark
=
1492 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u4
.pszbmWatermark
, 0, NULL
, 0);
1495 /* Same behavior as for watermarks */
1496 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
1497 !(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
))
1499 psInfo
->ppshheader
.u5
.hbmHeader
=
1500 CreateMappedBitmap(psInfo
->ppshheader
.hInstance
, (INT_PTR
)psInfo
->ppshheader
.u5
.pszbmHeader
, 0, NULL
, 0);
1506 /******************************************************************************
1507 * PROPSHEET_ShowPage
1509 * Displays or creates the specified page.
1511 static BOOL
PROPSHEET_ShowPage(HWND hwndDlg
, int index
, PropSheetInfo
* psInfo
)
1514 HWND hwndLineHeader
;
1516 LPCPROPSHEETPAGEW ppshpage
;
1518 TRACE("active_page %d, index %d\n", psInfo
->active_page
, index
);
1519 if (index
== psInfo
->active_page
)
1521 if (GetTopWindow(hwndDlg
) != psInfo
->proppage
[index
].hwndPage
)
1522 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
);
1526 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1527 if (psInfo
->proppage
[index
].hwndPage
== 0)
1529 PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
);
1532 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
1534 PROPSHEET_SetTitleW(hwndDlg
, psInfo
->ppshheader
.dwFlags
,
1535 psInfo
->proppage
[index
].pszText
);
1537 control
= GetNextDlgTabItem(psInfo
->proppage
[index
].hwndPage
, NULL
, FALSE
);
1542 if (psInfo
->active_page
!= -1)
1543 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1545 ShowWindow(psInfo
->proppage
[index
].hwndPage
, SW_SHOW
);
1547 /* Synchronize current selection with tab control
1548 * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
1549 hwndTabCtrl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1550 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, index
, 0);
1552 psInfo
->active_page
= index
;
1553 psInfo
->activeValid
= TRUE
;
1555 if (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
) )
1557 hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
1558 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
1560 if ((ppshpage
->dwFlags
& PSP_HIDEHEADER
) || (!(psInfo
->ppshheader
.dwFlags
& PSH_HEADER
)) )
1561 ShowWindow(hwndLineHeader
, SW_HIDE
);
1563 ShowWindow(hwndLineHeader
, SW_SHOW
);
1569 /******************************************************************************
1572 static BOOL
PROPSHEET_Back(HWND hwndDlg
)
1576 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1580 TRACE("active_page %d\n", psInfo
->active_page
);
1581 if (psInfo
->active_page
< 0)
1584 psn
.hdr
.code
= PSN_WIZBACK
;
1585 psn
.hdr
.hwndFrom
= hwndDlg
;
1589 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1591 result
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1594 else if (result
== 0)
1595 idx
= psInfo
->active_page
- 1;
1597 idx
= PROPSHEET_FindPageByResId(psInfo
, result
);
1599 if (idx
>= 0 && idx
< psInfo
->nPages
)
1601 if (PROPSHEET_CanSetCurSel(hwndDlg
))
1603 SetFocus(GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
));
1604 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
1605 PROPSHEET_SetCurSel(hwndDlg
, idx
, -1, 0);
1611 /******************************************************************************
1614 static BOOL
PROPSHEET_Next(HWND hwndDlg
)
1618 LRESULT msgResult
= 0;
1619 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1622 TRACE("active_page %d\n", psInfo
->active_page
);
1623 if (psInfo
->active_page
< 0)
1626 psn
.hdr
.code
= PSN_WIZNEXT
;
1627 psn
.hdr
.hwndFrom
= hwndDlg
;
1631 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1633 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1634 if (msgResult
== -1)
1636 else if (msgResult
== 0)
1637 idx
= psInfo
->active_page
+ 1;
1639 idx
= PROPSHEET_FindPageByResId(psInfo
, msgResult
);
1641 if (idx
< psInfo
->nPages
)
1643 if (PROPSHEET_CanSetCurSel(hwndDlg
) != FALSE
)
1645 SetFocus(GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
));
1646 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
1647 PROPSHEET_SetCurSel(hwndDlg
, idx
, 1, 0);
1654 /******************************************************************************
1657 static BOOL
PROPSHEET_Finish(HWND hwndDlg
)
1661 LRESULT msgResult
= 0;
1662 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1664 TRACE("active_page %d\n", psInfo
->active_page
);
1665 if (psInfo
->active_page
< 0)
1668 psn
.hdr
.code
= PSN_WIZFINISH
;
1669 psn
.hdr
.hwndFrom
= hwndDlg
;
1673 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1675 msgResult
= SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1677 TRACE("msg result %ld\n", msgResult
);
1682 if (psInfo
->result
== 0)
1683 psInfo
->result
= IDOK
;
1684 if (psInfo
->isModeless
)
1685 psInfo
->activeValid
= FALSE
;
1687 psInfo
->ended
= TRUE
;
1692 /******************************************************************************
1695 static BOOL
PROPSHEET_Apply(HWND hwndDlg
, LPARAM lParam
)
1700 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1702 TRACE("active_page %d\n", psInfo
->active_page
);
1703 if (psInfo
->active_page
< 0)
1706 psn
.hdr
.hwndFrom
= hwndDlg
;
1712 * Send PSN_KILLACTIVE to the current page.
1714 psn
.hdr
.code
= PSN_KILLACTIVE
;
1716 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1718 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
) != FALSE
)
1722 * Send PSN_APPLY to all pages.
1724 psn
.hdr
.code
= PSN_APPLY
;
1725 psn
.lParam
= lParam
;
1727 for (i
= 0; i
< psInfo
->nPages
; i
++)
1729 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1732 switch (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1734 case PSNRET_INVALID
:
1735 PROPSHEET_ShowPage(hwndDlg
, i
, psInfo
);
1737 case PSNRET_INVALID_NOCHANGEPAGE
:
1745 psInfo
->activeValid
= FALSE
;
1747 else if(psInfo
->active_page
>= 0)
1749 psn
.hdr
.code
= PSN_SETACTIVE
;
1751 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1752 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1758 /******************************************************************************
1761 static void PROPSHEET_Cancel(HWND hwndDlg
, LPARAM lParam
)
1763 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1768 TRACE("active_page %d\n", psInfo
->active_page
);
1769 if (psInfo
->active_page
< 0)
1772 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1773 psn
.hdr
.code
= PSN_QUERYCANCEL
;
1774 psn
.hdr
.hwndFrom
= hwndDlg
;
1778 if (SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
))
1781 psn
.hdr
.code
= PSN_RESET
;
1782 psn
.lParam
= lParam
;
1784 for (i
= 0; i
< psInfo
->nPages
; i
++)
1786 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
1789 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1792 if (psInfo
->isModeless
)
1794 /* makes PSM_GETCURRENTPAGEHWND return NULL */
1795 psInfo
->activeValid
= FALSE
;
1798 psInfo
->ended
= TRUE
;
1801 /******************************************************************************
1804 static void PROPSHEET_Help(HWND hwndDlg
)
1806 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1810 TRACE("active_page %d\n", psInfo
->active_page
);
1811 if (psInfo
->active_page
< 0)
1814 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1815 psn
.hdr
.code
= PSN_HELP
;
1816 psn
.hdr
.hwndFrom
= hwndDlg
;
1820 SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1823 /******************************************************************************
1826 static void PROPSHEET_Changed(HWND hwndDlg
, HWND hwndDirtyPage
)
1829 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1832 if (!psInfo
) return;
1834 * Set the dirty flag of this page.
1836 for (i
= 0; i
< psInfo
->nPages
; i
++)
1838 if (psInfo
->proppage
[i
].hwndPage
== hwndDirtyPage
)
1839 psInfo
->proppage
[i
].isDirty
= TRUE
;
1843 * Enable the Apply button.
1845 if (psInfo
->hasApply
)
1847 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1849 EnableWindow(hwndApplyBtn
, TRUE
);
1853 /******************************************************************************
1854 * PROPSHEET_UnChanged
1856 static void PROPSHEET_UnChanged(HWND hwndDlg
, HWND hwndCleanPage
)
1859 BOOL noPageDirty
= TRUE
;
1860 HWND hwndApplyBtn
= GetDlgItem(hwndDlg
, IDC_APPLY_BUTTON
);
1861 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1864 if ( !psInfo
) return;
1865 for (i
= 0; i
< psInfo
->nPages
; i
++)
1867 /* set the specified page as clean */
1868 if (psInfo
->proppage
[i
].hwndPage
== hwndCleanPage
)
1869 psInfo
->proppage
[i
].isDirty
= FALSE
;
1871 /* look to see if there are any dirty pages */
1872 if (psInfo
->proppage
[i
].isDirty
)
1873 noPageDirty
= FALSE
;
1877 * Disable Apply button.
1880 EnableWindow(hwndApplyBtn
, FALSE
);
1883 /******************************************************************************
1884 * PROPSHEET_PressButton
1886 static void PROPSHEET_PressButton(HWND hwndDlg
, int buttonID
)
1888 TRACE("buttonID %d\n", buttonID
);
1891 case PSBTN_APPLYNOW
:
1892 PROPSHEET_DoCommand(hwndDlg
, IDC_APPLY_BUTTON
);
1895 PROPSHEET_Back(hwndDlg
);
1898 PROPSHEET_DoCommand(hwndDlg
, IDCANCEL
);
1901 PROPSHEET_Finish(hwndDlg
);
1904 PROPSHEET_DoCommand(hwndDlg
, IDHELP
);
1907 PROPSHEET_Next(hwndDlg
);
1910 PROPSHEET_DoCommand(hwndDlg
, IDOK
);
1913 FIXME("Invalid button index %d\n", buttonID
);
1918 /*************************************************************************
1919 * BOOL PROPSHEET_CanSetCurSel [Internal]
1921 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
1924 * hwndDlg [I] handle to a Dialog hWnd
1927 * TRUE if Current Selection can change
1931 static BOOL
PROPSHEET_CanSetCurSel(HWND hwndDlg
)
1933 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1944 TRACE("active_page %d\n", psInfo
->active_page
);
1945 if (psInfo
->active_page
< 0)
1952 * Notify the current page.
1954 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
1955 psn
.hdr
.code
= PSN_KILLACTIVE
;
1956 psn
.hdr
.hwndFrom
= hwndDlg
;
1960 res
= !SendMessageW(hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
1963 TRACE("<-- %d\n", res
);
1967 /******************************************************************************
1968 * PROPSHEET_SetCurSel
1970 static BOOL
PROPSHEET_SetCurSel(HWND hwndDlg
,
1973 HPROPSHEETPAGE hpage
1976 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
1977 HWND hwndHelp
= GetDlgItem(hwndDlg
, IDHELP
);
1978 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
1980 TRACE("index %d, skipdir %d, hpage %p\n", index
, skipdir
, hpage
);
1982 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
1984 if (index
< 0 || index
>= psInfo
->nPages
)
1986 TRACE("Could not find page to select!\n");
1990 /* unset active page while doing this transition. */
1991 if (psInfo
->active_page
!= -1)
1992 ShowWindow(psInfo
->proppage
[psInfo
->active_page
].hwndPage
, SW_HIDE
);
1993 psInfo
->active_page
= -1;
1999 LPCPROPSHEETPAGEW ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2002 SendMessageW(hwndTabControl
, TCM_SETCURSEL
, index
, 0);
2004 psn
.hdr
.code
= PSN_SETACTIVE
;
2005 psn
.hdr
.hwndFrom
= hwndDlg
;
2009 if (!psInfo
->proppage
[index
].hwndPage
) {
2010 if(!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppshpage
)) {
2011 PROPSHEET_RemovePage(hwndDlg
, index
, NULL
);
2013 if (!psInfo
->isModeless
)
2015 DestroyWindow(hwndDlg
);
2019 if(index
>= psInfo
->nPages
)
2027 /* Resize the property sheet page to the fit in the Tab control
2028 * (for regular property sheets) or to fit in the client area (for
2030 * NOTE: The resizing happens every time the page is selected and
2031 * not only when it's created (some applications depend on it). */
2032 PROPSHEET_GetPageRect(psInfo
, hwndDlg
, &rc
, ppshpage
);
2033 TRACE("setting page %p, rc (%s) w=%d, h=%d\n",
2034 psInfo
->proppage
[index
].hwndPage
, wine_dbgstr_rect(&rc
),
2035 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
);
2036 SetWindowPos(psInfo
->proppage
[index
].hwndPage
, HWND_TOP
,
2038 rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, 0);
2040 result
= SendMessageW(psInfo
->proppage
[index
].hwndPage
, WM_NOTIFY
, 0, (LPARAM
) &psn
);
2047 WARN("Tried to skip before first property sheet page!\n");
2050 if (index
>= psInfo
->nPages
) {
2051 WARN("Tried to skip after last property sheet page!\n");
2052 index
= psInfo
->nPages
-1;
2056 else if (result
!= 0)
2058 int old_index
= index
;
2059 index
= PROPSHEET_FindPageByResId(psInfo
, result
);
2060 if(index
>= psInfo
->nPages
) {
2062 WARN("Tried to skip to nonexistent page by res id\n");
2069 /* Invalidate the header area */
2070 if ( (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
2071 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
2073 HWND hwndLineHeader
= GetDlgItem(hwndDlg
, IDC_SUNKEN_LINEHEADER
);
2076 GetClientRect(hwndLineHeader
, &r
);
2077 MapWindowPoints(hwndLineHeader
, hwndDlg
, (LPPOINT
) &r
, 2);
2078 SetRect(&r
, 0, 0, r
.right
+ 1, r
.top
- 1);
2080 InvalidateRect(hwndDlg
, &r
, TRUE
);
2084 * Display the new page.
2086 PROPSHEET_ShowPage(hwndDlg
, index
, psInfo
);
2088 if (psInfo
->proppage
[index
].hasHelp
)
2089 EnableWindow(hwndHelp
, TRUE
);
2091 EnableWindow(hwndHelp
, FALSE
);
2096 /******************************************************************************
2097 * PROPSHEET_SetCurSelId
2099 * Selects the page, specified by resource id.
2101 static void PROPSHEET_SetCurSelId(HWND hwndDlg
, int id
)
2104 PropSheetInfo
* psInfo
= 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(!IS_INTRESOURCE(lpszText
))
2122 MultiByteToWideChar(CP_ACP
, 0, lpszText
, -1, szTitle
, ARRAY_SIZE(szTitle
));
2123 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, szTitle
);
2127 PROPSHEET_SetTitleW(hwndDlg
, dwStyle
, (LPCWSTR
)lpszText
);
2131 /******************************************************************************
2132 * PROPSHEET_SetTitleW
2134 static void PROPSHEET_SetTitleW(HWND hwndDlg
, DWORD dwStyle
, LPCWSTR lpszText
)
2136 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2139 TRACE("%s (style %08x)\n", debugstr_w(lpszText
), dwStyle
);
2140 if (IS_INTRESOURCE(lpszText
)) {
2141 if (!LoadStringW(psInfo
->ppshheader
.hInstance
, LOWORD(lpszText
), szTitle
, ARRAY_SIZE(szTitle
)))
2145 if (dwStyle
& PSH_PROPTITLE
)
2148 int lentitle
= lstrlenW(lpszText
);
2149 int lenprop
= lstrlenW(psInfo
->strPropertiesFor
);
2151 dest
= Alloc( (lentitle
+ lenprop
+ 1)*sizeof (WCHAR
));
2152 wsprintfW(dest
, psInfo
->strPropertiesFor
, lpszText
);
2154 SetWindowTextW(hwndDlg
, dest
);
2158 SetWindowTextW(hwndDlg
, lpszText
);
2161 /******************************************************************************
2162 * PROPSHEET_SetFinishTextA
2164 static void PROPSHEET_SetFinishTextA(HWND hwndDlg
, LPCSTR lpszText
)
2166 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2167 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2169 TRACE("'%s'\n", lpszText
);
2170 /* Set text, show and enable the Finish button */
2171 SetWindowTextA(hwndButton
, lpszText
);
2172 ShowWindow(hwndButton
, SW_SHOW
);
2173 EnableWindow(hwndButton
, TRUE
);
2175 /* Make it default pushbutton */
2176 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2178 /* Hide Back button */
2179 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2180 ShowWindow(hwndButton
, SW_HIDE
);
2182 if (!psInfo
->hasFinish
)
2184 /* Hide Next button */
2185 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2186 ShowWindow(hwndButton
, SW_HIDE
);
2190 /******************************************************************************
2191 * PROPSHEET_SetFinishTextW
2193 static void PROPSHEET_SetFinishTextW(HWND hwndDlg
, LPCWSTR lpszText
)
2195 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2196 HWND hwndButton
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2198 TRACE("%s\n", debugstr_w(lpszText
));
2199 /* Set text, show and enable the Finish button */
2200 SetWindowTextW(hwndButton
, lpszText
);
2201 ShowWindow(hwndButton
, SW_SHOW
);
2202 EnableWindow(hwndButton
, TRUE
);
2204 /* Make it default pushbutton */
2205 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2207 /* Hide Back button */
2208 hwndButton
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2209 ShowWindow(hwndButton
, SW_HIDE
);
2211 if (!psInfo
->hasFinish
)
2213 /* Hide Next button */
2214 hwndButton
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2215 ShowWindow(hwndButton
, SW_HIDE
);
2219 /******************************************************************************
2220 * PROPSHEET_QuerySiblings
2222 static LRESULT
PROPSHEET_QuerySiblings(HWND hwndDlg
,
2223 WPARAM wParam
, LPARAM lParam
)
2227 LRESULT msgResult
= 0;
2228 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2230 while ((i
< psInfo
->nPages
) && (msgResult
== 0))
2232 hwndPage
= psInfo
->proppage
[i
].hwndPage
;
2233 msgResult
= SendMessageW(hwndPage
, PSM_QUERYSIBLINGS
, wParam
, lParam
);
2240 /******************************************************************************
2241 * PROPSHEET_InsertPage
2243 static BOOL
PROPSHEET_InsertPage(HWND hwndDlg
, HPROPSHEETPAGE hpageInsertAfter
, HPROPSHEETPAGE hpage
)
2245 PropSheetInfo
*psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2246 PropPageInfo
*ppi
, *prev_ppi
= psInfo
->proppage
;
2247 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2248 LPCPROPSHEETPAGEW ppsp
= (LPCPROPSHEETPAGEW
)hpage
;
2252 TRACE("hwndDlg %p, hpageInsertAfter %p, hpage %p\n", hwndDlg
, hpageInsertAfter
, hpage
);
2254 if (IS_INTRESOURCE(hpageInsertAfter
))
2255 index
= LOWORD(hpageInsertAfter
);
2258 index
= PROPSHEET_GetPageIndex(hpageInsertAfter
, psInfo
, -1);
2261 TRACE("Could not find page to insert after!\n");
2267 if (index
> psInfo
->nPages
)
2268 index
= psInfo
->nPages
;
2270 ppi
= Alloc(sizeof(PropPageInfo
) * (psInfo
->nPages
+ 1));
2275 * Fill in a new PropPageInfo entry.
2278 memcpy(ppi
, prev_ppi
, index
* sizeof(PropPageInfo
));
2279 memset(&ppi
[index
], 0, sizeof(PropPageInfo
));
2280 if (index
< psInfo
->nPages
)
2281 memcpy(&ppi
[index
+ 1], &prev_ppi
[index
], (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2282 psInfo
->proppage
= ppi
;
2284 if (!PROPSHEET_CollectPageInfo(ppsp
, psInfo
, index
, FALSE
))
2286 psInfo
->proppage
= prev_ppi
;
2291 psInfo
->proppage
[index
].hpage
= hpage
;
2293 if (ppsp
->dwFlags
& PSP_PREMATURE
)
2295 /* Create the page but don't show it */
2296 if (!PROPSHEET_CreatePage(hwndDlg
, index
, psInfo
, ppsp
))
2298 psInfo
->proppage
= prev_ppi
;
2306 if (index
<= psInfo
->active_page
)
2307 psInfo
->active_page
++;
2310 * Add a new tab to the tab control.
2312 item
.mask
= TCIF_TEXT
;
2313 item
.pszText
= (LPWSTR
) psInfo
->proppage
[index
].pszText
;
2314 item
.cchTextMax
= MAX_TABTEXT_LENGTH
;
2316 if (psInfo
->hImageList
)
2317 SendMessageW(hwndTabControl
, TCM_SETIMAGELIST
, 0, (LPARAM
)psInfo
->hImageList
);
2319 if (psInfo
->proppage
[index
].hasIcon
)
2321 item
.mask
|= TCIF_IMAGE
;
2322 item
.iImage
= index
;
2325 SendMessageW(hwndTabControl
, TCM_INSERTITEMW
, index
, (LPARAM
)&item
);
2327 /* If it is the only page - show it */
2328 if (psInfo
->nPages
== 1)
2329 PROPSHEET_SetCurSel(hwndDlg
, 0, 1, 0);
2334 /******************************************************************************
2337 static BOOL
PROPSHEET_AddPage(HWND hwndDlg
, HPROPSHEETPAGE hpage
)
2339 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2340 TRACE("hwndDlg %p, hpage %p\n", hwndDlg
, hpage
);
2341 return PROPSHEET_InsertPage(hwndDlg
, UlongToPtr(psInfo
->nPages
), hpage
);
2344 /******************************************************************************
2345 * PROPSHEET_RemovePage
2347 static BOOL
PROPSHEET_RemovePage(HWND hwndDlg
,
2349 HPROPSHEETPAGE hpage
)
2351 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2352 HWND hwndTabControl
= GetDlgItem(hwndDlg
, IDC_TABCONTROL
);
2353 PropPageInfo
* oldPages
;
2355 TRACE("index %d, hpage %p\n", index
, hpage
);
2360 index
= PROPSHEET_GetPageIndex(hpage
, psInfo
, index
);
2362 /* Make sure that index is within range */
2363 if (index
< 0 || index
>= psInfo
->nPages
)
2365 TRACE("Could not find page to remove!\n");
2369 TRACE("total pages %d removing page %d active page %d\n",
2370 psInfo
->nPages
, index
, psInfo
->active_page
);
2372 * Check if we're removing the active page.
2374 if (index
== psInfo
->active_page
)
2376 if (psInfo
->nPages
> 1)
2380 /* activate previous page */
2381 PROPSHEET_SetCurSel(hwndDlg
, index
- 1, -1, 0);
2385 /* activate the next page */
2386 PROPSHEET_SetCurSel(hwndDlg
, index
+ 1, 1, 0);
2387 psInfo
->active_page
= index
;
2392 psInfo
->active_page
= -1;
2393 if (!psInfo
->isModeless
)
2395 psInfo
->ended
= TRUE
;
2400 else if (index
< psInfo
->active_page
)
2401 psInfo
->active_page
--;
2403 /* Unsubclass the page dialog window */
2404 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
) &&
2405 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2406 ((PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
)->dwFlags
& PSP_HIDEHEADER
))
2408 RemoveWindowSubclass(psInfo
->proppage
[index
].hwndPage
,
2409 PROPSHEET_WizardSubclassProc
, 1);
2412 /* Destroy page dialog window */
2413 DestroyWindow(psInfo
->proppage
[index
].hwndPage
);
2415 /* Free page resources */
2416 if(psInfo
->proppage
[index
].hpage
)
2418 PROPSHEETPAGEW
* psp
= (PROPSHEETPAGEW
*)psInfo
->proppage
[index
].hpage
;
2420 if (psp
->dwFlags
& PSP_USETITLE
)
2421 Free ((LPVOID
)psInfo
->proppage
[index
].pszText
);
2423 DestroyPropertySheetPage(psInfo
->proppage
[index
].hpage
);
2426 /* Remove the tab */
2427 SendMessageW(hwndTabControl
, TCM_DELETEITEM
, index
, 0);
2429 oldPages
= psInfo
->proppage
;
2431 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * psInfo
->nPages
);
2434 memcpy(&psInfo
->proppage
[0], &oldPages
[0], index
* sizeof(PropPageInfo
));
2436 if (index
< psInfo
->nPages
)
2437 memcpy(&psInfo
->proppage
[index
], &oldPages
[index
+ 1],
2438 (psInfo
->nPages
- index
) * sizeof(PropPageInfo
));
2445 /******************************************************************************
2446 * PROPSHEET_SetWizButtons
2448 * This code will work if (and assumes that) the Next button is on top of the
2449 * Finish button. ie. Finish comes after Next in the Z order.
2450 * This means make sure the dialog template reflects this.
2453 static void PROPSHEET_SetWizButtons(HWND hwndDlg
, DWORD dwFlags
)
2455 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2456 HWND hwndBack
= GetDlgItem(hwndDlg
, IDC_BACK_BUTTON
);
2457 HWND hwndNext
= GetDlgItem(hwndDlg
, IDC_NEXT_BUTTON
);
2458 HWND hwndFinish
= GetDlgItem(hwndDlg
, IDC_FINISH_BUTTON
);
2459 BOOL enable_finish
= ((dwFlags
& PSWIZB_FINISH
) || psInfo
->hasFinish
) && !(dwFlags
& PSWIZB_DISABLEDFINISH
);
2461 TRACE("%d\n", dwFlags
);
2463 EnableWindow(hwndBack
, dwFlags
& PSWIZB_BACK
);
2464 EnableWindow(hwndNext
, dwFlags
& PSWIZB_NEXT
);
2465 EnableWindow(hwndFinish
, enable_finish
);
2467 /* set the default pushbutton to an enabled button */
2469 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_FINISH_BUTTON
, 0);
2470 else if (dwFlags
& PSWIZB_NEXT
)
2471 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_NEXT_BUTTON
, 0);
2472 else if (dwFlags
& PSWIZB_BACK
)
2473 SendMessageW(hwndDlg
, DM_SETDEFID
, IDC_BACK_BUTTON
, 0);
2475 SendMessageW(hwndDlg
, DM_SETDEFID
, IDCANCEL
, 0);
2477 if (!psInfo
->hasFinish
)
2479 if ((dwFlags
& PSWIZB_FINISH
) || (dwFlags
& PSWIZB_DISABLEDFINISH
))
2481 /* Hide the Next button */
2482 ShowWindow(hwndNext
, SW_HIDE
);
2484 /* Show the Finish button */
2485 ShowWindow(hwndFinish
, SW_SHOW
);
2489 /* Hide the Finish button */
2490 ShowWindow(hwndFinish
, SW_HIDE
);
2491 /* Show the Next button */
2492 ShowWindow(hwndNext
, SW_SHOW
);
2497 /******************************************************************************
2498 * PROPSHEET_SetHeaderTitleW
2500 static void PROPSHEET_SetHeaderTitleW(HWND hwndDlg
, UINT page_index
, const WCHAR
*title
)
2502 PropSheetInfo
*psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2503 PROPSHEETPAGEW
*page
;
2505 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_w(title
));
2507 if (page_index
>= psInfo
->nPages
)
2510 page
= (PROPSHEETPAGEW
*)psInfo
->proppage
[page_index
].hpage
;
2512 if (!IS_INTRESOURCE(page
->pszHeaderTitle
))
2513 Free((void *)page
->pszHeaderTitle
);
2515 page
->pszHeaderTitle
= heap_strdupW(title
);
2516 page
->dwFlags
|= PSP_USEHEADERTITLE
;
2519 /******************************************************************************
2520 * PROPSHEET_SetHeaderTitleA
2522 static void PROPSHEET_SetHeaderTitleA(HWND hwndDlg
, UINT page_index
, const char *title
)
2526 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_a(title
));
2528 titleW
= heap_strdupAtoW(title
);
2529 PROPSHEET_SetHeaderTitleW(hwndDlg
, page_index
, titleW
);
2533 /******************************************************************************
2534 * PROPSHEET_SetHeaderSubTitleW
2536 static void PROPSHEET_SetHeaderSubTitleW(HWND hwndDlg
, UINT page_index
, const WCHAR
*subtitle
)
2538 PropSheetInfo
*psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2539 PROPSHEETPAGEW
*page
;
2541 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_w(subtitle
));
2543 if (page_index
>= psInfo
->nPages
)
2546 page
= (PROPSHEETPAGEW
*)psInfo
->proppage
[page_index
].hpage
;
2548 if (!IS_INTRESOURCE(page
->pszHeaderSubTitle
))
2549 Free((void *)page
->pszHeaderSubTitle
);
2551 page
->pszHeaderSubTitle
= heap_strdupW(subtitle
);
2552 page
->dwFlags
|= PSP_USEHEADERSUBTITLE
;
2555 /******************************************************************************
2556 * PROPSHEET_SetHeaderSubTitleA
2558 static void PROPSHEET_SetHeaderSubTitleA(HWND hwndDlg
, UINT page_index
, const char *subtitle
)
2562 TRACE("(%p, %u, %s)\n", hwndDlg
, page_index
, debugstr_a(subtitle
));
2564 subtitleW
= heap_strdupAtoW(subtitle
);
2565 PROPSHEET_SetHeaderSubTitleW(hwndDlg
, page_index
, subtitleW
);
2569 /******************************************************************************
2570 * PROPSHEET_HwndToIndex
2572 static LRESULT
PROPSHEET_HwndToIndex(HWND hwndDlg
, HWND hPageDlg
)
2575 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2577 TRACE("(%p, %p)\n", hwndDlg
, hPageDlg
);
2579 for (index
= 0; index
< psInfo
->nPages
; index
++)
2580 if (psInfo
->proppage
[index
].hwndPage
== hPageDlg
)
2582 WARN("%p not found\n", hPageDlg
);
2586 /******************************************************************************
2587 * PROPSHEET_IndexToHwnd
2589 static LRESULT
PROPSHEET_IndexToHwnd(HWND hwndDlg
, int iPageIndex
)
2591 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2592 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2595 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2596 WARN("%d out of range.\n", iPageIndex
);
2599 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hwndPage
;
2602 /******************************************************************************
2603 * PROPSHEET_PageToIndex
2605 static LRESULT
PROPSHEET_PageToIndex(HWND hwndDlg
, HPROPSHEETPAGE hPage
)
2607 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2609 TRACE("(%p, %p)\n", hwndDlg
, hPage
);
2611 return PROPSHEET_GetPageIndex(hPage
, psInfo
, -1);
2614 /******************************************************************************
2615 * PROPSHEET_IndexToPage
2617 static LRESULT
PROPSHEET_IndexToPage(HWND hwndDlg
, int iPageIndex
)
2619 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2620 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2621 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2622 WARN("%d out of range.\n", iPageIndex
);
2625 return (LRESULT
)psInfo
->proppage
[iPageIndex
].hpage
;
2628 /******************************************************************************
2629 * PROPSHEET_IdToIndex
2631 static LRESULT
PROPSHEET_IdToIndex(HWND hwndDlg
, int iPageId
)
2634 LPCPROPSHEETPAGEW psp
;
2635 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2636 TRACE("(%p, %d)\n", hwndDlg
, iPageId
);
2637 for (index
= 0; index
< psInfo
->nPages
; index
++) {
2638 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[index
].hpage
;
2639 if (psp
->u
.pszTemplate
== MAKEINTRESOURCEW(iPageId
))
2646 /******************************************************************************
2647 * PROPSHEET_IndexToId
2649 static LRESULT
PROPSHEET_IndexToId(HWND hwndDlg
, int iPageIndex
)
2651 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2652 LPCPROPSHEETPAGEW psp
;
2653 TRACE("(%p, %d)\n", hwndDlg
, iPageIndex
);
2654 if (iPageIndex
<0 || iPageIndex
>=psInfo
->nPages
) {
2655 WARN("%d out of range.\n", iPageIndex
);
2658 psp
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[iPageIndex
].hpage
;
2659 if (psp
->dwFlags
& PSP_DLGINDIRECT
|| !IS_INTRESOURCE(psp
->u
.pszTemplate
)) {
2662 return (LRESULT
)psp
->u
.pszTemplate
;
2665 /******************************************************************************
2666 * PROPSHEET_GetResult
2668 static LRESULT
PROPSHEET_GetResult(HWND hwndDlg
)
2670 PropSheetInfo
* psInfo
= GetPropW(hwndDlg
, PropSheetInfoStr
);
2671 return psInfo
->result
;
2674 /******************************************************************************
2675 * PROPSHEET_RecalcPageSizes
2677 static BOOL
PROPSHEET_RecalcPageSizes(HWND hwndDlg
)
2679 FIXME("(%p): stub\n", hwndDlg
);
2683 /******************************************************************************
2684 * PROPSHEET_GetPageIndex
2686 * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
2687 * the array of PropPageInfo. If page is not found original index is used
2688 * (page takes precedence over index).
2690 static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE page
, const PropSheetInfo
* psInfo
, int original_index
)
2694 TRACE("page %p index %d\n", page
, original_index
);
2696 for (index
= 0; index
< psInfo
->nPages
; index
++)
2697 if (psInfo
->proppage
[index
].hpage
== page
)
2700 return original_index
;
2703 /******************************************************************************
2706 static void PROPSHEET_CleanUp(HWND hwndDlg
)
2709 PropSheetInfo
* psInfo
= RemovePropW(hwndDlg
, PropSheetInfoStr
);
2712 if (!psInfo
) return;
2713 if (!IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
))
2714 Free ((LPVOID
)psInfo
->ppshheader
.pszCaption
);
2716 for (i
= 0; i
< psInfo
->nPages
; i
++)
2718 PROPSHEETPAGEA
* psp
= (PROPSHEETPAGEA
*)psInfo
->proppage
[i
].hpage
;
2720 /* Unsubclass the page dialog window */
2721 if((psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_NEW
| PSH_WIZARD97_OLD
)) &&
2722 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2723 (psp
->dwFlags
& PSP_HIDEHEADER
))
2725 RemoveWindowSubclass(psInfo
->proppage
[i
].hwndPage
,
2726 PROPSHEET_WizardSubclassProc
, 1);
2729 if(psInfo
->proppage
[i
].hwndPage
)
2730 DestroyWindow(psInfo
->proppage
[i
].hwndPage
);
2734 if (psp
->dwFlags
& PSP_USETITLE
)
2735 Free ((LPVOID
)psInfo
->proppage
[i
].pszText
);
2737 DestroyPropertySheetPage(psInfo
->proppage
[i
].hpage
);
2741 DeleteObject(psInfo
->hFont
);
2742 DeleteObject(psInfo
->hFontBold
);
2743 /* If we created the bitmaps, destroy them */
2744 if ((psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) &&
2745 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMWATERMARK
)) )
2746 DeleteObject(psInfo
->ppshheader
.u4
.hbmWatermark
);
2747 if ((psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) &&
2748 (!(psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)) )
2749 DeleteObject(psInfo
->ppshheader
.u5
.hbmHeader
);
2751 Free(psInfo
->proppage
);
2752 Free(psInfo
->strPropertiesFor
);
2753 ImageList_Destroy(psInfo
->hImageList
);
2758 static INT
do_loop(const PropSheetInfo
*psInfo
)
2762 HWND hwnd
= psInfo
->hwnd
;
2763 HWND parent
= psInfo
->ppshheader
.hwndParent
;
2765 while(IsWindow(hwnd
) && !psInfo
->ended
&& (ret
= GetMessageW(&msg
, NULL
, 0, 0)))
2770 if(!IsDialogMessageW(hwnd
, &msg
))
2772 TranslateMessage(&msg
);
2773 DispatchMessageW(&msg
);
2777 if(ret
== 0 && msg
.message
)
2778 PostQuitMessage(msg
.wParam
);
2781 ret
= psInfo
->result
;
2784 EnableWindow(parent
, TRUE
);
2786 DestroyWindow(hwnd
);
2790 /******************************************************************************
2791 * PROPSHEET_PropertySheet
2793 * Common code between PropertySheetA/W
2795 static INT_PTR
PROPSHEET_PropertySheet(PropSheetInfo
* psInfo
, BOOL unicode
)
2799 if (psInfo
->active_page
>= psInfo
->nPages
) psInfo
->active_page
= 0;
2800 TRACE("startpage: %d of %d pages\n", psInfo
->active_page
, psInfo
->nPages
);
2802 psInfo
->unicode
= unicode
;
2803 psInfo
->ended
= FALSE
;
2805 if(!psInfo
->isModeless
)
2807 parent
= psInfo
->ppshheader
.hwndParent
;
2808 if (parent
) EnableWindow(parent
, FALSE
);
2810 bRet
= PROPSHEET_CreateDialog(psInfo
);
2811 if(!psInfo
->isModeless
)
2812 bRet
= do_loop(psInfo
);
2816 /******************************************************************************
2817 * PropertySheet (COMCTL32.@)
2818 * PropertySheetA (COMCTL32.@)
2820 * Creates a property sheet in the specified property sheet header.
2823 * Modal property sheets: Positive if successful or -1 otherwise.
2824 * Modeless property sheets: Property sheet handle.
2826 *| ID_PSREBOOTSYSTEM - The user must reboot the computer for the changes to take effect.
2827 *| ID_PSRESTARTWINDOWS - The user must restart Windows for the changes to take effect.
2829 INT_PTR WINAPI
PropertySheetA(LPCPROPSHEETHEADERA lppsh
)
2831 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2835 TRACE("(%p)\n", lppsh
);
2837 PROPSHEET_CollectSheetInfoA(lppsh
, psInfo
);
2839 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2840 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2842 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2844 if (!psInfo
->usePropPage
)
2845 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2848 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageA((LPCPROPSHEETPAGEA
)pByte
);
2849 pByte
+= ((LPCPROPSHEETPAGEA
)pByte
)->dwSize
;
2852 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2855 if (psInfo
->usePropPage
)
2856 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2862 return PROPSHEET_PropertySheet(psInfo
, FALSE
);
2865 /******************************************************************************
2866 * PropertySheetW (COMCTL32.@)
2868 * See PropertySheetA.
2870 INT_PTR WINAPI
PropertySheetW(LPCPROPSHEETHEADERW lppsh
)
2872 PropSheetInfo
* psInfo
= GlobalAlloc(GPTR
, sizeof(PropSheetInfo
));
2876 TRACE("(%p)\n", lppsh
);
2878 PROPSHEET_CollectSheetInfoW(lppsh
, psInfo
);
2880 psInfo
->proppage
= Alloc(sizeof(PropPageInfo
) * lppsh
->nPages
);
2881 pByte
= (const BYTE
*) psInfo
->ppshheader
.u3
.ppsp
;
2883 for (n
= i
= 0; i
< lppsh
->nPages
; i
++, n
++)
2885 if (!psInfo
->usePropPage
)
2886 psInfo
->proppage
[n
].hpage
= psInfo
->ppshheader
.u3
.phpage
[i
];
2889 psInfo
->proppage
[n
].hpage
= CreatePropertySheetPageW((LPCPROPSHEETPAGEW
)pByte
);
2890 pByte
+= ((LPCPROPSHEETPAGEW
)pByte
)->dwSize
;
2893 if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEW
)psInfo
->proppage
[n
].hpage
,
2896 if (psInfo
->usePropPage
)
2897 DestroyPropertySheetPage(psInfo
->proppage
[n
].hpage
);
2903 return PROPSHEET_PropertySheet(psInfo
, TRUE
);
2906 static LPWSTR
load_string( HINSTANCE instance
, LPCWSTR str
)
2910 if (IS_INTRESOURCE(str
))
2915 WORD i
, id
= LOWORD(str
);
2918 if (!(hrsrc
= FindResourceW( instance
, MAKEINTRESOURCEW((id
>> 4) + 1), (LPWSTR
)RT_STRING
)))
2920 if (!(hmem
= LoadResource( instance
, hrsrc
))) return NULL
;
2921 if (!(ptr
= LockResource( hmem
))) return NULL
;
2922 for (i
= id
& 0x0f; i
> 0; i
--) ptr
+= *ptr
+ 1;
2924 if (!len
) return NULL
;
2925 ret
= Alloc( (len
+ 1) * sizeof(WCHAR
) );
2928 memcpy( ret
, ptr
+ 1, len
* sizeof(WCHAR
) );
2934 int len
= (lstrlenW(str
) + 1) * sizeof(WCHAR
);
2936 if (ret
) memcpy( ret
, str
, len
);
2942 /******************************************************************************
2943 * CreatePropertySheetPage (COMCTL32.@)
2944 * CreatePropertySheetPageA (COMCTL32.@)
2946 * Creates a new property sheet page.
2949 * Success: Handle to new property sheet page.
2953 * An application must use the PSM_ADDPAGE message to add the new page to
2954 * an existing property sheet.
2956 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageA(
2957 LPCPROPSHEETPAGEA lpPropSheetPage
)
2959 PROPSHEETPAGEW
*ppsp
;
2961 if (lpPropSheetPage
->dwSize
< PROPSHEETPAGEA_V1_SIZE
)
2964 /* original data is used for callback notifications */
2965 if ((lpPropSheetPage
->dwFlags
& PSP_USECALLBACK
) && lpPropSheetPage
->pfnCallback
)
2967 ppsp
= Alloc(2 * sizeof(*ppsp
));
2968 memcpy(ppsp
, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEA
)));
2969 memcpy(ppsp
+ 1, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEA
)));
2973 ppsp
= Alloc(sizeof(*ppsp
));
2974 memcpy(ppsp
, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEA
)));
2977 ppsp
->dwFlags
&= ~PSP_INTERNAL_UNICODE
;
2979 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
2981 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
2983 int len
= strlen(lpPropSheetPage
->u
.pszTemplate
) + 1;
2984 char *template = Alloc( len
);
2986 ppsp
->u
.pszTemplate
= (LPWSTR
)strcpy( template, lpPropSheetPage
->u
.pszTemplate
);
2990 if (ppsp
->dwFlags
& PSP_USEICONID
)
2992 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
2993 ppsp
->u2
.pszIcon
= heap_strdupAtoW( lpPropSheetPage
->u2
.pszIcon
);
2996 if (ppsp
->dwFlags
& PSP_USETITLE
)
2998 if (IS_INTRESOURCE( ppsp
->pszTitle
))
2999 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3001 ppsp
->pszTitle
= heap_strdupAtoW( lpPropSheetPage
->pszTitle
);
3004 ppsp
->pszTitle
= NULL
;
3006 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3007 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3009 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3011 if (IS_INTRESOURCE( ppsp
->pszHeaderTitle
))
3012 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3014 ppsp
->pszHeaderTitle
= heap_strdupAtoW( lpPropSheetPage
->pszHeaderTitle
);
3017 ppsp
->pszHeaderTitle
= NULL
;
3019 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3021 if (IS_INTRESOURCE( ppsp
->pszHeaderSubTitle
))
3022 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3024 ppsp
->pszHeaderSubTitle
= heap_strdupAtoW( lpPropSheetPage
->pszHeaderSubTitle
);
3027 ppsp
->pszHeaderSubTitle
= NULL
;
3029 if ((ppsp
->dwFlags
& PSP_USECALLBACK
) && ppsp
->dwSize
> PROPSHEETPAGEA_V1_SIZE
&& ppsp
->pfnCallback
)
3030 ppsp
->pfnCallback(0, PSPCB_ADDREF
, ppsp
+ 1);
3032 return (HPROPSHEETPAGE
)ppsp
;
3035 /******************************************************************************
3036 * CreatePropertySheetPageW (COMCTL32.@)
3038 * See CreatePropertySheetA.
3040 HPROPSHEETPAGE WINAPI
CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
)
3042 PROPSHEETPAGEW
*ppsp
;
3044 if (lpPropSheetPage
->dwSize
< PROPSHEETPAGEW_V1_SIZE
)
3047 /* original data is used for callback notifications */
3048 if ((lpPropSheetPage
->dwFlags
& PSP_USECALLBACK
) && lpPropSheetPage
->pfnCallback
)
3050 ppsp
= Alloc(2 * sizeof(*ppsp
));
3051 memcpy(ppsp
, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEW
)));
3052 memcpy(ppsp
+ 1, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEW
)));
3056 ppsp
= Alloc(sizeof(*ppsp
));
3057 memcpy(ppsp
, lpPropSheetPage
, min(lpPropSheetPage
->dwSize
, sizeof(PROPSHEETPAGEW
)));
3060 ppsp
->dwFlags
|= PSP_INTERNAL_UNICODE
;
3062 if ( !(ppsp
->dwFlags
& PSP_DLGINDIRECT
) )
3064 if (!IS_INTRESOURCE( ppsp
->u
.pszTemplate
))
3065 ppsp
->u
.pszTemplate
= heap_strdupW( lpPropSheetPage
->u
.pszTemplate
);
3068 if ( ppsp
->dwFlags
& PSP_USEICONID
)
3070 if (!IS_INTRESOURCE( ppsp
->u2
.pszIcon
))
3071 ppsp
->u2
.pszIcon
= heap_strdupW( lpPropSheetPage
->u2
.pszIcon
);
3074 if (ppsp
->dwFlags
& PSP_USETITLE
)
3075 ppsp
->pszTitle
= load_string( ppsp
->hInstance
, ppsp
->pszTitle
);
3077 ppsp
->pszTitle
= NULL
;
3079 if (ppsp
->dwFlags
& PSP_HIDEHEADER
)
3080 ppsp
->dwFlags
&= ~(PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
);
3082 if (ppsp
->dwFlags
& PSP_USEHEADERTITLE
)
3083 ppsp
->pszHeaderTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderTitle
);
3085 ppsp
->pszHeaderTitle
= NULL
;
3087 if (ppsp
->dwFlags
& PSP_USEHEADERSUBTITLE
)
3088 ppsp
->pszHeaderSubTitle
= load_string( ppsp
->hInstance
, ppsp
->pszHeaderSubTitle
);
3090 ppsp
->pszHeaderSubTitle
= NULL
;
3092 if ((ppsp
->dwFlags
& PSP_USECALLBACK
) && ppsp
->dwSize
> PROPSHEETPAGEW_V1_SIZE
&& ppsp
->pfnCallback
)
3093 ppsp
->pfnCallback(0, PSPCB_ADDREF
, ppsp
+ 1);
3095 return (HPROPSHEETPAGE
)ppsp
;
3098 /******************************************************************************
3099 * DestroyPropertySheetPage (COMCTL32.@)
3101 * Destroys a property sheet page previously created with
3102 * CreatePropertySheetA() or CreatePropertySheetW() and frees the associated
3109 BOOL WINAPI
DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage
)
3111 PROPSHEETPAGEW
*psp
= (PROPSHEETPAGEW
*)hPropPage
;
3116 if ((psp
->dwFlags
& PSP_USECALLBACK
) && psp
->pfnCallback
)
3117 psp
->pfnCallback(0, PSPCB_RELEASE
, psp
+ 1);
3119 if (!(psp
->dwFlags
& PSP_DLGINDIRECT
) && !IS_INTRESOURCE( psp
->u
.pszTemplate
))
3120 Free ((LPVOID
)psp
->u
.pszTemplate
);
3122 if ((psp
->dwFlags
& PSP_USEICONID
) && !IS_INTRESOURCE( psp
->u2
.pszIcon
))
3123 Free ((LPVOID
)psp
->u2
.pszIcon
);
3125 if ((psp
->dwFlags
& PSP_USETITLE
) && !IS_INTRESOURCE( psp
->pszTitle
))
3126 Free ((LPVOID
)psp
->pszTitle
);
3128 if ((psp
->dwFlags
& PSP_USEHEADERTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderTitle
))
3129 Free ((LPVOID
)psp
->pszHeaderTitle
);
3131 if ((psp
->dwFlags
& PSP_USEHEADERSUBTITLE
) && !IS_INTRESOURCE( psp
->pszHeaderSubTitle
))
3132 Free ((LPVOID
)psp
->pszHeaderSubTitle
);
3139 /******************************************************************************
3140 * PROPSHEET_IsDialogMessage
3142 static BOOL
PROPSHEET_IsDialogMessage(HWND hwnd
, LPMSG lpMsg
)
3144 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3147 if (!psInfo
|| (hwnd
!= lpMsg
->hwnd
&& !IsChild(hwnd
, lpMsg
->hwnd
)))
3150 if (lpMsg
->message
== WM_KEYDOWN
&& (GetKeyState(VK_CONTROL
) & 0x8000))
3153 INT dlgCode
= SendMessageW(lpMsg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)lpMsg
);
3155 if (!(dlgCode
& DLGC_WANTMESSAGE
))
3157 switch (lpMsg
->wParam
)
3160 if (GetKeyState(VK_SHIFT
) & 0x8000)
3166 case VK_NEXT
: new_page
= 1; break;
3167 case VK_PRIOR
: new_page
= -1; break;
3173 if (PROPSHEET_CanSetCurSel(hwnd
) != FALSE
)
3175 new_page
+= psInfo
->active_page
;
3178 new_page
= psInfo
->nPages
- 1;
3179 else if (new_page
>= psInfo
->nPages
)
3182 PROPSHEET_SetCurSel(hwnd
, new_page
, 1, 0);
3189 return IsDialogMessageW(hwnd
, lpMsg
);
3192 /******************************************************************************
3193 * PROPSHEET_DoCommand
3195 static BOOL
PROPSHEET_DoCommand(HWND hwnd
, WORD wID
)
3201 case IDC_APPLY_BUTTON
:
3203 HWND hwndApplyBtn
= GetDlgItem(hwnd
, IDC_APPLY_BUTTON
);
3205 if (PROPSHEET_Apply(hwnd
, wID
== IDOK
? 1: 0) == FALSE
)
3210 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3212 /* don't overwrite ID_PSRESTARTWINDOWS or ID_PSREBOOTSYSTEM */
3213 if (psInfo
->result
== 0)
3214 psInfo
->result
= IDOK
;
3216 if (psInfo
->isModeless
)
3217 psInfo
->activeValid
= FALSE
;
3219 psInfo
->ended
= TRUE
;
3222 EnableWindow(hwndApplyBtn
, FALSE
);
3227 case IDC_BACK_BUTTON
:
3228 PROPSHEET_Back(hwnd
);
3231 case IDC_NEXT_BUTTON
:
3232 PROPSHEET_Next(hwnd
);
3235 case IDC_FINISH_BUTTON
:
3236 PROPSHEET_Finish(hwnd
);
3240 PROPSHEET_Cancel(hwnd
, 0);
3244 PROPSHEET_Help(hwnd
);
3254 /******************************************************************************
3257 static LRESULT
PROPSHEET_Paint(HWND hwnd
, HDC hdcParam
)
3259 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3264 HPALETTE hOldPal
= 0;
3268 LPCPROPSHEETPAGEW ppshpage
;
3269 WCHAR szBuffer
[256];
3272 hdc
= hdcParam
? hdcParam
: BeginPaint(hwnd
, &ps
);
3275 hdcSrc
= CreateCompatibleDC(0);
3277 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3278 hOldPal
= SelectPalette(hdc
, psInfo
->ppshheader
.hplWatermark
, FALSE
);
3280 if (psInfo
->active_page
< 0)
3283 ppshpage
= (LPCPROPSHEETPAGEW
)psInfo
->proppage
[psInfo
->active_page
].hpage
;
3285 if ( (ppshpage
&& !(ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3286 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3287 (psInfo
->ppshheader
.dwFlags
& PSH_HEADER
) )
3289 HWND hwndLineHeader
= GetDlgItem(hwnd
, IDC_SUNKEN_LINEHEADER
);
3291 COLORREF clrOld
= 0;
3294 GetClientRect(hwndLineHeader
, &r
);
3295 MapWindowPoints(hwndLineHeader
, hwnd
, (LPPOINT
) &r
, 2);
3296 SetRect(&rzone
, 0, 0, r
.right
+ 1, r
.top
- 1);
3298 hOldFont
= SelectObject(hdc
, psInfo
->hFontBold
);
3300 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHBMHEADER
)
3302 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u5
.hbmHeader
);
3304 GetObjectW(psInfo
->ppshheader
.u5
.hbmHeader
, sizeof(BITMAP
), &bm
);
3305 if (psInfo
->ppshheader
.dwFlags
& PSH_WIZARD97_OLD
)
3307 /* Fill the unoccupied part of the header with color of the
3308 * left-top pixel, but do it only when needed.
3310 if (bm
.bmWidth
< r
.right
|| bm
.bmHeight
< r
.bottom
)
3312 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3314 if (bm
.bmWidth
< r
.right
)
3316 r
.left
= bm
.bmWidth
;
3317 FillRect(hdc
, &r
, hbr
);
3319 if (bm
.bmHeight
< r
.bottom
)
3322 r
.top
= bm
.bmHeight
;
3323 FillRect(hdc
, &r
, hbr
);
3328 /* Draw the header itself. */
3329 BitBlt(hdc
, 0, 0, bm
.bmWidth
, min(bm
.bmHeight
, rzone
.bottom
),
3330 hdcSrc
, 0, 0, SRCCOPY
);
3335 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3336 FillRect(hdc
, &rzone
, hbr
);
3338 /* Draw the header bitmap. It's always centered like a
3339 * common 49 x 49 bitmap. */
3340 margin
= (rzone
.bottom
- 49) / 2;
3341 BitBlt(hdc
, rzone
.right
- 49 - margin
, margin
,
3342 min(bm
.bmWidth
, 49), min(bm
.bmHeight
, 49),
3343 hdcSrc
, 0, 0, SRCCOPY
);
3345 /* NOTE: Native COMCTL32 draws a white stripe over the bitmap
3346 * if its height is smaller than 49 pixels. Because the reason
3347 * for this bug is unknown the current code doesn't try to
3351 SelectObject(hdcSrc
, hbmp
);
3354 clrOld
= SetTextColor (hdc
, 0x00000000);
3355 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
3357 if (ppshpage
->dwFlags
& PSP_USEHEADERTITLE
) {
3358 SetRect(&r
, 20, 10, 0, 0);
3359 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3360 DrawTextW(hdc
, ppshpage
->pszHeaderTitle
, -1, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3363 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderTitle
,
3367 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_SINGLELINE
| DT_NOCLIP
);
3372 if (ppshpage
->dwFlags
& PSP_USEHEADERSUBTITLE
) {
3373 SelectObject(hdc
, psInfo
->hFont
);
3374 SetRect(&r
, 40, 25, rzone
.right
- 69, rzone
.bottom
);
3375 if (!IS_INTRESOURCE(ppshpage
->pszHeaderTitle
))
3376 DrawTextW(hdc
, ppshpage
->pszHeaderSubTitle
, -1, &r
, DT_LEFT
| DT_WORDBREAK
);
3379 nLength
= LoadStringW(ppshpage
->hInstance
, (UINT_PTR
)ppshpage
->pszHeaderSubTitle
,
3383 DrawTextW(hdc
, szBuffer
, nLength
, &r
, DT_LEFT
| DT_WORDBREAK
);
3388 offsety
= rzone
.bottom
+ 2;
3390 SetTextColor(hdc
, clrOld
);
3391 SetBkMode(hdc
, oldBkMode
);
3392 SelectObject(hdc
, hOldFont
);
3395 if ( (ppshpage
&& (ppshpage
->dwFlags
& PSP_HIDEHEADER
)) &&
3396 (psInfo
->ppshheader
.dwFlags
& (PSH_WIZARD97_OLD
| PSH_WIZARD97_NEW
)) &&
3397 (psInfo
->ppshheader
.dwFlags
& PSH_WATERMARK
) )
3399 HWND hwndLine
= GetDlgItem(hwnd
, IDC_SUNKEN_LINE
);
3401 GetClientRect(hwndLine
, &r
);
3402 MapWindowPoints(hwndLine
, hwnd
, (LPPOINT
) &r
, 2);
3403 SetRect(&rzone
, 0, 0, r
.right
, r
.top
- 1);
3405 hbr
= GetSysColorBrush(COLOR_WINDOW
);
3406 FillRect(hdc
, &rzone
, hbr
);
3408 GetObjectW(psInfo
->ppshheader
.u4
.hbmWatermark
, sizeof(BITMAP
), &bm
);
3409 hbmp
= SelectObject(hdcSrc
, psInfo
->ppshheader
.u4
.hbmWatermark
);
3411 /* The watermark is truncated to a width of 164 pixels */
3412 r
.right
= min(r
.right
, 164);
3413 BitBlt(hdc
, 0, offsety
, min(bm
.bmWidth
, r
.right
),
3414 min(bm
.bmHeight
, r
.bottom
), hdcSrc
, 0, 0, SRCCOPY
);
3416 /* If the bitmap is not big enough, fill the remaining area
3417 with the color of pixel (0,0) of bitmap - see MSDN */
3418 if (r
.top
> bm
.bmHeight
) {
3419 r
.bottom
= r
.top
- 1;
3420 r
.top
= bm
.bmHeight
;
3422 r
.right
= bm
.bmWidth
;
3423 hbr
= CreateSolidBrush(GetPixel(hdcSrc
, 0, 0));
3424 FillRect(hdc
, &r
, hbr
);
3428 SelectObject(hdcSrc
, hbmp
);
3431 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHPLWATERMARK
)
3432 SelectPalette(hdc
, hOldPal
, FALSE
);
3436 if (!hdcParam
) EndPaint(hwnd
, &ps
);
3441 /******************************************************************************
3442 * PROPSHEET_DialogProc
3444 static INT_PTR CALLBACK
3445 PROPSHEET_DialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3447 TRACE("hwnd=%p msg=0x%04x wparam=%lx lparam=%lx\n",
3448 hwnd
, uMsg
, wParam
, lParam
);
3454 PropSheetInfo
* psInfo
= (PropSheetInfo
*) lParam
;
3455 WCHAR
* strCaption
= Alloc(MAX_CAPTION_LENGTH
*sizeof(WCHAR
));
3456 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3460 /* Using PropSheetInfoStr to store extra data doesn't match the native
3461 * common control: native uses TCM_[GS]ETITEM
3463 SetPropW(hwnd
, PropSheetInfoStr
, psInfo
);
3466 * psInfo->hwnd is not being used by WINE code - it exists
3467 * for compatibility with "real" Windoze. The same about
3468 * SetWindowLongPtr - WINE is only using the PropSheetInfoStr
3471 psInfo
->hwnd
= hwnd
;
3472 SetWindowLongPtrW(hwnd
, DWLP_USER
, (DWORD_PTR
)psInfo
);
3474 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3476 /* set up the Next and Back buttons by default */
3477 PROPSHEET_SetWizButtons(hwnd
, PSWIZB_BACK
|PSWIZB_NEXT
);
3481 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
3482 psInfo
->hFont
= CreateFontIndirectW (&logFont
);
3483 logFont
.lfWeight
= FW_BOLD
;
3484 psInfo
->hFontBold
= CreateFontIndirectW (&logFont
);
3487 * Small icon in the title bar.
3489 if ((psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
) ||
3490 (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
))
3493 int icon_cx
= GetSystemMetrics(SM_CXSMICON
);
3494 int icon_cy
= GetSystemMetrics(SM_CYSMICON
);
3496 if (psInfo
->ppshheader
.dwFlags
& PSH_USEICONID
)
3497 hIcon
= LoadImageW(psInfo
->ppshheader
.hInstance
,
3498 psInfo
->ppshheader
.u
.pszIcon
,
3503 hIcon
= psInfo
->ppshheader
.u
.hIcon
;
3505 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)hIcon
);
3508 if (psInfo
->ppshheader
.dwFlags
& PSH_USEHICON
)
3509 SendMessageW(hwnd
, WM_SETICON
, 0, (LPARAM
)psInfo
->ppshheader
.u
.hIcon
);
3511 psInfo
->strPropertiesFor
= strCaption
;
3513 GetWindowTextW(hwnd
, psInfo
->strPropertiesFor
, MAX_CAPTION_LENGTH
);
3515 PROPSHEET_CreateTabControl(hwnd
, psInfo
);
3517 PROPSHEET_LoadWizardBitmaps(psInfo
);
3519 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3521 ShowWindow(hwndTabCtrl
, SW_HIDE
);
3522 PROPSHEET_AdjustSizeWizard(hwnd
, psInfo
);
3523 PROPSHEET_AdjustButtonsWizard(hwnd
, psInfo
);
3524 SetFocus(GetDlgItem(hwnd
, IDC_NEXT_BUTTON
));
3528 if (PROPSHEET_SizeMismatch(hwnd
, psInfo
))
3530 PROPSHEET_AdjustSize(hwnd
, psInfo
);
3531 PROPSHEET_AdjustButtons(hwnd
, psInfo
);
3533 SetFocus(GetDlgItem(hwnd
, IDOK
));
3536 if (IS_INTRESOURCE(psInfo
->ppshheader
.pszCaption
) &&
3537 psInfo
->ppshheader
.hInstance
)
3541 if (LoadStringW(psInfo
->ppshheader
.hInstance
,
3542 (UINT_PTR
)psInfo
->ppshheader
.pszCaption
, szText
, 255))
3543 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
, szText
);
3547 PROPSHEET_SetTitleW(hwnd
, psInfo
->ppshheader
.dwFlags
,
3548 psInfo
->ppshheader
.pszCaption
);
3552 if (psInfo
->useCallback
)
3553 (*(psInfo
->ppshheader
.pfnCallback
))(hwnd
, PSCB_INITIALIZED
, 0);
3555 idx
= psInfo
->active_page
;
3556 psInfo
->active_page
= -1;
3558 PROPSHEET_SetCurSel(hwnd
, idx
, 1, psInfo
->proppage
[idx
].hpage
);
3560 /* doing TCM_SETCURSEL seems to be needed even in case of PSH_WIZARD,
3561 * as some programs call TCM_GETCURSEL to get the current selection
3562 * from which to switch to the next page */
3563 SendMessageW(hwndTabCtrl
, TCM_SETCURSEL
, psInfo
->active_page
, 0);
3565 PROPSHEET_UnChanged(hwnd
, NULL
);
3567 /* wizards set their focus during init */
3568 if (psInfo
->ppshheader
.dwFlags
& INTRNL_ANY_WIZARD
)
3574 case WM_PRINTCLIENT
:
3576 PROPSHEET_Paint(hwnd
, (HDC
)wParam
);
3580 PROPSHEET_CleanUp(hwnd
);
3584 PROPSHEET_Cancel(hwnd
, 1);
3585 return FALSE
; /* let DefDlgProc post us WM_COMMAND/IDCANCEL */
3588 if (!PROPSHEET_DoCommand(hwnd
, LOWORD(wParam
)))
3590 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3595 /* No default handler, forward notification to active page */
3596 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3598 HWND hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3599 SendMessageW(hwndPage
, WM_COMMAND
, wParam
, lParam
);
3606 NMHDR
* pnmh
= (LPNMHDR
) lParam
;
3608 if (pnmh
->code
== TCN_SELCHANGE
)
3610 int index
= SendMessageW(pnmh
->hwndFrom
, TCM_GETCURSEL
, 0, 0);
3611 PROPSHEET_SetCurSel(hwnd
, index
, 1, 0);
3614 if(pnmh
->code
== TCN_SELCHANGING
)
3616 BOOL bRet
= PROPSHEET_CanSetCurSel(hwnd
);
3617 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, !bRet
);
3624 case WM_SYSCOLORCHANGE
:
3625 COMCTL32_RefreshSysColors();
3628 case PSM_GETCURRENTPAGEHWND
:
3630 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3636 if (psInfo
->activeValid
&& psInfo
->active_page
!= -1)
3637 hwndPage
= psInfo
->proppage
[psInfo
->active_page
].hwndPage
;
3639 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndPage
);
3645 PROPSHEET_Changed(hwnd
, (HWND
)wParam
);
3649 PROPSHEET_UnChanged(hwnd
, (HWND
)wParam
);
3652 case PSM_GETTABCONTROL
:
3654 HWND hwndTabCtrl
= GetDlgItem(hwnd
, IDC_TABCONTROL
);
3656 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, (DWORD_PTR
)hwndTabCtrl
);
3665 msgResult
= PROPSHEET_CanSetCurSel(hwnd
);
3666 if(msgResult
!= FALSE
)
3668 msgResult
= PROPSHEET_SetCurSel(hwnd
,
3671 (HPROPSHEETPAGE
)lParam
);
3674 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3679 case PSM_CANCELTOCLOSE
:
3681 WCHAR buf
[MAX_BUTTONTEXT_LENGTH
];
3682 HWND hwndOK
= GetDlgItem(hwnd
, IDOK
);
3683 HWND hwndCancel
= GetDlgItem(hwnd
, IDCANCEL
);
3685 EnableWindow(hwndCancel
, FALSE
);
3686 if (LoadStringW(COMCTL32_hModule
, IDS_CLOSE
, buf
, ARRAY_SIZE(buf
)))
3687 SetWindowTextW(hwndOK
, buf
);
3692 case PSM_RESTARTWINDOWS
:
3694 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3699 /* reboot system takes precedence over restart windows */
3700 if (psInfo
->result
!= ID_PSREBOOTSYSTEM
)
3701 psInfo
->result
= ID_PSRESTARTWINDOWS
;
3706 case PSM_REBOOTSYSTEM
:
3708 PropSheetInfo
* psInfo
= GetPropW(hwnd
, PropSheetInfoStr
);
3713 psInfo
->result
= ID_PSREBOOTSYSTEM
;
3719 PROPSHEET_SetTitleA(hwnd
, (DWORD
) wParam
, (LPCSTR
) lParam
);
3723 PROPSHEET_SetTitleW(hwnd
, (DWORD
) wParam
, (LPCWSTR
) lParam
);
3728 BOOL msgResult
= PROPSHEET_Apply(hwnd
, 0);
3730 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3735 case PSM_QUERYSIBLINGS
:
3737 LRESULT msgResult
= PROPSHEET_QuerySiblings(hwnd
, wParam
, lParam
);
3739 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3747 * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
3748 * a return value. This is not true. PSM_ADDPAGE returns TRUE
3749 * on success or FALSE otherwise, as specified on MSDN Online.
3750 * Also see the MFC code for
3751 * CPropertySheet::AddPage(CPropertyPage* pPage).
3754 BOOL msgResult
= PROPSHEET_AddPage(hwnd
, (HPROPSHEETPAGE
)lParam
);
3756 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3761 case PSM_REMOVEPAGE
:
3762 PROPSHEET_RemovePage(hwnd
, (int)wParam
, (HPROPSHEETPAGE
)lParam
);
3765 case PSM_ISDIALOGMESSAGE
:
3767 BOOL msgResult
= PROPSHEET_IsDialogMessage(hwnd
, (LPMSG
)lParam
);
3768 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3772 case PSM_PRESSBUTTON
:
3773 PROPSHEET_PressButton(hwnd
, (int)wParam
);
3776 case PSM_SETFINISHTEXTA
:
3777 PROPSHEET_SetFinishTextA(hwnd
, (LPCSTR
) lParam
);
3780 case PSM_SETWIZBUTTONS
:
3781 PROPSHEET_SetWizButtons(hwnd
, (DWORD
)lParam
);
3784 case PSM_SETCURSELID
:
3785 PROPSHEET_SetCurSelId(hwnd
, (int)lParam
);
3788 case PSM_SETFINISHTEXTW
:
3789 PROPSHEET_SetFinishTextW(hwnd
, (LPCWSTR
) lParam
);
3792 case PSM_INSERTPAGE
:
3794 BOOL msgResult
= PROPSHEET_InsertPage(hwnd
, (HPROPSHEETPAGE
)wParam
, (HPROPSHEETPAGE
)lParam
);
3795 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3799 case PSM_SETHEADERTITLEW
:
3800 PROPSHEET_SetHeaderTitleW(hwnd
, wParam
, (LPCWSTR
)lParam
);
3803 case PSM_SETHEADERTITLEA
:
3804 PROPSHEET_SetHeaderTitleA(hwnd
, wParam
, (LPCSTR
)lParam
);
3807 case PSM_SETHEADERSUBTITLEW
:
3808 PROPSHEET_SetHeaderSubTitleW(hwnd
, wParam
, (LPCWSTR
)lParam
);
3811 case PSM_SETHEADERSUBTITLEA
:
3812 PROPSHEET_SetHeaderSubTitleA(hwnd
, wParam
, (LPCSTR
)lParam
);
3815 case PSM_HWNDTOINDEX
:
3817 LRESULT msgResult
= PROPSHEET_HwndToIndex(hwnd
, (HWND
)wParam
);
3818 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3822 case PSM_INDEXTOHWND
:
3824 LRESULT msgResult
= PROPSHEET_IndexToHwnd(hwnd
, (int)wParam
);
3825 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3829 case PSM_PAGETOINDEX
:
3831 LRESULT msgResult
= PROPSHEET_PageToIndex(hwnd
, (HPROPSHEETPAGE
)wParam
);
3832 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3836 case PSM_INDEXTOPAGE
:
3838 LRESULT msgResult
= PROPSHEET_IndexToPage(hwnd
, (int)wParam
);
3839 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3845 LRESULT msgResult
= PROPSHEET_IdToIndex(hwnd
, (int)lParam
);
3846 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3852 LRESULT msgResult
= PROPSHEET_IndexToId(hwnd
, (int)wParam
);
3853 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3859 LRESULT msgResult
= PROPSHEET_GetResult(hwnd
);
3860 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);
3864 case PSM_RECALCPAGESIZES
:
3866 LRESULT msgResult
= PROPSHEET_RecalcPageSizes(hwnd
);
3867 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, msgResult
);