| 1 | /* $Id: propsheet.cpp,v 1.13 2001-12-04 16:11:52 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Property Sheets
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1998 Francis Beaudet
|
|---|
| 6 | * Copyright 1999 Thuy Nguyen
|
|---|
| 7 | * Copyright 1999 Achim Hasenmueller
|
|---|
| 8 | * Copyright 1999-2000 Christoph Bratschi
|
|---|
| 9 | *
|
|---|
| 10 | * TODO:
|
|---|
| 11 | * - Tab order
|
|---|
| 12 | * - Unicode property sheets
|
|---|
| 13 | * - Wizard bugs
|
|---|
| 14 | */
|
|---|
| 15 |
|
|---|
| 16 | /*
|
|---|
| 17 | - Corel WINE 20000807 level
|
|---|
| 18 | - (WINE 991212 level)
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | #include <string.h>
|
|---|
| 22 | #include "winbase.h"
|
|---|
| 23 | #include "commctrl.h"
|
|---|
| 24 | #include "prsht.h"
|
|---|
| 25 | #include "dialog.h"
|
|---|
| 26 | #include "winnls.h"
|
|---|
| 27 | #include "comctl32.h"
|
|---|
| 28 | #include "heapstring.h"
|
|---|
| 29 | #include <debugtools.h>
|
|---|
| 30 |
|
|---|
| 31 | /******************************************************************************
|
|---|
| 32 | * Data structures
|
|---|
| 33 | */
|
|---|
| 34 | typedef struct
|
|---|
| 35 | {
|
|---|
| 36 | WORD dlgVer;
|
|---|
| 37 | WORD signature;
|
|---|
| 38 | DWORD helpID;
|
|---|
| 39 | DWORD exStyle;
|
|---|
| 40 | DWORD style;
|
|---|
| 41 | } MyDLGTEMPLATEEX;
|
|---|
| 42 |
|
|---|
| 43 | typedef struct tagPropPageInfo
|
|---|
| 44 | {
|
|---|
| 45 | HPROPSHEETPAGE hpage; /* to keep track of pages not passed to PropertySheet */
|
|---|
| 46 | HWND hwndPage;
|
|---|
| 47 | BOOL isDirty;
|
|---|
| 48 | LPCWSTR pszText;
|
|---|
| 49 | BOOL hasHelp;
|
|---|
| 50 | BOOL useCallback;
|
|---|
| 51 | BOOL hasIcon;
|
|---|
| 52 | } PropPageInfo;
|
|---|
| 53 |
|
|---|
| 54 | typedef struct tagPropSheetInfo
|
|---|
| 55 | {
|
|---|
| 56 | LPSTR strPropertiesFor;
|
|---|
| 57 | int nPages;
|
|---|
| 58 | int active_page;
|
|---|
| 59 | LPPROPSHEETHEADERA ppshheader;
|
|---|
| 60 | BOOL isModeless;
|
|---|
| 61 | BOOL hasHelp;
|
|---|
| 62 | BOOL hasApply;
|
|---|
| 63 | BOOL useCallback;
|
|---|
| 64 | BOOL restartWindows;
|
|---|
| 65 | BOOL rebootSystem;
|
|---|
| 66 | BOOL activeValid;
|
|---|
| 67 | PropPageInfo* proppage;
|
|---|
| 68 | int x;
|
|---|
| 69 | int y;
|
|---|
| 70 | int width;
|
|---|
| 71 | int height;
|
|---|
| 72 | HIMAGELIST hImageList;
|
|---|
| 73 | } PropSheetInfo;
|
|---|
| 74 |
|
|---|
| 75 | typedef struct
|
|---|
| 76 | {
|
|---|
| 77 | int x;
|
|---|
| 78 | int y;
|
|---|
| 79 | } PADDING_INFO;
|
|---|
| 80 |
|
|---|
| 81 | /******************************************************************************
|
|---|
| 82 | * Defines and global variables
|
|---|
| 83 | */
|
|---|
| 84 |
|
|---|
| 85 | const char * PropSheetInfoStr = "PropertySheetInfo";
|
|---|
| 86 |
|
|---|
| 87 | #define MAX_CAPTION_LENGTH 255
|
|---|
| 88 | #define MAX_TABTEXT_LENGTH 255
|
|---|
| 89 | #define MAX_BUTTONTEXT_LENGTH 64
|
|---|
| 90 |
|
|---|
| 91 | /******************************************************************************
|
|---|
| 92 | * Prototypes
|
|---|
| 93 | */
|
|---|
| 94 | static BOOL PROPSHEET_CreateDialog(PropSheetInfo* psInfo);
|
|---|
| 95 | static BOOL PROPSHEET_SizeMismatch(HWND hwndDlg, PropSheetInfo* psInfo);
|
|---|
| 96 | static BOOL PROPSHEET_IsTooSmall(HWND hwndDlg, PropSheetInfo* psInfo);
|
|---|
| 97 | static BOOL PROPSHEET_AdjustSize(HWND hwndDlg, PropSheetInfo* psInfo);
|
|---|
| 98 | static BOOL PROPSHEET_AdjustButtons(HWND hwndParent, PropSheetInfo* psInfo);
|
|---|
| 99 | static BOOL PROPSHEET_CollectSheetInfo(LPCPROPSHEETHEADERA lppsh,
|
|---|
| 100 | PropSheetInfo * psInfo);
|
|---|
| 101 | static BOOL PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEA lppsp,
|
|---|
| 102 | PropSheetInfo * psInfo,
|
|---|
| 103 | int index);
|
|---|
| 104 | static BOOL PROPSHEET_CreateTabControl(HWND hwndParent,
|
|---|
| 105 | PropSheetInfo * psInfo);
|
|---|
| 106 | static int PROPSHEET_CreatePage(HWND hwndParent, int index,
|
|---|
| 107 | const PropSheetInfo * psInfo,
|
|---|
| 108 | LPPROPSHEETPAGEA ppshpage);
|
|---|
| 109 | static int PROPSHEET_ShowPage(HWND hwndDlg, int index, PropSheetInfo * psInfo);
|
|---|
| 110 | static PADDING_INFO PROPSHEET_GetPaddingInfo(HWND hwndDlg);
|
|---|
| 111 | static void PROPSHEET_Back(HWND hwndDlg);
|
|---|
| 112 | static void PROPSHEET_Next(HWND hwndDlg);
|
|---|
| 113 | static void PROPSHEET_Finish(HWND hwndDlg);
|
|---|
| 114 | static BOOL PROPSHEET_Apply(HWND hwndDlg, LPARAM lParam);
|
|---|
| 115 | static void PROPSHEET_Cancel(HWND hwndDlg, LPARAM lParam);
|
|---|
| 116 | static void PROPSHEET_Help(HWND hwndDlg);
|
|---|
| 117 | static void PROPSHEET_Changed(HWND hwndDlg, HWND hwndDirtyPage);
|
|---|
| 118 | static void PROPSHEET_UnChanged(HWND hwndDlg, HWND hwndCleanPage);
|
|---|
| 119 | static void PROPSHEET_PressButton(HWND hwndDlg, int buttonID);
|
|---|
| 120 | static void PROPSHEET_SetFinishTextA(HWND hwndDlg, LPCSTR lpszText);
|
|---|
| 121 | static void PROPSHEET_SetTitleA(HWND hwndDlg, DWORD dwStyle, LPCSTR lpszText);
|
|---|
| 122 | static BOOL PROPSHEET_CanSetCurSel(HWND hwndDlg);
|
|---|
| 123 | static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
|
|---|
| 124 | int index,
|
|---|
| 125 | HPROPSHEETPAGE hpage);
|
|---|
| 126 | static LRESULT PROPSHEET_QuerySiblings(HWND hwndDlg,
|
|---|
| 127 | WPARAM wParam, LPARAM lParam);
|
|---|
| 128 | static BOOL PROPSHEET_AddPage(HWND hwndDlg,
|
|---|
| 129 | HPROPSHEETPAGE hpage);
|
|---|
| 130 |
|
|---|
| 131 | static BOOL PROPSHEET_RemovePage(HWND hwndDlg,
|
|---|
| 132 | int index,
|
|---|
| 133 | HPROPSHEETPAGE hpage);
|
|---|
| 134 | static void PROPSHEET_CleanUp();
|
|---|
| 135 | static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage, PropSheetInfo* psInfo);
|
|---|
| 136 | static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags);
|
|---|
| 137 | static PADDING_INFO PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg,PropSheetInfo* psInfo);
|
|---|
| 138 | static BOOL PROPSHEET_IsDialogMessage(HWND hwnd, LPMSG lpMsg);
|
|---|
| 139 | static INT PROPSHEET_DoDialogBox( HWND hwnd, HWND owner);
|
|---|
| 140 |
|
|---|
| 141 | BOOL WINAPI
|
|---|
| 142 | PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 | /******************************************************************************
|
|---|
| 146 | * PROPSHEET_CollectSheetInfo
|
|---|
| 147 | *
|
|---|
| 148 | * Collect relevant data.
|
|---|
| 149 | */
|
|---|
| 150 | static BOOL PROPSHEET_CollectSheetInfo(LPCPROPSHEETHEADERA lppsh,
|
|---|
| 151 | PropSheetInfo * psInfo)
|
|---|
| 152 | {
|
|---|
| 153 | DWORD dwFlags = lppsh->dwFlags;
|
|---|
| 154 |
|
|---|
| 155 | psInfo->hasHelp = dwFlags & PSH_HASHELP;
|
|---|
| 156 | psInfo->hasApply = !(dwFlags & PSH_NOAPPLYNOW);
|
|---|
| 157 | psInfo->useCallback = dwFlags & PSH_USECALLBACK;
|
|---|
| 158 | psInfo->isModeless = dwFlags & PSH_MODELESS;
|
|---|
| 159 | psInfo->ppshheader = (PROPSHEETHEADERA*)lppsh;
|
|---|
| 160 | psInfo->ppshheader = (PROPSHEETHEADERA*)COMCTL32_Alloc(sizeof(PROPSHEETHEADERA));
|
|---|
| 161 | *psInfo->ppshheader = *lppsh;
|
|---|
| 162 |
|
|---|
| 163 | if (HIWORD(lppsh->pszCaption))
|
|---|
| 164 | psInfo->ppshheader->pszCaption = HEAP_strdupA( GetProcessHeap(),
|
|---|
| 165 | 0, lppsh->pszCaption );
|
|---|
| 166 |
|
|---|
| 167 | psInfo->nPages = lppsh->nPages;
|
|---|
| 168 |
|
|---|
| 169 | if (dwFlags & PSH_USEPSTARTPAGE)
|
|---|
| 170 | {
|
|---|
| 171 | TRACE("PSH_USEPSTARTPAGE is on");
|
|---|
| 172 | psInfo->active_page = 0;
|
|---|
| 173 | }
|
|---|
| 174 | else
|
|---|
| 175 | psInfo->active_page = lppsh->nStartPage;
|
|---|
| 176 |
|
|---|
| 177 | if (psInfo->active_page < 0 || psInfo->active_page >= psInfo->nPages)
|
|---|
| 178 | psInfo->active_page = 0;
|
|---|
| 179 |
|
|---|
| 180 | psInfo->restartWindows = FALSE;
|
|---|
| 181 | psInfo->rebootSystem = FALSE;
|
|---|
| 182 | psInfo->hImageList = 0;
|
|---|
| 183 | psInfo->activeValid = FALSE;
|
|---|
| 184 |
|
|---|
| 185 | return TRUE;
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | /******************************************************************************
|
|---|
| 189 | * PROPSHEET_FindPageByResId
|
|---|
| 190 | *
|
|---|
| 191 | * Find page index corresponding to page resource id.
|
|---|
| 192 | */
|
|---|
| 193 | INT PROPSHEET_FindPageByResId(PropSheetInfo * psInfo, LRESULT resId)
|
|---|
| 194 | {
|
|---|
| 195 | INT i;
|
|---|
| 196 |
|
|---|
| 197 | for (i = 0; i < psInfo->nPages; i++)
|
|---|
| 198 | {
|
|---|
| 199 | LPCPROPSHEETPAGEA lppsp = (LPCPROPSHEETPAGEA)psInfo->proppage[i].hpage;
|
|---|
| 200 |
|
|---|
| 201 | /* Fixme: if resource ID is a string shall we use strcmp ??? */
|
|---|
| 202 | if (lppsp->pszTemplate == (LPVOID)resId)
|
|---|
| 203 | break;
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 | return i;
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | /******************************************************************************
|
|---|
| 210 | * PROPSHEET_CollectPageInfo
|
|---|
| 211 | *
|
|---|
| 212 | * Collect property sheet data.
|
|---|
| 213 | * With code taken from DIALOG_ParseTemplate32.
|
|---|
| 214 | */
|
|---|
| 215 | BOOL PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEA lppsp,
|
|---|
| 216 | PropSheetInfo * psInfo,
|
|---|
| 217 | int index)
|
|---|
| 218 | {
|
|---|
| 219 | DLGTEMPLATE* pTemplate;
|
|---|
| 220 | const WORD* p;
|
|---|
| 221 | DWORD dwFlags;
|
|---|
| 222 | int width, height;
|
|---|
| 223 |
|
|---|
| 224 | psInfo->proppage[index].hpage = (HPROPSHEETPAGE)lppsp;
|
|---|
| 225 | psInfo->proppage[index].hwndPage = 0;
|
|---|
| 226 | psInfo->proppage[index].isDirty = FALSE;
|
|---|
| 227 |
|
|---|
| 228 | /*
|
|---|
| 229 | * Process property page flags.
|
|---|
| 230 | */
|
|---|
| 231 | dwFlags = lppsp->dwFlags;
|
|---|
| 232 | psInfo->proppage[index].useCallback = dwFlags & PSP_USECALLBACK;
|
|---|
| 233 | psInfo->proppage[index].hasHelp = dwFlags & PSP_HASHELP;
|
|---|
| 234 | psInfo->proppage[index].hasIcon = dwFlags & (PSP_USEHICON | PSP_USEICONID);
|
|---|
| 235 |
|
|---|
| 236 | /* as soon as we have a page with the help flag, set the sheet flag on */
|
|---|
| 237 | if (psInfo->proppage[index].hasHelp)
|
|---|
| 238 | psInfo->hasHelp = TRUE;
|
|---|
| 239 |
|
|---|
| 240 | /*
|
|---|
| 241 | * Process page template.
|
|---|
| 242 | */
|
|---|
| 243 | if (dwFlags & PSP_DLGINDIRECT)
|
|---|
| 244 | pTemplate = (DLGTEMPLATE*)lppsp->pResource;
|
|---|
| 245 | else
|
|---|
| 246 | {
|
|---|
| 247 | HRSRC hResource = FindResourceA(lppsp->hInstance,
|
|---|
| 248 | lppsp->pszTemplate,
|
|---|
| 249 | RT_DIALOGA);
|
|---|
| 250 | HGLOBAL hTemplate = LoadResource(lppsp->hInstance,
|
|---|
| 251 | hResource);
|
|---|
| 252 | pTemplate = (LPDLGTEMPLATEA)LockResource(hTemplate);
|
|---|
| 253 | }
|
|---|
| 254 |
|
|---|
| 255 | /*
|
|---|
| 256 | * Extract the size of the page and the caption.
|
|---|
| 257 | */
|
|---|
| 258 | p = (const WORD *)pTemplate;
|
|---|
| 259 |
|
|---|
| 260 | if (((MyDLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF)
|
|---|
| 261 | {
|
|---|
| 262 | /* DIALOGEX template */
|
|---|
| 263 |
|
|---|
| 264 | p++; /* dlgVer */
|
|---|
| 265 | p++; /* signature */
|
|---|
| 266 | p += 2; /* help ID */
|
|---|
| 267 | p += 2; /* ext style */
|
|---|
| 268 | p += 2; /* style */
|
|---|
| 269 | }
|
|---|
| 270 | else
|
|---|
| 271 | {
|
|---|
| 272 | /* DIALOG template */
|
|---|
| 273 |
|
|---|
| 274 | p += 2; /* style */
|
|---|
| 275 | p += 2; /* ext style */
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | p++; /* nb items */
|
|---|
| 279 | p++; /* x */
|
|---|
| 280 | p++; /* y */
|
|---|
| 281 | width = (WORD)*p; p++;
|
|---|
| 282 | height = (WORD)*p; p++;
|
|---|
| 283 |
|
|---|
| 284 | /* remember the largest width and height */
|
|---|
| 285 | if (width > psInfo->width)
|
|---|
| 286 | psInfo->width = width;
|
|---|
| 287 |
|
|---|
| 288 | if (height > psInfo->height)
|
|---|
| 289 | psInfo->height = height;
|
|---|
| 290 |
|
|---|
| 291 | /* menu */
|
|---|
| 292 | switch ((WORD)*p)
|
|---|
| 293 | {
|
|---|
| 294 | case 0x0000:
|
|---|
| 295 | p++;
|
|---|
| 296 | break;
|
|---|
| 297 | case 0xffff:
|
|---|
| 298 | p += 2;
|
|---|
| 299 | break;
|
|---|
| 300 | default:
|
|---|
| 301 | p += lstrlenW( (LPCWSTR)p ) + 1;
|
|---|
| 302 | break;
|
|---|
| 303 | }
|
|---|
| 304 |
|
|---|
| 305 | /* class */
|
|---|
| 306 | switch ((WORD)*p)
|
|---|
| 307 | {
|
|---|
| 308 | case 0x0000:
|
|---|
| 309 | p++;
|
|---|
| 310 | break;
|
|---|
| 311 | case 0xffff:
|
|---|
| 312 | p += 2;
|
|---|
| 313 | break;
|
|---|
| 314 | default:
|
|---|
| 315 | p += lstrlenW( (LPCWSTR)p ) + 1;
|
|---|
| 316 | break;
|
|---|
| 317 | }
|
|---|
| 318 |
|
|---|
| 319 | /* Extract the caption */
|
|---|
| 320 | psInfo->proppage[index].pszText = (LPCWSTR)p;
|
|---|
| 321 | TRACE("Tab %d %s\n",index,debugstr_w((LPCWSTR)p));
|
|---|
| 322 | p += lstrlenW((LPCWSTR)p) + 1;
|
|---|
| 323 |
|
|---|
| 324 | if (dwFlags & PSP_USETITLE)
|
|---|
| 325 | {
|
|---|
| 326 | if ( !HIWORD( lppsp->pszTitle ) )
|
|---|
| 327 | {
|
|---|
| 328 | char szTitle[256];
|
|---|
| 329 |
|
|---|
| 330 | if ( !LoadStringA( lppsp->hInstance, (UINT) lppsp->pszTitle, szTitle, 256 ) )
|
|---|
| 331 | return FALSE;
|
|---|
| 332 |
|
|---|
| 333 | psInfo->proppage[index].pszText = HEAP_strdupAtoW( GetProcessHeap(),
|
|---|
| 334 | 0, szTitle );
|
|---|
| 335 | }
|
|---|
| 336 | else
|
|---|
| 337 | psInfo->proppage[index].pszText = HEAP_strdupAtoW(GetProcessHeap(),
|
|---|
| 338 | 0,
|
|---|
| 339 | lppsp->pszTitle);
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 | /*
|
|---|
| 343 | * Build the image list for icons
|
|---|
| 344 | */
|
|---|
| 345 | if ((dwFlags & PSP_USEHICON) || (dwFlags & PSP_USEICONID))
|
|---|
| 346 | {
|
|---|
| 347 | HICON hIcon;
|
|---|
| 348 | int icon_cx = GetSystemMetrics(SM_CXSMICON);
|
|---|
| 349 | int icon_cy = GetSystemMetrics(SM_CYSMICON);
|
|---|
| 350 |
|
|---|
| 351 | if (dwFlags & PSP_USEICONID)
|
|---|
| 352 | hIcon = LoadImageA(lppsp->hInstance, lppsp->pszIcon, IMAGE_ICON,
|
|---|
| 353 | icon_cx, icon_cy, LR_DEFAULTCOLOR);
|
|---|
| 354 | else
|
|---|
| 355 | hIcon = lppsp->hIcon;
|
|---|
| 356 |
|
|---|
| 357 | if ( hIcon )
|
|---|
| 358 | {
|
|---|
| 359 | if (psInfo->hImageList == 0 )
|
|---|
| 360 | psInfo->hImageList = ImageList_Create(icon_cx, icon_cy, ILC_COLOR, 1, 1);
|
|---|
| 361 |
|
|---|
| 362 | ImageList_AddIcon(psInfo->hImageList, hIcon);
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | }
|
|---|
| 366 |
|
|---|
| 367 | return TRUE;
|
|---|
| 368 | }
|
|---|
| 369 |
|
|---|
| 370 | /******************************************************************************
|
|---|
| 371 | * PROPSHEET_DoDialogBox
|
|---|
| 372 | *
|
|---|
| 373 | * Copied from windows/dialog.c:DIALOG_DoDialogBox
|
|---|
| 374 | */
|
|---|
| 375 | static INT PROPSHEET_DoDialogBox( HWND hwnd, HWND owner)
|
|---|
| 376 | {
|
|---|
| 377 | DIALOGINFO * dlgInfo;
|
|---|
| 378 | MSG msg;
|
|---|
| 379 | INT retval;
|
|---|
| 380 |
|
|---|
| 381 | dprintf(("PROPSHEET: PROPSHEET_DoDialogBox not implemented!!!"));
|
|---|
| 382 |
|
|---|
| 383 | #if 0 //CB: implement! sync with user32\win32dlg.cpp DoDialogBox method (not easy)
|
|---|
| 384 | // this functions isn't used so far
|
|---|
| 385 | /* Owner must be a top-level window */
|
|---|
| 386 | owner = WIN_GetTopParent( owner );
|
|---|
| 387 | if (!IsWindow(hwnd))) return -1;
|
|---|
| 388 | dlgInfo = (DIALOGINFO*)wndPtr->wExtra;
|
|---|
| 389 |
|
|---|
| 390 | if (!dlgInfo->flags & DF_END) /* was EndDialog called in WM_INITDIALOG ? */
|
|---|
| 391 | {
|
|---|
| 392 | EnableWindow( owner, FALSE );
|
|---|
| 393 | ShowWindow( hwnd, SW_SHOW );
|
|---|
| 394 | while (GetMessageA(&msg, 0, 0, 0))
|
|---|
| 395 | {
|
|---|
| 396 | if (!PROPSHEET_IsDialogMessage( hwnd, &msg))
|
|---|
| 397 | {
|
|---|
| 398 | TranslateMessage( &msg );
|
|---|
| 399 | DispatchMessageA( &msg );
|
|---|
| 400 | }
|
|---|
| 401 | if (dlgInfo->flags & DF_END) break;
|
|---|
| 402 | }
|
|---|
| 403 | EnableWindow( owner, TRUE );
|
|---|
| 404 | }
|
|---|
| 405 | retval = dlgInfo->dlgExtra->idResult;
|
|---|
| 406 | #endif
|
|---|
| 407 | DestroyWindow( hwnd );
|
|---|
| 408 | return retval;
|
|---|
| 409 | }
|
|---|
| 410 |
|
|---|
| 411 | /******************************************************************************
|
|---|
| 412 | * PROPSHEET_CreateDialog
|
|---|
| 413 | *
|
|---|
| 414 | * Creates the actual property sheet.
|
|---|
| 415 | */
|
|---|
| 416 |
|
|---|
| 417 | BOOL PROPSHEET_CreateDialog(PropSheetInfo* psInfo)
|
|---|
| 418 | {
|
|---|
| 419 | LRESULT ret;
|
|---|
| 420 | LPCVOID templ;
|
|---|
| 421 | LPVOID temp = 0;
|
|---|
| 422 | HRSRC hRes;
|
|---|
| 423 | DWORD resSize;
|
|---|
| 424 | WORD resID = IDD_PROPSHEET;
|
|---|
| 425 |
|
|---|
| 426 | if (psInfo->ppshheader->dwFlags & PSH_WIZARD)
|
|---|
| 427 | resID = IDD_WIZARD;
|
|---|
| 428 |
|
|---|
| 429 | if(!(hRes = FindResourceA(COMCTL32_hModule,
|
|---|
| 430 | MAKEINTRESOURCEA(resID),
|
|---|
| 431 | RT_DIALOGA)))
|
|---|
| 432 | return FALSE;
|
|---|
| 433 |
|
|---|
| 434 | if(!(templ = (LPVOID)LoadResource(COMCTL32_hModule, hRes)))
|
|---|
| 435 | return FALSE;
|
|---|
| 436 |
|
|---|
| 437 | /*
|
|---|
| 438 | * Make a copy of the dialog template.
|
|---|
| 439 | */
|
|---|
| 440 | resSize = SizeofResource(COMCTL32_hModule, hRes);
|
|---|
| 441 |
|
|---|
| 442 | temp = COMCTL32_Alloc(resSize);
|
|---|
| 443 |
|
|---|
| 444 | if (!temp)
|
|---|
| 445 | return FALSE;
|
|---|
| 446 |
|
|---|
| 447 | memcpy(temp, templ, resSize);
|
|---|
| 448 |
|
|---|
| 449 | if (psInfo->useCallback)
|
|---|
| 450 | (*(psInfo->ppshheader->pfnCallback))(0, PSCB_PRECREATE, (LPARAM)temp);
|
|---|
| 451 |
|
|---|
| 452 | if (psInfo->ppshheader->dwFlags & PSH_MODELESS)
|
|---|
| 453 | ret = CreateDialogIndirectParamA(psInfo->ppshheader->hInstance,
|
|---|
| 454 | (LPDLGTEMPLATEA) temp,
|
|---|
| 455 | psInfo->ppshheader->hwndParent,
|
|---|
| 456 | (DLGPROC) PROPSHEET_DialogProc,
|
|---|
| 457 | (LPARAM)psInfo);
|
|---|
| 458 | else
|
|---|
| 459 | ret = DialogBoxIndirectParamA(psInfo->ppshheader->hInstance,
|
|---|
| 460 | (LPDLGTEMPLATEA) temp,
|
|---|
| 461 | psInfo->ppshheader->hwndParent,
|
|---|
| 462 | (DLGPROC) PROPSHEET_DialogProc,
|
|---|
| 463 | (LPARAM)psInfo);
|
|---|
| 464 |
|
|---|
| 465 | COMCTL32_Free(temp);
|
|---|
| 466 |
|
|---|
| 467 | return ret;
|
|---|
| 468 | }
|
|---|
| 469 |
|
|---|
| 470 | /******************************************************************************
|
|---|
| 471 | * PROPSHEET_IsTooSmall
|
|---|
| 472 | *
|
|---|
| 473 | * Verify that the resource property sheet is big enough.
|
|---|
| 474 | */
|
|---|
| 475 | static BOOL PROPSHEET_IsTooSmall(HWND hwndDlg, PropSheetInfo* psInfo)
|
|---|
| 476 | {
|
|---|
| 477 | HWND hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|---|
| 478 | RECT rcOrigTab, rcPage;
|
|---|
| 479 |
|
|---|
| 480 | /*
|
|---|
| 481 | * Original tab size.
|
|---|
| 482 | */
|
|---|
| 483 | GetClientRect(hwndTabCtrl, &rcOrigTab);
|
|---|
| 484 | TRACE("orig tab %d %d %d %d\n", rcOrigTab.left, rcOrigTab.top,
|
|---|
| 485 | rcOrigTab.right, rcOrigTab.bottom);
|
|---|
| 486 |
|
|---|
| 487 | /*
|
|---|
| 488 | * Biggest page size.
|
|---|
| 489 | */
|
|---|
| 490 | rcPage.left = psInfo->x;
|
|---|
| 491 | rcPage.top = psInfo->y;
|
|---|
| 492 | rcPage.right = psInfo->width;
|
|---|
| 493 | rcPage.bottom = psInfo->height;
|
|---|
| 494 |
|
|---|
| 495 | MapDialogRect(hwndDlg, &rcPage);
|
|---|
| 496 | TRACE("biggest page %d %d %d %d (old %,%d)\n", rcPage.left, rcPage.top,
|
|---|
| 497 | rcPage.right, rcPage.bottom, rcOrigTab.right, rcOrigTab.bottom);
|
|---|
| 498 |
|
|---|
| 499 | if (rcPage.right > rcOrigTab.right)
|
|---|
| 500 | return TRUE;
|
|---|
| 501 |
|
|---|
| 502 | if (rcPage.bottom > rcOrigTab.bottom)
|
|---|
| 503 | return TRUE;
|
|---|
| 504 |
|
|---|
| 505 | return FALSE;
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 | /******************************************************************************
|
|---|
| 509 | * PROPSHEET_SizeMismatch
|
|---|
| 510 | *
|
|---|
| 511 | * Verify that the tab control and the "largest" property sheet page dlg. template
|
|---|
| 512 | * match in size.
|
|---|
| 513 | */
|
|---|
| 514 | static BOOL PROPSHEET_SizeMismatch(HWND hwndDlg, PropSheetInfo* psInfo)
|
|---|
| 515 | {
|
|---|
| 516 | HWND hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|---|
| 517 | RECT rcOrigTab, rcPage;
|
|---|
| 518 |
|
|---|
| 519 | /*
|
|---|
| 520 | * Original tab size.
|
|---|
| 521 | */
|
|---|
| 522 | GetClientRect(hwndTabCtrl, &rcOrigTab);
|
|---|
| 523 | TRACE("orig tab %d %d %d %d\n", rcOrigTab.left, rcOrigTab.top,
|
|---|
| 524 | rcOrigTab.right, rcOrigTab.bottom);
|
|---|
| 525 |
|
|---|
| 526 | /*
|
|---|
| 527 | * Biggest page size.
|
|---|
| 528 | */
|
|---|
| 529 | rcPage.left = psInfo->x;
|
|---|
| 530 | rcPage.top = psInfo->y;
|
|---|
| 531 | rcPage.right = psInfo->width;
|
|---|
| 532 | rcPage.bottom = psInfo->height;
|
|---|
| 533 |
|
|---|
| 534 | MapDialogRect(hwndDlg, &rcPage);
|
|---|
| 535 | TRACE("biggest page %d %d %d %d (old %d,%d %d,%d,)\n", rcPage.left, rcPage.top,
|
|---|
| 536 | rcPage.right, rcPage.bottom, rcOrigTab.left, rcOrigTab.top, rcOrigTab.right, rcOrigTab.bottom);
|
|---|
| 537 |
|
|---|
| 538 | if ( (rcPage.right - rcPage.left) != (rcOrigTab.right - rcOrigTab.left) )
|
|---|
| 539 | return TRUE;
|
|---|
| 540 | if ( (rcPage.bottom - rcPage.top) != (rcOrigTab.bottom - rcOrigTab.top) )
|
|---|
| 541 | return TRUE;
|
|---|
| 542 |
|
|---|
| 543 | return FALSE;
|
|---|
| 544 | }
|
|---|
| 545 |
|
|---|
| 546 | /******************************************************************************
|
|---|
| 547 | * PROPSHEET_IsTooSmallWizard
|
|---|
| 548 | *
|
|---|
| 549 | * Verify that the default property sheet is big enough.
|
|---|
| 550 | */
|
|---|
| 551 | static BOOL PROPSHEET_IsTooSmallWizard(HWND hwndDlg, PropSheetInfo* psInfo)
|
|---|
| 552 | {
|
|---|
| 553 | RECT rcSheetRect, rcPage, rcLine, rcSheetClient;
|
|---|
| 554 | HWND hwndLine = GetDlgItem(hwndDlg, IDC_SUNKEN_LINE);
|
|---|
| 555 | PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndDlg,psInfo);
|
|---|
| 556 |
|
|---|
| 557 | GetClientRect(hwndDlg, &rcSheetClient);
|
|---|
| 558 | GetWindowRect(hwndDlg, &rcSheetRect);
|
|---|
| 559 | GetWindowRect(hwndLine, &rcLine);
|
|---|
| 560 |
|
|---|
| 561 | /* Remove the space below the sunken line */
|
|---|
| 562 | rcSheetClient.bottom -= (rcSheetRect.bottom - rcLine.top);
|
|---|
| 563 |
|
|---|
| 564 | /* Remove the buffer zone all around the edge */
|
|---|
| 565 | rcSheetClient.bottom -= (padding.y * 2);
|
|---|
| 566 | rcSheetClient.right -= (padding.x * 2);
|
|---|
| 567 |
|
|---|
| 568 | /*
|
|---|
| 569 | * Biggest page size.
|
|---|
| 570 | */
|
|---|
| 571 | rcPage.left = psInfo->x;
|
|---|
| 572 | rcPage.top = psInfo->y;
|
|---|
| 573 | rcPage.right = psInfo->width;
|
|---|
| 574 | rcPage.bottom = psInfo->height;
|
|---|
| 575 |
|
|---|
| 576 | MapDialogRect(hwndDlg, &rcPage);
|
|---|
| 577 | TRACE("biggest page %d %d %d %d (old %d,%d)\n", rcPage.left, rcPage.top,
|
|---|
| 578 | rcPage.right, rcPage.bottom, rcSheetClient.right, rcSheetClient.bottom);
|
|---|
| 579 |
|
|---|
| 580 | if (rcPage.right > rcSheetClient.right)
|
|---|
| 581 | return TRUE;
|
|---|
| 582 |
|
|---|
| 583 | if (rcPage.bottom > rcSheetClient.bottom)
|
|---|
| 584 | return TRUE;
|
|---|
| 585 |
|
|---|
| 586 | return FALSE;
|
|---|
| 587 | }
|
|---|
| 588 |
|
|---|
| 589 | /******************************************************************************
|
|---|
| 590 | * PROPSHEET_AdjustSize
|
|---|
| 591 | *
|
|---|
| 592 | * Resizes the property sheet and the tab control to fit the largest page.
|
|---|
| 593 | */
|
|---|
| 594 | static BOOL PROPSHEET_AdjustSize(HWND hwndDlg, PropSheetInfo* psInfo)
|
|---|
| 595 | {
|
|---|
| 596 | HWND hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|---|
| 597 | HWND hwndButton = GetDlgItem(hwndDlg, IDOK);
|
|---|
| 598 | RECT rc;
|
|---|
| 599 | int tabOffsetX, tabOffsetY, buttonHeight;
|
|---|
| 600 | PADDING_INFO padding = PROPSHEET_GetPaddingInfo(hwndDlg);
|
|---|
| 601 |
|
|---|
| 602 | /* Get the height of buttons */
|
|---|
| 603 | GetClientRect(hwndButton, &rc);
|
|---|
| 604 | buttonHeight = rc.bottom;
|
|---|
| 605 |
|
|---|
| 606 | /*
|
|---|
| 607 | * Biggest page size.
|
|---|
| 608 | */
|
|---|
| 609 | rc.left = psInfo->x;
|
|---|
| 610 | rc.top = psInfo->y;
|
|---|
| 611 | rc.right = psInfo->width;
|
|---|
| 612 | rc.bottom = psInfo->height;
|
|---|
| 613 |
|
|---|
| 614 | MapDialogRect(hwndDlg, &rc);
|
|---|
| 615 |
|
|---|
| 616 | /*
|
|---|
| 617 | * Resize the tab control.
|
|---|
| 618 | */
|
|---|
| 619 | SendMessageA(hwndTabCtrl, TCM_ADJUSTRECT, TRUE, (LPARAM)&rc);
|
|---|
| 620 |
|
|---|
| 621 | tabOffsetX = -(rc.left);
|
|---|
| 622 | tabOffsetY = -(rc.top);
|
|---|
| 623 |
|
|---|
| 624 | rc.right -= rc.left;
|
|---|
| 625 | rc.bottom -= rc.top;
|
|---|
| 626 | SetWindowPos(hwndTabCtrl, 0, 0, 0, rc.right, rc.bottom,
|
|---|
| 627 | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 628 |
|
|---|
| 629 | GetClientRect(hwndTabCtrl, &rc);
|
|---|
| 630 |
|
|---|
| 631 | TRACE("tab client rc %d %d %d %d\n",
|
|---|
| 632 | rc.left, rc.top, rc.right, rc.bottom);
|
|---|
| 633 |
|
|---|
| 634 | rc.right += ((padding.x * 2) + tabOffsetX);
|
|---|
| 635 | rc.bottom += (buttonHeight + (3 * padding.y) + tabOffsetY);
|
|---|
| 636 |
|
|---|
| 637 | /*
|
|---|
| 638 | * Resize the property sheet.
|
|---|
| 639 | */
|
|---|
| 640 | SetWindowPos(hwndDlg, 0, 0, 0, rc.right, rc.bottom,
|
|---|
| 641 | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 642 |
|
|---|
| 643 | return TRUE;
|
|---|
| 644 | }
|
|---|
| 645 | /******************************************************************************
|
|---|
| 646 | * PROPSHEET_AdjustSizeWizard
|
|---|
| 647 | *
|
|---|
| 648 | * Resizes the property sheet to fit the largest page.
|
|---|
| 649 | */
|
|---|
| 650 | static BOOL PROPSHEET_AdjustSizeWizard(HWND hwndDlg, PropSheetInfo* psInfo)
|
|---|
| 651 | {
|
|---|
| 652 | HWND hwndButton = GetDlgItem(hwndDlg, IDCANCEL);
|
|---|
| 653 | HWND hwndLine = GetDlgItem(hwndDlg, IDC_SUNKEN_LINE);
|
|---|
| 654 | RECT rc;
|
|---|
| 655 | int buttonHeight, lineHeight;
|
|---|
| 656 | PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndDlg,psInfo);
|
|---|
| 657 |
|
|---|
| 658 | dprintf(("PROPSHEET_AdjustSizeWizard %x", hwndDlg));
|
|---|
| 659 |
|
|---|
| 660 | /* Get the height of buttons */
|
|---|
| 661 | GetClientRect(hwndButton, &rc);
|
|---|
| 662 | buttonHeight = rc.bottom;
|
|---|
| 663 |
|
|---|
| 664 | GetClientRect(hwndLine, &rc);
|
|---|
| 665 | lineHeight = rc.bottom;
|
|---|
| 666 |
|
|---|
| 667 | /*
|
|---|
| 668 | * Biggest page size.
|
|---|
| 669 | */
|
|---|
| 670 | rc.left = psInfo->x;
|
|---|
| 671 | rc.top = psInfo->y;
|
|---|
| 672 | rc.right = psInfo->width;
|
|---|
| 673 | rc.bottom = psInfo->height;
|
|---|
| 674 |
|
|---|
| 675 | MapDialogRect(hwndDlg, &rc);
|
|---|
| 676 |
|
|---|
| 677 | TRACE("Biggest page %d %d %d %d\n", rc.left, rc.top, rc.right, rc.bottom);
|
|---|
| 678 |
|
|---|
| 679 | /* Make room */
|
|---|
| 680 | rc.right += (padding.x * 2);
|
|---|
| 681 | rc.bottom += (buttonHeight + (5 * padding.y) + lineHeight);
|
|---|
| 682 |
|
|---|
| 683 | /*
|
|---|
| 684 | * Resize the property sheet.
|
|---|
| 685 | */
|
|---|
| 686 | SetWindowPos(hwndDlg, 0, 0, 0, rc.right, rc.bottom,
|
|---|
| 687 | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 688 |
|
|---|
| 689 | dprintf(("PROPSHEET_AdjustSizeWizard %x DONE", hwndDlg));
|
|---|
| 690 | return TRUE;
|
|---|
| 691 | }
|
|---|
| 692 |
|
|---|
| 693 |
|
|---|
| 694 | /******************************************************************************
|
|---|
| 695 | * PROPSHEET_AdjustButtons
|
|---|
| 696 | *
|
|---|
| 697 | * Adjusts the buttons' positions.
|
|---|
| 698 | */
|
|---|
| 699 | static BOOL PROPSHEET_AdjustButtons(HWND hwndParent, PropSheetInfo* psInfo)
|
|---|
| 700 | {
|
|---|
| 701 | HWND hwndButton = GetDlgItem(hwndParent, IDOK);
|
|---|
| 702 | RECT rcSheet;
|
|---|
| 703 | int x, y;
|
|---|
| 704 | int num_buttons = 2;
|
|---|
| 705 | int buttonWidth, buttonHeight;
|
|---|
| 706 | PADDING_INFO padding = PROPSHEET_GetPaddingInfo(hwndParent);
|
|---|
| 707 |
|
|---|
| 708 | if (psInfo->hasApply)
|
|---|
| 709 | num_buttons++;
|
|---|
| 710 |
|
|---|
| 711 | if (psInfo->hasHelp)
|
|---|
| 712 | num_buttons++;
|
|---|
| 713 |
|
|---|
| 714 | /*
|
|---|
| 715 | * Obtain the size of the buttons.
|
|---|
| 716 | */
|
|---|
| 717 | GetClientRect(hwndButton, &rcSheet);
|
|---|
| 718 | buttonWidth = rcSheet.right;
|
|---|
| 719 | buttonHeight = rcSheet.bottom;
|
|---|
| 720 |
|
|---|
| 721 | /*
|
|---|
| 722 | * Get the size of the property sheet.
|
|---|
| 723 | */
|
|---|
| 724 | GetClientRect(hwndParent, &rcSheet);
|
|---|
| 725 |
|
|---|
| 726 | /*
|
|---|
| 727 | * All buttons will be at this y coordinate.
|
|---|
| 728 | */
|
|---|
| 729 | y = rcSheet.bottom - (padding.y + buttonHeight);
|
|---|
| 730 |
|
|---|
| 731 | /*
|
|---|
| 732 | * Position OK button.
|
|---|
| 733 | */
|
|---|
| 734 | hwndButton = GetDlgItem(hwndParent, IDOK);
|
|---|
| 735 |
|
|---|
| 736 | x = rcSheet.right - ((padding.x + buttonWidth) * num_buttons);
|
|---|
| 737 |
|
|---|
| 738 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|---|
| 739 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 740 |
|
|---|
| 741 | /*
|
|---|
| 742 | * Position Cancel button.
|
|---|
| 743 | */
|
|---|
| 744 | hwndButton = GetDlgItem(hwndParent, IDCANCEL);
|
|---|
| 745 |
|
|---|
| 746 | x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 1));
|
|---|
| 747 |
|
|---|
| 748 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|---|
| 749 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 750 |
|
|---|
| 751 | /*
|
|---|
| 752 | * Position Apply button.
|
|---|
| 753 | */
|
|---|
| 754 | hwndButton = GetDlgItem(hwndParent, IDC_APPLY_BUTTON);
|
|---|
| 755 |
|
|---|
| 756 | if (psInfo->hasApply)
|
|---|
| 757 | {
|
|---|
| 758 | if (psInfo->hasHelp)
|
|---|
| 759 | x = rcSheet.right - ((padding.x + buttonWidth) * 2);
|
|---|
| 760 | else
|
|---|
| 761 | x = rcSheet.right - (padding.x + buttonWidth);
|
|---|
| 762 |
|
|---|
| 763 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|---|
| 764 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 765 |
|
|---|
| 766 | EnableWindow(hwndButton, FALSE);
|
|---|
| 767 | }
|
|---|
| 768 | else
|
|---|
| 769 | ShowWindow(hwndButton, SW_HIDE);
|
|---|
| 770 |
|
|---|
| 771 | /*
|
|---|
| 772 | * Position Help button.
|
|---|
| 773 | */
|
|---|
| 774 | hwndButton = GetDlgItem(hwndParent, IDHELP);
|
|---|
| 775 |
|
|---|
| 776 | if (psInfo->hasHelp)
|
|---|
| 777 | {
|
|---|
| 778 | x = rcSheet.right - (padding.x + buttonWidth);
|
|---|
| 779 |
|
|---|
| 780 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|---|
| 781 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 782 | }
|
|---|
| 783 | else
|
|---|
| 784 | ShowWindow(hwndButton, SW_HIDE);
|
|---|
| 785 |
|
|---|
| 786 | return TRUE;
|
|---|
| 787 | }
|
|---|
| 788 |
|
|---|
| 789 | /******************************************************************************
|
|---|
| 790 | * PROPSHEET_AdjustButtonsWizard
|
|---|
| 791 | *
|
|---|
| 792 | * Adjusts the buttons' positions.
|
|---|
| 793 | */
|
|---|
| 794 | static BOOL PROPSHEET_AdjustButtonsWizard(HWND hwndParent,
|
|---|
| 795 | PropSheetInfo* psInfo)
|
|---|
| 796 | {
|
|---|
| 797 | HWND hwndButton = GetDlgItem(hwndParent, IDCANCEL);
|
|---|
| 798 | HWND hwndLine = GetDlgItem(hwndParent, IDC_SUNKEN_LINE);
|
|---|
| 799 | RECT rcSheet;
|
|---|
| 800 | int x, y;
|
|---|
| 801 | int num_buttons = 3;
|
|---|
| 802 | int buttonWidth, buttonHeight, lineHeight, lineWidth;
|
|---|
| 803 | PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndParent,psInfo);
|
|---|
| 804 |
|
|---|
| 805 | if (psInfo->hasHelp)
|
|---|
| 806 | num_buttons++;
|
|---|
| 807 |
|
|---|
| 808 | /*
|
|---|
| 809 | * Obtain the size of the buttons.
|
|---|
| 810 | */
|
|---|
| 811 | GetClientRect(hwndButton, &rcSheet);
|
|---|
| 812 | buttonWidth = rcSheet.right;
|
|---|
| 813 | buttonHeight = rcSheet.bottom;
|
|---|
| 814 |
|
|---|
| 815 | GetClientRect(hwndLine, &rcSheet);
|
|---|
| 816 | lineHeight = rcSheet.bottom;
|
|---|
| 817 |
|
|---|
| 818 | /*
|
|---|
| 819 | * Get the size of the property sheet.
|
|---|
| 820 | */
|
|---|
| 821 | GetClientRect(hwndParent, &rcSheet);
|
|---|
| 822 |
|
|---|
| 823 | /*
|
|---|
| 824 | * All buttons will be at this y coordinate.
|
|---|
| 825 | */
|
|---|
| 826 | y = rcSheet.bottom - (padding.y + buttonHeight);
|
|---|
| 827 |
|
|---|
| 828 | /*
|
|---|
| 829 | * Position the Next and the Finish buttons.
|
|---|
| 830 | */
|
|---|
| 831 | hwndButton = GetDlgItem(hwndParent, IDC_NEXT_BUTTON);
|
|---|
| 832 |
|
|---|
| 833 | x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 1));
|
|---|
| 834 |
|
|---|
| 835 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|---|
| 836 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 837 |
|
|---|
| 838 | hwndButton = GetDlgItem(hwndParent, IDC_FINISH_BUTTON);
|
|---|
| 839 |
|
|---|
| 840 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|---|
| 841 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 842 |
|
|---|
| 843 | ShowWindow(hwndButton, SW_HIDE);
|
|---|
| 844 |
|
|---|
| 845 | /*
|
|---|
| 846 | * Position the Back button.
|
|---|
| 847 | */
|
|---|
| 848 | hwndButton = GetDlgItem(hwndParent, IDC_BACK_BUTTON);
|
|---|
| 849 |
|
|---|
| 850 | x -= buttonWidth;
|
|---|
| 851 |
|
|---|
| 852 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|---|
| 853 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 854 |
|
|---|
| 855 | /*
|
|---|
| 856 | * Position the Cancel button.
|
|---|
| 857 | */
|
|---|
| 858 | hwndButton = GetDlgItem(hwndParent, IDCANCEL);
|
|---|
| 859 |
|
|---|
| 860 | x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 2));
|
|---|
| 861 |
|
|---|
| 862 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|---|
| 863 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 864 |
|
|---|
| 865 | /*
|
|---|
| 866 | * Position Help button.
|
|---|
| 867 | */
|
|---|
| 868 | hwndButton = GetDlgItem(hwndParent, IDHELP);
|
|---|
| 869 |
|
|---|
| 870 | if (psInfo->hasHelp)
|
|---|
| 871 | {
|
|---|
| 872 | x = rcSheet.right - (padding.x + buttonWidth);
|
|---|
| 873 |
|
|---|
| 874 | SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|---|
| 875 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 876 | }
|
|---|
| 877 | else
|
|---|
| 878 | ShowWindow(hwndButton, SW_HIDE);
|
|---|
| 879 |
|
|---|
| 880 | /*
|
|---|
| 881 | * Position and resize the sunken line.
|
|---|
| 882 | */
|
|---|
| 883 | x = padding.x;
|
|---|
| 884 | y = rcSheet.bottom - ((padding.y * 2) + buttonHeight + lineHeight);
|
|---|
| 885 |
|
|---|
| 886 | GetClientRect(hwndParent, &rcSheet);
|
|---|
| 887 | lineWidth = rcSheet.right - (padding.x * 2);
|
|---|
| 888 |
|
|---|
| 889 | SetWindowPos(hwndLine, 0, x, y, lineWidth, 2,
|
|---|
| 890 | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 891 |
|
|---|
| 892 | return TRUE;
|
|---|
| 893 | }
|
|---|
| 894 |
|
|---|
| 895 | /******************************************************************************
|
|---|
| 896 | * PROPSHEET_GetPaddingInfo
|
|---|
| 897 | *
|
|---|
| 898 | * Returns the layout information.
|
|---|
| 899 | */
|
|---|
| 900 | static PADDING_INFO PROPSHEET_GetPaddingInfo(HWND hwndDlg)
|
|---|
| 901 | {
|
|---|
| 902 | HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|---|
| 903 | RECT rcTab;
|
|---|
| 904 | POINT tl;
|
|---|
| 905 | PADDING_INFO padding;
|
|---|
| 906 |
|
|---|
| 907 | GetWindowRect(hwndTab, &rcTab);
|
|---|
| 908 |
|
|---|
| 909 | tl.x = rcTab.left;
|
|---|
| 910 | tl.y = rcTab.top;
|
|---|
| 911 |
|
|---|
| 912 | ScreenToClient(hwndDlg, &tl);
|
|---|
| 913 |
|
|---|
| 914 | padding.x = tl.x;
|
|---|
| 915 | padding.y = tl.y;
|
|---|
| 916 |
|
|---|
| 917 | return padding;
|
|---|
| 918 | }
|
|---|
| 919 |
|
|---|
| 920 | /******************************************************************************
|
|---|
| 921 | * PROPSHEET_GetPaddingInfoWizard
|
|---|
| 922 | *
|
|---|
| 923 | * Returns the layout information.
|
|---|
| 924 | * Vertical spacing is the distance between the line and the buttons.
|
|---|
| 925 | * Do NOT use the Help button to gather padding information when it isn't mapped
|
|---|
| 926 | * (PSH_HASHELP), as app writers aren't forced to supply correct coordinates
|
|---|
| 927 | * for it in this case !
|
|---|
| 928 | * FIXME: I'm not sure about any other coordinate problems with these evil
|
|---|
| 929 | * buttons. Fix it in case additional problems appear or maybe calculate
|
|---|
| 930 | * a padding in a completely different way, as this is somewhat messy.
|
|---|
| 931 | */
|
|---|
| 932 | static PADDING_INFO PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg, PropSheetInfo* psInfo)
|
|---|
| 933 | {
|
|---|
| 934 | PADDING_INFO padding;
|
|---|
| 935 | RECT rc;
|
|---|
| 936 | HWND hwndControl;
|
|---|
| 937 | INT idButton;
|
|---|
| 938 | POINT ptButton, ptLine;
|
|---|
| 939 |
|
|---|
| 940 | TRACE("\n");
|
|---|
| 941 | if (psInfo->hasHelp)
|
|---|
| 942 | {
|
|---|
| 943 | idButton = IDHELP;
|
|---|
| 944 | }
|
|---|
| 945 | else
|
|---|
| 946 | {
|
|---|
| 947 | if (psInfo->ppshheader->dwFlags & PSH_WIZARD)
|
|---|
| 948 | {
|
|---|
| 949 | idButton = IDC_NEXT_BUTTON;
|
|---|
| 950 | }
|
|---|
| 951 | else
|
|---|
| 952 | {
|
|---|
| 953 | /* hopefully this is ok */
|
|---|
| 954 | idButton = IDCANCEL;
|
|---|
| 955 | }
|
|---|
| 956 | }
|
|---|
| 957 |
|
|---|
| 958 | hwndControl = GetDlgItem(hwndDlg, idButton);
|
|---|
| 959 | GetWindowRect(hwndControl, &rc);
|
|---|
| 960 |
|
|---|
| 961 | ptButton.x = rc.left;
|
|---|
| 962 | ptButton.y = rc.top;
|
|---|
| 963 |
|
|---|
| 964 | ScreenToClient(hwndDlg, &ptButton);
|
|---|
| 965 |
|
|---|
| 966 | /* Line */
|
|---|
| 967 | hwndControl = GetDlgItem(hwndDlg, IDC_SUNKEN_LINE);
|
|---|
| 968 | GetWindowRect(hwndControl, &rc);
|
|---|
| 969 |
|
|---|
| 970 | ptLine.x = 0;
|
|---|
| 971 | ptLine.y = rc.bottom;
|
|---|
| 972 |
|
|---|
| 973 | ScreenToClient(hwndDlg, &ptLine);
|
|---|
| 974 |
|
|---|
| 975 | padding.y = ptButton.y - ptLine.y;
|
|---|
| 976 |
|
|---|
| 977 | if (padding.y < 0)
|
|---|
| 978 | ERR("padding negative ! Please report this !\n");
|
|---|
| 979 |
|
|---|
| 980 | /* this is most probably not correct, but the best we have now */
|
|---|
| 981 | padding.x = padding.y;
|
|---|
| 982 |
|
|---|
| 983 | return padding;
|
|---|
| 984 | }
|
|---|
| 985 |
|
|---|
| 986 | /******************************************************************************
|
|---|
| 987 | * PROPSHEET_CreateTabControl
|
|---|
| 988 | *
|
|---|
| 989 | * Insert the tabs in the tab control.
|
|---|
| 990 | */
|
|---|
| 991 | static BOOL PROPSHEET_CreateTabControl(HWND hwndParent,
|
|---|
| 992 | PropSheetInfo * psInfo)
|
|---|
| 993 | {
|
|---|
| 994 | HWND hwndTabCtrl = GetDlgItem(hwndParent, IDC_TABCONTROL);
|
|---|
| 995 | TCITEMA item;
|
|---|
| 996 | int i, nTabs;
|
|---|
| 997 | int iImage = 0;
|
|---|
| 998 | char tabtext[MAX_TABTEXT_LENGTH] = "Tab text";
|
|---|
| 999 |
|
|---|
| 1000 | item.mask = TCIF_TEXT;
|
|---|
| 1001 | item.pszText = tabtext;
|
|---|
| 1002 | item.cchTextMax = MAX_TABTEXT_LENGTH;
|
|---|
| 1003 |
|
|---|
| 1004 | nTabs = psInfo->ppshheader->nPages;
|
|---|
| 1005 |
|
|---|
| 1006 | /*
|
|---|
| 1007 | * Set the image list for icons.
|
|---|
| 1008 | */
|
|---|
| 1009 | if (psInfo->hImageList)
|
|---|
| 1010 | {
|
|---|
| 1011 | SendMessageA(hwndTabCtrl, TCM_SETIMAGELIST, 0, (LPARAM)psInfo->hImageList);
|
|---|
| 1012 | }
|
|---|
| 1013 |
|
|---|
| 1014 | for (i = 0; i < nTabs; i++)
|
|---|
| 1015 | {
|
|---|
| 1016 | if ( psInfo->proppage[i].hasIcon )
|
|---|
| 1017 | {
|
|---|
| 1018 | item.mask |= TCIF_IMAGE;
|
|---|
| 1019 | item.iImage = iImage++;
|
|---|
| 1020 | }
|
|---|
| 1021 | else
|
|---|
| 1022 | {
|
|---|
| 1023 | item.mask &= ~TCIF_IMAGE;
|
|---|
| 1024 | }
|
|---|
| 1025 |
|
|---|
| 1026 | WideCharToMultiByte(CP_ACP, 0,
|
|---|
| 1027 | (LPCWSTR)psInfo->proppage[i].pszText,
|
|---|
| 1028 | -1, tabtext, MAX_TABTEXT_LENGTH, NULL, NULL);
|
|---|
| 1029 |
|
|---|
| 1030 | SendMessageA(hwndTabCtrl, TCM_INSERTITEMA, (WPARAM)i, (LPARAM)&item);
|
|---|
| 1031 | }
|
|---|
| 1032 |
|
|---|
| 1033 | return TRUE;
|
|---|
| 1034 | }
|
|---|
| 1035 |
|
|---|
| 1036 | /******************************************************************************
|
|---|
| 1037 | * PROPSHEET_CreatePage
|
|---|
| 1038 | *
|
|---|
| 1039 | * Creates a page.
|
|---|
| 1040 | */
|
|---|
| 1041 | static int PROPSHEET_CreatePage(HWND hwndParent,
|
|---|
| 1042 | int index,
|
|---|
| 1043 | const PropSheetInfo * psInfo,
|
|---|
| 1044 | LPPROPSHEETPAGEA ppshpage)
|
|---|
| 1045 | {
|
|---|
| 1046 | DLGTEMPLATE* pTemplate;
|
|---|
| 1047 | HWND hwndPage;
|
|---|
| 1048 | RECT rc;
|
|---|
| 1049 | PropPageInfo* ppInfo = psInfo->proppage;
|
|---|
| 1050 | PADDING_INFO padding;
|
|---|
| 1051 | UINT pageWidth,pageHeight;
|
|---|
| 1052 | DWORD resSize;
|
|---|
| 1053 | LPVOID temp = NULL;
|
|---|
| 1054 |
|
|---|
| 1055 | TRACE("index %d\n", index);
|
|---|
| 1056 |
|
|---|
| 1057 | #ifdef __WIN32OS2__
|
|---|
| 1058 | //AH: Check if ppshpage is valid
|
|---|
| 1059 | if (ppshpage == NULL)
|
|---|
| 1060 | {
|
|---|
| 1061 | dprintf(("COMCTL32:PROPSHEET_CreatePage: ERROR!!! ppshpage == NULL!!!\n"));
|
|---|
| 1062 | return FALSE;
|
|---|
| 1063 | }
|
|---|
| 1064 | #endif
|
|---|
| 1065 |
|
|---|
| 1066 | if (ppshpage->dwFlags & PSP_DLGINDIRECT)
|
|---|
| 1067 | pTemplate = (DLGTEMPLATE*)ppshpage->pResource;
|
|---|
| 1068 | else
|
|---|
| 1069 | {
|
|---|
| 1070 | HRSRC hResource;
|
|---|
| 1071 | HANDLE hTemplate;
|
|---|
| 1072 |
|
|---|
| 1073 | hResource = FindResourceA(ppshpage->hInstance,
|
|---|
| 1074 | ppshpage->pszTemplate,
|
|---|
| 1075 | RT_DIALOGA);
|
|---|
| 1076 | if(!hResource)
|
|---|
| 1077 | return FALSE;
|
|---|
| 1078 |
|
|---|
| 1079 | resSize = SizeofResource(ppshpage->hInstance, hResource);
|
|---|
| 1080 |
|
|---|
| 1081 | hTemplate = LoadResource(ppshpage->hInstance, hResource);
|
|---|
| 1082 | if(!hTemplate)
|
|---|
| 1083 | return FALSE;
|
|---|
| 1084 |
|
|---|
| 1085 | pTemplate = (LPDLGTEMPLATEA)LockResource(hTemplate);
|
|---|
| 1086 | /*
|
|---|
| 1087 | * Make a copy of the dialog template to make it writable
|
|---|
| 1088 | */
|
|---|
| 1089 | temp = COMCTL32_Alloc(resSize);
|
|---|
| 1090 | if (!temp)
|
|---|
| 1091 | return FALSE;
|
|---|
| 1092 |
|
|---|
| 1093 | memcpy(temp, pTemplate, resSize);
|
|---|
| 1094 | pTemplate = (DLGTEMPLATE*)temp;
|
|---|
| 1095 | }
|
|---|
| 1096 |
|
|---|
| 1097 | if (((MyDLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF)
|
|---|
| 1098 | {
|
|---|
| 1099 | ((MyDLGTEMPLATEEX*)pTemplate)->style |= WS_CHILD | DS_CONTROL;
|
|---|
| 1100 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~DS_MODALFRAME;
|
|---|
| 1101 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_CAPTION;
|
|---|
| 1102 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_SYSMENU;
|
|---|
| 1103 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_POPUP;
|
|---|
| 1104 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_DISABLED;
|
|---|
| 1105 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_VISIBLE;
|
|---|
| 1106 | #ifdef __WIN32OS2__
|
|---|
| 1107 | ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_THICKFRAME;
|
|---|
| 1108 | #endif
|
|---|
| 1109 | }
|
|---|
| 1110 | else
|
|---|
| 1111 | {
|
|---|
| 1112 | pTemplate->style |= WS_CHILD | DS_CONTROL;
|
|---|
| 1113 | pTemplate->style &= ~DS_MODALFRAME;
|
|---|
| 1114 | pTemplate->style &= ~WS_CAPTION;
|
|---|
| 1115 | pTemplate->style &= ~WS_SYSMENU;
|
|---|
| 1116 | pTemplate->style &= ~WS_POPUP;
|
|---|
| 1117 | pTemplate->style &= ~WS_DISABLED;
|
|---|
| 1118 | pTemplate->style &= ~WS_VISIBLE;
|
|---|
| 1119 | #ifdef __WIN32OS2__
|
|---|
| 1120 | pTemplate->style &= ~WS_THICKFRAME;
|
|---|
| 1121 | #endif
|
|---|
| 1122 | }
|
|---|
| 1123 |
|
|---|
| 1124 | if (psInfo->proppage[index].useCallback)
|
|---|
| 1125 | (*(ppshpage->pfnCallback))(hwndParent,
|
|---|
| 1126 | PSPCB_CREATE,
|
|---|
| 1127 | (LPPROPSHEETPAGEA)ppshpage);
|
|---|
| 1128 |
|
|---|
| 1129 | hwndPage = CreateDialogIndirectParamA(ppshpage->hInstance,
|
|---|
| 1130 | pTemplate,
|
|---|
| 1131 | hwndParent,
|
|---|
| 1132 | ppshpage->pfnDlgProc,
|
|---|
| 1133 | (LPARAM)ppshpage);
|
|---|
| 1134 | /* Free a no more needed copy */
|
|---|
| 1135 | if(temp)
|
|---|
| 1136 | COMCTL32_Free(temp);
|
|---|
| 1137 |
|
|---|
| 1138 | ppInfo[index].hwndPage = hwndPage;
|
|---|
| 1139 |
|
|---|
| 1140 | rc.left = psInfo->x;
|
|---|
| 1141 | rc.top = psInfo->y;
|
|---|
| 1142 | rc.right = psInfo->width;
|
|---|
| 1143 | rc.bottom = psInfo->height;
|
|---|
| 1144 |
|
|---|
| 1145 | MapDialogRect(hwndParent, &rc);
|
|---|
| 1146 |
|
|---|
| 1147 | pageWidth = rc.right - rc.left;
|
|---|
| 1148 | pageHeight = rc.bottom - rc.top;
|
|---|
| 1149 |
|
|---|
| 1150 | if (psInfo->ppshheader->dwFlags & PSH_WIZARD)
|
|---|
| 1151 | padding = PROPSHEET_GetPaddingInfoWizard(hwndParent, (PropSheetInfo* )psInfo);
|
|---|
| 1152 | else
|
|---|
| 1153 | {
|
|---|
| 1154 | /*
|
|---|
| 1155 | * Ask the Tab control to fit this page in.
|
|---|
| 1156 | */
|
|---|
| 1157 |
|
|---|
| 1158 | HWND hwndTabCtrl = GetDlgItem(hwndParent, IDC_TABCONTROL);
|
|---|
| 1159 | SendMessageA(hwndTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM)&rc);
|
|---|
| 1160 | padding = PROPSHEET_GetPaddingInfo(hwndParent);
|
|---|
| 1161 | }
|
|---|
| 1162 |
|
|---|
| 1163 | #ifdef __WIN32OS2__
|
|---|
| 1164 | //HACK alert!
|
|---|
| 1165 | //SvL: CVP multiplies y padding by two to calculate the new height
|
|---|
| 1166 | //I have no idea if this is always correct
|
|---|
| 1167 | //This actually does make sense. The property page will get centered instead
|
|---|
| 1168 | //of being slammed in the lower right corner
|
|---|
| 1169 | SetWindowPos(hwndPage, HWND_TOP,
|
|---|
| 1170 | rc.left + padding.x/2,
|
|---|
| 1171 | rc.top + padding.y/2,
|
|---|
| 1172 | pageWidth, pageHeight, 0);
|
|---|
| 1173 | #else
|
|---|
| 1174 | SetWindowPos(hwndPage, HWND_TOP,
|
|---|
| 1175 | rc.left + padding.x,
|
|---|
| 1176 | rc.top + padding.y,
|
|---|
| 1177 | pageWidth, pageHeight, 0);
|
|---|
| 1178 | #endif
|
|---|
| 1179 |
|
|---|
| 1180 | return TRUE;
|
|---|
| 1181 | }
|
|---|
| 1182 |
|
|---|
| 1183 | /******************************************************************************
|
|---|
| 1184 | * PROPSHEET_ShowPage
|
|---|
| 1185 | *
|
|---|
| 1186 | * Displays or creates the specified page.
|
|---|
| 1187 | *
|
|---|
| 1188 | * Returns: 1 - specified page is activated.
|
|---|
| 1189 | * 0 - function fails
|
|---|
| 1190 | * -1 - some other page is activated
|
|---|
| 1191 | */
|
|---|
| 1192 | static int PROPSHEET_ShowPage(HWND hwndDlg, int index, PropSheetInfo * psInfo)
|
|---|
| 1193 | {
|
|---|
| 1194 | RECT rc;
|
|---|
| 1195 | PADDING_INFO padding;
|
|---|
| 1196 | UINT pageWidth,pageHeight;
|
|---|
| 1197 |
|
|---|
| 1198 | if (index == psInfo->active_page)
|
|---|
| 1199 | {
|
|---|
| 1200 | if (GetTopWindow(hwndDlg) != psInfo->proppage[index].hwndPage)
|
|---|
| 1201 | SetWindowPos(psInfo->proppage[index].hwndPage, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
|---|
| 1202 |
|
|---|
| 1203 | return 1;
|
|---|
| 1204 | }
|
|---|
| 1205 |
|
|---|
| 1206 | if (psInfo->active_page != -1)
|
|---|
| 1207 | ShowWindow(psInfo->proppage[psInfo->active_page].hwndPage, SW_HIDE);
|
|---|
| 1208 |
|
|---|
| 1209 | if (psInfo->proppage[index].hwndPage == 0)
|
|---|
| 1210 | {
|
|---|
| 1211 | LPCPROPSHEETPAGEA ppshpage;
|
|---|
| 1212 | PSHNOTIFY psn;
|
|---|
| 1213 | LRESULT ret;
|
|---|
| 1214 |
|
|---|
| 1215 | ppshpage = (LPCPROPSHEETPAGEA)psInfo->proppage[index].hpage;
|
|---|
| 1216 | PROPSHEET_CreatePage(hwndDlg, index, psInfo, (PROPSHEETPAGEA*)ppshpage);
|
|---|
| 1217 |
|
|---|
| 1218 | if (psInfo->proppage[index].hwndPage == 0)
|
|---|
| 1219 | return 0;
|
|---|
| 1220 |
|
|---|
| 1221 | psn.hdr.hwndFrom = hwndDlg;
|
|---|
| 1222 | psn.hdr.code = PSN_SETACTIVE;
|
|---|
| 1223 | psn.hdr.idFrom = 0;
|
|---|
| 1224 | psn.lParam = 0;
|
|---|
| 1225 |
|
|---|
| 1226 | /* Send the notification before showing the page. */
|
|---|
| 1227 | ret = SendMessageA(psInfo->proppage[index].hwndPage,
|
|---|
| 1228 | WM_NOTIFY, 0, (LPARAM) &psn);
|
|---|
| 1229 |
|
|---|
| 1230 | if (ret)
|
|---|
| 1231 | {
|
|---|
| 1232 | /* User doesn't accept new selection - find desired page and reselect */
|
|---|
| 1233 | if (ret == -1)
|
|---|
| 1234 | {
|
|---|
| 1235 | if (index > psInfo->active_page)
|
|---|
| 1236 | index++;
|
|---|
| 1237 | else
|
|---|
| 1238 | index--;
|
|---|
| 1239 | }
|
|---|
| 1240 | else
|
|---|
| 1241 | index = PROPSHEET_FindPageByResId(psInfo, ret);
|
|---|
| 1242 |
|
|---|
| 1243 | return PROPSHEET_SetCurSel(hwndDlg, index, 0) ? -1 : 0;
|
|---|
| 1244 | }
|
|---|
| 1245 | }
|
|---|
| 1246 |
|
|---|
| 1247 | if (psInfo->active_page != -1)
|
|---|
| 1248 | {
|
|---|
| 1249 | ShowWindow(psInfo->proppage[psInfo->active_page].hwndPage, SW_HIDE);
|
|---|
| 1250 | }
|
|---|
| 1251 |
|
|---|
| 1252 | #if 1
|
|---|
| 1253 | ShowWindow(psInfo->proppage[index].hwndPage, SW_SHOW);
|
|---|
| 1254 |
|
|---|
| 1255 | /* Synchronize current selection with tab control
|
|---|
| 1256 | * It seems to be needed even in case of PSH_WIZARD (no tab controls there) */
|
|---|
| 1257 | HWND hwndTabCtrl;
|
|---|
| 1258 | hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|---|
| 1259 | SendMessageA(hwndTabCtrl, TCM_SETCURSEL, index, 0);
|
|---|
| 1260 |
|
|---|
| 1261 | psInfo->active_page = index;
|
|---|
| 1262 | psInfo->activeValid = TRUE;
|
|---|
| 1263 | #else
|
|---|
| 1264 | /* HACK: Sometimes a property page doesn't get displayed at the right place inside the
|
|---|
| 1265 | * property sheet. This will force the window to be placed at the proper location
|
|---|
| 1266 | * before it is displayed.
|
|---|
| 1267 | */
|
|---|
| 1268 | rc.left = psInfo->x;
|
|---|
| 1269 | rc.top = psInfo->y;
|
|---|
| 1270 | rc.right = psInfo->width;
|
|---|
| 1271 | rc.bottom = psInfo->height;
|
|---|
| 1272 |
|
|---|
| 1273 | MapDialogRect(hwndDlg, &rc);
|
|---|
| 1274 |
|
|---|
| 1275 | pageWidth = rc.right - rc.left;
|
|---|
| 1276 | pageHeight = rc.bottom - rc.top;
|
|---|
| 1277 |
|
|---|
| 1278 | if (psInfo->ppshheader->dwFlags & PSH_WIZARD)
|
|---|
| 1279 | padding = PROPSHEET_GetPaddingInfoWizard(hwndDlg,psInfo);
|
|---|
| 1280 | else
|
|---|
| 1281 | {
|
|---|
| 1282 | /*
|
|---|
| 1283 | * Ask the Tab control to fit this page in.
|
|---|
| 1284 | */
|
|---|
| 1285 |
|
|---|
| 1286 | HWND hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|---|
| 1287 | SendMessageA(hwndTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM)&rc);
|
|---|
| 1288 | padding = PROPSHEET_GetPaddingInfo(hwndDlg);
|
|---|
| 1289 | }
|
|---|
| 1290 |
|
|---|
| 1291 | SetWindowPos(psInfo->proppage[index].hwndPage,HWND_TOP,rc.left+padding.x,rc.top+padding.y,pageWidth,pageHeight,SWP_SHOWWINDOW);
|
|---|
| 1292 |
|
|---|
| 1293 | if (!(psInfo->ppshheader->dwFlags & PSH_WIZARD))
|
|---|
| 1294 | {
|
|---|
| 1295 | HWND hwndTabCtrl;
|
|---|
| 1296 |
|
|---|
| 1297 | /* Synchronize current selection with tab control */
|
|---|
| 1298 | hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|---|
| 1299 | SendMessageA(hwndTabCtrl, TCM_SETCURSEL, index, 0);
|
|---|
| 1300 | }
|
|---|
| 1301 |
|
|---|
| 1302 | psInfo->active_page = index;
|
|---|
| 1303 | psInfo->activeValid = TRUE;
|
|---|
| 1304 | #endif
|
|---|
| 1305 | return 1;
|
|---|
| 1306 | }
|
|---|
| 1307 |
|
|---|
| 1308 | /******************************************************************************
|
|---|
| 1309 | * PROPSHEET_Back
|
|---|
| 1310 | */
|
|---|
| 1311 | static void PROPSHEET_Back(HWND hwndDlg)
|
|---|
| 1312 | {
|
|---|
| 1313 | PSHNOTIFY psn;
|
|---|
| 1314 | HWND hwndPage;
|
|---|
| 1315 | LRESULT msgResult = 0;
|
|---|
| 1316 | INT idx;
|
|---|
| 1317 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|---|
| 1318 | PropSheetInfoStr);
|
|---|
| 1319 |
|
|---|
| 1320 | if (psInfo->active_page < 0)
|
|---|
| 1321 | return;
|
|---|
| 1322 |
|
|---|
| 1323 | psn.hdr.code = PSN_WIZBACK;
|
|---|
| 1324 | psn.hdr.hwndFrom = hwndDlg;
|
|---|
| 1325 | psn.hdr.idFrom = 0;
|
|---|
| 1326 | psn.lParam = 0;
|
|---|
| 1327 |
|
|---|
| 1328 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|---|
| 1329 |
|
|---|
| 1330 | msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
|---|
| 1331 |
|
|---|
| 1332 | if (msgResult == -1)
|
|---|
| 1333 | return;
|
|---|
| 1334 | else if (msgResult == 0)
|
|---|
| 1335 | idx = psInfo->active_page - 1;
|
|---|
| 1336 | else
|
|---|
| 1337 | idx = PROPSHEET_FindPageByResId(psInfo, msgResult);
|
|---|
| 1338 |
|
|---|
| 1339 | if (idx >= 0 && idx < psInfo->nPages)
|
|---|
| 1340 | {
|
|---|
| 1341 | if (PROPSHEET_CanSetCurSel(hwndDlg))
|
|---|
| 1342 | PROPSHEET_SetCurSel(hwndDlg, idx, 0);
|
|---|
| 1343 | }
|
|---|
| 1344 | }
|
|---|
| 1345 |
|
|---|
| 1346 | /******************************************************************************
|
|---|
| 1347 | * PROPSHEET_Next
|
|---|
| 1348 | */
|
|---|
| 1349 | static void PROPSHEET_Next(HWND hwndDlg)
|
|---|
| 1350 | {
|
|---|
| 1351 | PSHNOTIFY psn;
|
|---|
| 1352 | HWND hwndPage;
|
|---|
| 1353 | LRESULT msgResult = 0;
|
|---|
| 1354 | INT idx;
|
|---|
| 1355 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|---|
| 1356 | PropSheetInfoStr);
|
|---|
| 1357 |
|
|---|
| 1358 | if (psInfo->active_page < 0)
|
|---|
| 1359 | return;
|
|---|
| 1360 |
|
|---|
| 1361 | psn.hdr.code = PSN_WIZNEXT;
|
|---|
| 1362 | psn.hdr.hwndFrom = hwndDlg;
|
|---|
| 1363 | psn.hdr.idFrom = 0;
|
|---|
| 1364 | psn.lParam = 0;
|
|---|
| 1365 |
|
|---|
| 1366 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|---|
| 1367 |
|
|---|
| 1368 | msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
|---|
| 1369 |
|
|---|
| 1370 | TRACE("msg result %ld\n", msgResult);
|
|---|
| 1371 |
|
|---|
| 1372 | if (msgResult == -1)
|
|---|
| 1373 | return;
|
|---|
| 1374 | else if (msgResult == 0)
|
|---|
| 1375 | idx = psInfo->active_page + 1;
|
|---|
| 1376 | else
|
|---|
| 1377 | idx = PROPSHEET_FindPageByResId(psInfo, msgResult);
|
|---|
| 1378 |
|
|---|
| 1379 | if (idx < psInfo->nPages )
|
|---|
| 1380 | {
|
|---|
| 1381 | if (PROPSHEET_CanSetCurSel(hwndDlg) != FALSE)
|
|---|
| 1382 | PROPSHEET_SetCurSel(hwndDlg, idx, 0);
|
|---|
| 1383 | }
|
|---|
| 1384 | }
|
|---|
| 1385 |
|
|---|
| 1386 | /******************************************************************************
|
|---|
| 1387 | * PROPSHEET_Finish
|
|---|
| 1388 | */
|
|---|
| 1389 | static void PROPSHEET_Finish(HWND hwndDlg)
|
|---|
| 1390 | {
|
|---|
| 1391 | PSHNOTIFY psn;
|
|---|
| 1392 | HWND hwndPage;
|
|---|
| 1393 | LRESULT msgResult = 0;
|
|---|
| 1394 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|---|
| 1395 | PropSheetInfoStr);
|
|---|
| 1396 |
|
|---|
| 1397 | if (psInfo->active_page < 0)
|
|---|
| 1398 | return;
|
|---|
| 1399 |
|
|---|
| 1400 | psn.hdr.code = PSN_WIZFINISH;
|
|---|
| 1401 | psn.hdr.hwndFrom = hwndDlg;
|
|---|
| 1402 | psn.hdr.idFrom = 0;
|
|---|
| 1403 | psn.lParam = 0;
|
|---|
| 1404 |
|
|---|
| 1405 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|---|
| 1406 |
|
|---|
| 1407 | msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
|---|
| 1408 |
|
|---|
| 1409 | TRACE("msg result %ld\n", msgResult);
|
|---|
| 1410 |
|
|---|
| 1411 | if (msgResult != 0)
|
|---|
| 1412 | return;
|
|---|
| 1413 |
|
|---|
| 1414 | if (psInfo->isModeless)
|
|---|
| 1415 | psInfo->activeValid = FALSE;
|
|---|
| 1416 | else
|
|---|
| 1417 | EndDialog(hwndDlg, TRUE);
|
|---|
| 1418 | }
|
|---|
| 1419 |
|
|---|
| 1420 | /******************************************************************************
|
|---|
| 1421 | * PROPSHEET_Apply
|
|---|
| 1422 | */
|
|---|
| 1423 | static BOOL PROPSHEET_Apply(HWND hwndDlg, LPARAM lParam)
|
|---|
| 1424 | {
|
|---|
| 1425 | int i;
|
|---|
| 1426 | HWND hwndPage;
|
|---|
| 1427 | PSHNOTIFY psn;
|
|---|
| 1428 | LRESULT msgResult;
|
|---|
| 1429 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|---|
| 1430 | PropSheetInfoStr);
|
|---|
| 1431 |
|
|---|
| 1432 | if (psInfo->active_page < 0)
|
|---|
| 1433 | return FALSE;
|
|---|
| 1434 |
|
|---|
| 1435 | psn.hdr.hwndFrom = hwndDlg;
|
|---|
| 1436 | psn.hdr.idFrom = 0;
|
|---|
| 1437 | psn.lParam = 0;
|
|---|
| 1438 |
|
|---|
| 1439 |
|
|---|
| 1440 | /*
|
|---|
| 1441 | * Send PSN_KILLACTIVE to the current page.
|
|---|
| 1442 | */
|
|---|
| 1443 | psn.hdr.code = PSN_KILLACTIVE;
|
|---|
| 1444 |
|
|---|
| 1445 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|---|
| 1446 |
|
|---|
| 1447 | if (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn) != FALSE)
|
|---|
| 1448 | return FALSE;
|
|---|
| 1449 |
|
|---|
| 1450 | /*
|
|---|
| 1451 | * Send PSN_APPLY to all pages.
|
|---|
| 1452 | */
|
|---|
| 1453 | psn.hdr.code = PSN_APPLY;
|
|---|
| 1454 | psn.lParam = lParam;
|
|---|
| 1455 |
|
|---|
| 1456 | for (i = 0; i < psInfo->nPages; i++)
|
|---|
| 1457 | {
|
|---|
| 1458 | hwndPage = psInfo->proppage[i].hwndPage;
|
|---|
| 1459 | if (hwndPage)
|
|---|
| 1460 | {
|
|---|
| 1461 | msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
|---|
| 1462 | if (msgResult == PSNRET_INVALID_NOCHANGEPAGE)
|
|---|
| 1463 | return FALSE;
|
|---|
| 1464 | else if (msgResult == PSNRET_INVALID)
|
|---|
| 1465 | {
|
|---|
| 1466 | PROPSHEET_SetCurSel(hwndDlg, i, 0);
|
|---|
| 1467 | return FALSE;
|
|---|
| 1468 | }
|
|---|
| 1469 | }
|
|---|
| 1470 | }
|
|---|
| 1471 |
|
|---|
| 1472 | EnableWindow(GetDlgItem(hwndDlg, IDC_APPLY_BUTTON), FALSE);
|
|---|
| 1473 |
|
|---|
| 1474 | if(lParam)
|
|---|
| 1475 | {
|
|---|
| 1476 | int result = TRUE;
|
|---|
| 1477 |
|
|---|
| 1478 | psInfo->activeValid = FALSE;
|
|---|
| 1479 |
|
|---|
| 1480 | if (psInfo->restartWindows)
|
|---|
| 1481 | result = ID_PSRESTARTWINDOWS;
|
|---|
| 1482 |
|
|---|
| 1483 | /* reboot system takes precedence over restart windows */
|
|---|
| 1484 | if (psInfo->rebootSystem)
|
|---|
| 1485 | result = ID_PSREBOOTSYSTEM;
|
|---|
| 1486 |
|
|---|
| 1487 | if (!psInfo->isModeless)
|
|---|
| 1488 | EndDialog(hwndDlg, result);
|
|---|
| 1489 | }
|
|---|
| 1490 | else if(psInfo->active_page >= 0)
|
|---|
| 1491 | {
|
|---|
| 1492 | psn.hdr.code = PSN_SETACTIVE;
|
|---|
| 1493 | psn.lParam = 0;
|
|---|
| 1494 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|---|
| 1495 | SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
|---|
| 1496 | /* Fixme: probably we have to handle return value */
|
|---|
| 1497 | }
|
|---|
| 1498 |
|
|---|
| 1499 | return TRUE;
|
|---|
| 1500 | }
|
|---|
| 1501 |
|
|---|
| 1502 | /******************************************************************************
|
|---|
| 1503 | * PROPSHEET_Cancel
|
|---|
| 1504 | */
|
|---|
| 1505 | static void PROPSHEET_Cancel(HWND hwndDlg, LPARAM lParam)
|
|---|
| 1506 | {
|
|---|
| 1507 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|---|
| 1508 | PropSheetInfoStr);
|
|---|
| 1509 | HWND hwndPage;
|
|---|
| 1510 | PSHNOTIFY psn;
|
|---|
| 1511 | int i;
|
|---|
| 1512 |
|
|---|
| 1513 | if (psInfo->active_page < 0)
|
|---|
| 1514 | return;
|
|---|
| 1515 |
|
|---|
| 1516 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|---|
| 1517 | psn.hdr.code = PSN_QUERYCANCEL;
|
|---|
| 1518 | psn.hdr.hwndFrom = hwndDlg;
|
|---|
| 1519 | psn.hdr.idFrom = 0;
|
|---|
| 1520 | psn.lParam = 0;
|
|---|
| 1521 |
|
|---|
| 1522 | if (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn))
|
|---|
| 1523 | return;
|
|---|
| 1524 |
|
|---|
| 1525 | psn.hdr.code = PSN_RESET;
|
|---|
| 1526 | psn.lParam = lParam;
|
|---|
| 1527 |
|
|---|
| 1528 | for (i = 0; i < psInfo->nPages; i++)
|
|---|
| 1529 | {
|
|---|
| 1530 | hwndPage = psInfo->proppage[i].hwndPage;
|
|---|
| 1531 |
|
|---|
| 1532 | if (hwndPage)
|
|---|
| 1533 | SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
|---|
| 1534 | /* No return value */
|
|---|
| 1535 | }
|
|---|
| 1536 |
|
|---|
| 1537 | if (psInfo->isModeless)
|
|---|
| 1538 | {
|
|---|
| 1539 | /* makes PSM_GETCURRENTPAGEHWND return NULL */
|
|---|
| 1540 | psInfo->activeValid = FALSE;
|
|---|
| 1541 | }
|
|---|
| 1542 | else
|
|---|
| 1543 | EndDialog(hwndDlg, FALSE);
|
|---|
| 1544 | }
|
|---|
| 1545 |
|
|---|
| 1546 | /******************************************************************************
|
|---|
| 1547 | * PROPSHEET_Help
|
|---|
| 1548 | */
|
|---|
| 1549 | static void PROPSHEET_Help(HWND hwndDlg)
|
|---|
| 1550 | {
|
|---|
| 1551 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|---|
| 1552 | PropSheetInfoStr);
|
|---|
| 1553 | HWND hwndPage;
|
|---|
| 1554 | PSHNOTIFY psn;
|
|---|
| 1555 |
|
|---|
| 1556 | if (psInfo->active_page < 0)
|
|---|
| 1557 | return;
|
|---|
| 1558 |
|
|---|
| 1559 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|---|
| 1560 | psn.hdr.code = PSN_HELP;
|
|---|
| 1561 | psn.hdr.hwndFrom = hwndDlg;
|
|---|
| 1562 | psn.hdr.idFrom = 0;
|
|---|
| 1563 | psn.lParam = 0;
|
|---|
| 1564 |
|
|---|
| 1565 | SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
|---|
| 1566 | }
|
|---|
| 1567 |
|
|---|
| 1568 | /******************************************************************************
|
|---|
| 1569 | * PROPSHEET_Changed
|
|---|
| 1570 | */
|
|---|
| 1571 | static void PROPSHEET_Changed(HWND hwndDlg, HWND hwndDirtyPage)
|
|---|
| 1572 | {
|
|---|
| 1573 | int i;
|
|---|
| 1574 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|---|
| 1575 | PropSheetInfoStr);
|
|---|
| 1576 | if (!psInfo) return;
|
|---|
| 1577 | /*
|
|---|
| 1578 | * Set the dirty flag of this page.
|
|---|
| 1579 | */
|
|---|
| 1580 | for (i = 0; i < psInfo->nPages; i++)
|
|---|
| 1581 | {
|
|---|
| 1582 | if (psInfo->proppage[i].hwndPage == hwndDirtyPage)
|
|---|
| 1583 | psInfo->proppage[i].isDirty = TRUE;
|
|---|
| 1584 | }
|
|---|
| 1585 |
|
|---|
| 1586 | /*
|
|---|
| 1587 | * Enable the Apply button.
|
|---|
| 1588 | */
|
|---|
| 1589 | if (psInfo->hasApply)
|
|---|
| 1590 | {
|
|---|
| 1591 | HWND hwndApplyBtn = GetDlgItem(hwndDlg, IDC_APPLY_BUTTON);
|
|---|
| 1592 |
|
|---|
| 1593 | EnableWindow(hwndApplyBtn, TRUE);
|
|---|
| 1594 | }
|
|---|
| 1595 | }
|
|---|
| 1596 |
|
|---|
| 1597 | /******************************************************************************
|
|---|
| 1598 | * PROPSHEET_UnChanged
|
|---|
| 1599 | */
|
|---|
| 1600 | static void PROPSHEET_UnChanged(HWND hwndDlg, HWND hwndCleanPage)
|
|---|
| 1601 | {
|
|---|
| 1602 | int i;
|
|---|
| 1603 | BOOL noPageDirty = TRUE;
|
|---|
| 1604 | HWND hwndApplyBtn = GetDlgItem(hwndDlg, IDC_APPLY_BUTTON);
|
|---|
| 1605 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|---|
| 1606 | PropSheetInfoStr);
|
|---|
| 1607 | if ( !psInfo ) return;
|
|---|
| 1608 | for (i = 0; i < psInfo->nPages; i++)
|
|---|
| 1609 | {
|
|---|
| 1610 | /* set the specified page as clean */
|
|---|
| 1611 | if (psInfo->proppage[i].hwndPage == hwndCleanPage)
|
|---|
| 1612 | psInfo->proppage[i].isDirty = FALSE;
|
|---|
| 1613 |
|
|---|
| 1614 | /* look to see if there's any dirty pages */
|
|---|
| 1615 | if (psInfo->proppage[i].isDirty)
|
|---|
| 1616 | noPageDirty = FALSE;
|
|---|
| 1617 | }
|
|---|
| 1618 |
|
|---|
| 1619 | /*
|
|---|
| 1620 | * Disable Apply button.
|
|---|
| 1621 | */
|
|---|
| 1622 | if (noPageDirty)
|
|---|
| 1623 | EnableWindow(hwndApplyBtn, FALSE);
|
|---|
| 1624 | }
|
|---|
| 1625 |
|
|---|
| 1626 | /******************************************************************************
|
|---|
| 1627 | * PROPSHEET_PressButton
|
|---|
| 1628 | */
|
|---|
| 1629 | static void PROPSHEET_PressButton(HWND hwndDlg, int buttonID)
|
|---|
| 1630 | {
|
|---|
| 1631 | switch (buttonID)
|
|---|
| 1632 | {
|
|---|
| 1633 | case PSBTN_APPLYNOW:
|
|---|
| 1634 | PROPSHEET_Apply(hwndDlg, 0);
|
|---|
| 1635 | break;
|
|---|
| 1636 |
|
|---|
| 1637 | case PSBTN_BACK:
|
|---|
| 1638 | PROPSHEET_Back(hwndDlg);
|
|---|
| 1639 | break;
|
|---|
| 1640 |
|
|---|
| 1641 | case PSBTN_CANCEL:
|
|---|
| 1642 | PROPSHEET_Cancel(hwndDlg, 0);
|
|---|
| 1643 | break;
|
|---|
| 1644 |
|
|---|
| 1645 | case PSBTN_FINISH:
|
|---|
| 1646 | PROPSHEET_Finish(hwndDlg);
|
|---|
| 1647 | break;
|
|---|
| 1648 |
|
|---|
| 1649 | case PSBTN_HELP:
|
|---|
| 1650 | PROPSHEET_Help(hwndDlg);
|
|---|
| 1651 | break;
|
|---|
| 1652 |
|
|---|
| 1653 | case PSBTN_NEXT:
|
|---|
| 1654 | PROPSHEET_Next(hwndDlg);
|
|---|
| 1655 | break;
|
|---|
| 1656 |
|
|---|
| 1657 | case PSBTN_OK:
|
|---|
| 1658 | PROPSHEET_Apply(hwndDlg, 1);
|
|---|
| 1659 | break;
|
|---|
| 1660 |
|
|---|
| 1661 | //default:
|
|---|
| 1662 | // FIXME("Invalid button index %d\n", buttonID);
|
|---|
| 1663 | }
|
|---|
| 1664 | }
|
|---|
| 1665 |
|
|---|
| 1666 | /*************************************************************************
|
|---|
| 1667 | * BOOL PROPSHEET_CanSetCurSel [Internal]
|
|---|
| 1668 | *
|
|---|
| 1669 | * Test weither the current page can be changed by sending a PSN_KILLACTIVE
|
|---|
| 1670 | *
|
|---|
| 1671 | * PARAMS
|
|---|
| 1672 | * hwndDlg [I] handle to a Dialog hWnd
|
|---|
| 1673 | *
|
|---|
| 1674 | * RETURNS
|
|---|
| 1675 | * TRUE if Current Selection can change
|
|---|
| 1676 | *
|
|---|
| 1677 | * NOTES
|
|---|
| 1678 | */
|
|---|
| 1679 | static BOOL PROPSHEET_CanSetCurSel(HWND hwndDlg)
|
|---|
| 1680 | {
|
|---|
| 1681 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|---|
| 1682 | PropSheetInfoStr);
|
|---|
| 1683 | HWND hwndPage;
|
|---|
| 1684 | PSHNOTIFY psn;
|
|---|
| 1685 |
|
|---|
| 1686 | if (!psInfo)
|
|---|
| 1687 | return FALSE;
|
|---|
| 1688 |
|
|---|
| 1689 | if (psInfo->active_page < 0)
|
|---|
| 1690 | return TRUE;
|
|---|
| 1691 |
|
|---|
| 1692 | /*
|
|---|
| 1693 | * Notify the current page.
|
|---|
| 1694 | */
|
|---|
| 1695 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|---|
| 1696 | psn.hdr.code = PSN_KILLACTIVE;
|
|---|
| 1697 | psn.hdr.hwndFrom = hwndDlg;
|
|---|
| 1698 | psn.hdr.idFrom = 0;
|
|---|
| 1699 | psn.lParam = 0;
|
|---|
| 1700 |
|
|---|
| 1701 | return !SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
|---|
| 1702 | }
|
|---|
| 1703 |
|
|---|
| 1704 | /******************************************************************************
|
|---|
| 1705 | * PROPSHEET_SetCurSel
|
|---|
| 1706 | */
|
|---|
| 1707 | static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
|
|---|
| 1708 | int index,
|
|---|
| 1709 | HPROPSHEETPAGE hpage)
|
|---|
| 1710 | {
|
|---|
| 1711 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|---|
| 1712 | PropSheetInfoStr);
|
|---|
| 1713 | HWND hwndPage;
|
|---|
| 1714 | HWND hwndHelp = GetDlgItem(hwndDlg, IDHELP);
|
|---|
| 1715 | int i;
|
|---|
| 1716 |
|
|---|
| 1717 | /* hpage takes precedence over index */
|
|---|
| 1718 | if (hpage != NULL)
|
|---|
| 1719 | index = PROPSHEET_GetPageIndex(hpage, psInfo);
|
|---|
| 1720 |
|
|---|
| 1721 | again:
|
|---|
| 1722 |
|
|---|
| 1723 | if (index < 0 || index >= psInfo->nPages)
|
|---|
| 1724 | {
|
|---|
| 1725 | TRACE("Could not find page to select!\n");
|
|---|
| 1726 | return FALSE;
|
|---|
| 1727 | }
|
|---|
| 1728 |
|
|---|
| 1729 | if (!psInfo->proppage[index].hwndPage) {
|
|---|
| 1730 | LPPROPSHEETPAGEA ppshpage = (LPPROPSHEETPAGEA)psInfo->proppage[index].hpage;
|
|---|
| 1731 | PROPSHEET_CreatePage(hwndDlg, index, psInfo, ppshpage);
|
|---|
| 1732 | }
|
|---|
| 1733 | hwndPage = psInfo->proppage[index].hwndPage;
|
|---|
| 1734 |
|
|---|
| 1735 | /*
|
|---|
| 1736 | * Notify the new page if it's already created.
|
|---|
| 1737 | * If not it will get created and notified in PROPSHEET_ShowPage.
|
|---|
| 1738 | */
|
|---|
| 1739 |
|
|---|
| 1740 | if (hwndPage)
|
|---|
| 1741 | {
|
|---|
| 1742 | LRESULT result;
|
|---|
| 1743 | PSHNOTIFY psn;
|
|---|
| 1744 |
|
|---|
| 1745 | psn.hdr.code = PSN_SETACTIVE;
|
|---|
| 1746 | psn.hdr.hwndFrom = hwndDlg;
|
|---|
| 1747 | psn.hdr.idFrom = 0;
|
|---|
| 1748 | psn.lParam = 0;
|
|---|
| 1749 |
|
|---|
| 1750 | result = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
|---|
| 1751 |
|
|---|
| 1752 | /* Fixme: If user doesn't accept new selection shall we send
|
|---|
| 1753 | * notifications to the page specified by user, or select it
|
|---|
| 1754 | * silently?
|
|---|
| 1755 | */
|
|---|
| 1756 | if (result == -1)
|
|---|
| 1757 | {
|
|---|
| 1758 | if (index != psInfo->active_page)
|
|---|
| 1759 | {
|
|---|
| 1760 | if (index > psInfo->active_page)
|
|---|
| 1761 | index++;
|
|---|
| 1762 | else if (index < psInfo->active_page)
|
|---|
| 1763 | index--;
|
|---|
| 1764 |
|
|---|
| 1765 | goto again;
|
|---|
| 1766 | }
|
|---|
| 1767 | }
|
|---|
| 1768 | else if (result != 0)
|
|---|
| 1769 | {
|
|---|
| 1770 | index = PROPSHEET_FindPageByResId(psInfo, result);
|
|---|
| 1771 | goto again;
|
|---|
| 1772 | }
|
|---|
| 1773 | }
|
|---|
| 1774 |
|
|---|
| 1775 | /*
|
|---|
| 1776 | * Display the new page.
|
|---|
| 1777 | */
|
|---|
| 1778 | i = PROPSHEET_ShowPage(hwndDlg, index, psInfo);
|
|---|
| 1779 |
|
|---|
| 1780 | /* 0 - function is failed,
|
|---|
| 1781 | * -1 - some other page is activated (via recursive call to SetCurSel) -
|
|---|
| 1782 | * exit now to avoid overwriting state of help button.
|
|---|
| 1783 | */
|
|---|
| 1784 | if (i <= 0)
|
|---|
| 1785 | return (BOOL)i;
|
|---|
| 1786 |
|
|---|
| 1787 | if (psInfo->proppage[index].hasHelp)
|
|---|
| 1788 | EnableWindow(hwndHelp, TRUE);
|
|---|
| 1789 | else
|
|---|
| 1790 | EnableWindow(hwndHelp, FALSE);
|
|---|
| 1791 |
|
|---|
| 1792 | return TRUE;
|
|---|
| 1793 | }
|
|---|
| 1794 |
|
|---|
| 1795 | /******************************************************************************
|
|---|
| 1796 | * PROPSHEET_SetTitleA
|
|---|
| 1797 | */
|
|---|
| 1798 | static void PROPSHEET_SetTitleA(HWND hwndDlg, DWORD dwStyle, LPCSTR lpszText)
|
|---|
| 1799 | {
|
|---|
| 1800 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg, PropSheetInfoStr);
|
|---|
| 1801 | char szTitle[256];
|
|---|
| 1802 |
|
|---|
| 1803 | if (HIWORD(lpszText) == 0) {
|
|---|
| 1804 | if (!LoadStringA(psInfo->ppshheader->hInstance,
|
|---|
| 1805 | LOWORD(lpszText), szTitle, sizeof(szTitle)-1))
|
|---|
| 1806 | return;
|
|---|
| 1807 | lpszText = szTitle;
|
|---|
| 1808 | }
|
|---|
| 1809 | if (dwStyle & PSH_PROPTITLE)
|
|---|
| 1810 | {
|
|---|
| 1811 | char* dest;
|
|---|
| 1812 | int lentitle = strlen(lpszText);
|
|---|
| 1813 | int lenprop = strlen(psInfo->strPropertiesFor);
|
|---|
| 1814 |
|
|---|
| 1815 | dest = (CHAR*)COMCTL32_Alloc(lentitle + lenprop + 1);
|
|---|
| 1816 | strcpy(dest, psInfo->strPropertiesFor);
|
|---|
| 1817 | strcat(dest, lpszText);
|
|---|
| 1818 |
|
|---|
| 1819 | SetWindowTextA(hwndDlg, dest);
|
|---|
| 1820 | COMCTL32_Free(dest);
|
|---|
| 1821 | }
|
|---|
| 1822 | else
|
|---|
| 1823 | SetWindowTextA(hwndDlg, lpszText);
|
|---|
| 1824 | }
|
|---|
| 1825 |
|
|---|
| 1826 | /******************************************************************************
|
|---|
| 1827 | * PROPSHEET_SetFinishTextA
|
|---|
| 1828 | */
|
|---|
| 1829 | static void PROPSHEET_SetFinishTextA(HWND hwndDlg, LPCSTR lpszText)
|
|---|
| 1830 | {
|
|---|
| 1831 | HWND hwndButton = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
|
|---|
| 1832 |
|
|---|
| 1833 | /* Set text, show and enable the Finish button */
|
|---|
| 1834 | SetWindowTextA(hwndButton, lpszText);
|
|---|
| 1835 | ShowWindow(hwndButton, SW_SHOW);
|
|---|
| 1836 | EnableWindow(hwndButton, TRUE);
|
|---|
| 1837 |
|
|---|
| 1838 | /* Make it default pushbutton */
|
|---|
| 1839 | SendMessageA(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0);
|
|---|
| 1840 |
|
|---|
| 1841 | /* Hide Back button */
|
|---|
| 1842 | hwndButton = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
|
|---|
| 1843 | ShowWindow(hwndButton, SW_HIDE);
|
|---|
| 1844 |
|
|---|
| 1845 | /* Hide Next button */
|
|---|
| 1846 | hwndButton = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
|
|---|
| 1847 | ShowWindow(hwndButton, SW_HIDE);
|
|---|
| 1848 | }
|
|---|
| 1849 |
|
|---|
| 1850 | /******************************************************************************
|
|---|
| 1851 | * PROPSHEET_QuerySiblings
|
|---|
| 1852 | */
|
|---|
| 1853 | static LRESULT PROPSHEET_QuerySiblings(HWND hwndDlg,
|
|---|
| 1854 | WPARAM wParam, LPARAM lParam)
|
|---|
| 1855 | {
|
|---|
| 1856 | int i = 0;
|
|---|
| 1857 | HWND hwndPage;
|
|---|
| 1858 | LRESULT msgResult = 0;
|
|---|
| 1859 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|---|
| 1860 | PropSheetInfoStr);
|
|---|
| 1861 |
|
|---|
| 1862 | while ((i < psInfo->nPages) && (msgResult == 0))
|
|---|
| 1863 | {
|
|---|
| 1864 | hwndPage = psInfo->proppage[i].hwndPage;
|
|---|
| 1865 | msgResult = SendMessageA(hwndPage, PSM_QUERYSIBLINGS, wParam, lParam);
|
|---|
| 1866 | i++;
|
|---|
| 1867 | }
|
|---|
| 1868 |
|
|---|
| 1869 | return msgResult;
|
|---|
| 1870 | }
|
|---|
| 1871 |
|
|---|
| 1872 |
|
|---|
| 1873 | /******************************************************************************
|
|---|
| 1874 | * PROPSHEET_AddPage
|
|---|
| 1875 | */
|
|---|
| 1876 | static BOOL PROPSHEET_AddPage(HWND hwndDlg,
|
|---|
| 1877 | HPROPSHEETPAGE hpage)
|
|---|
| 1878 | {
|
|---|
| 1879 | PropSheetInfo * psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|---|
| 1880 | PropSheetInfoStr);
|
|---|
| 1881 | HWND hwndTabControl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|---|
| 1882 | TCITEMA item;
|
|---|
| 1883 | char tabtext[MAX_TABTEXT_LENGTH] = "Tab text";
|
|---|
| 1884 | LPCPROPSHEETPAGEA ppsp = (LPCPROPSHEETPAGEA)hpage;
|
|---|
| 1885 |
|
|---|
| 1886 | /*
|
|---|
| 1887 | * Allocate and fill in a new PropPageInfo entry.
|
|---|
| 1888 | */
|
|---|
| 1889 | psInfo->proppage = (PropPageInfo*) COMCTL32_ReAlloc(psInfo->proppage,
|
|---|
| 1890 | sizeof(PropPageInfo) *
|
|---|
| 1891 | (psInfo->nPages + 1));
|
|---|
| 1892 |
|
|---|
| 1893 | PROPSHEET_CollectPageInfo(ppsp, psInfo, psInfo->nPages);
|
|---|
| 1894 | psInfo->proppage[psInfo->nPages].hpage = hpage;
|
|---|
| 1895 |
|
|---|
| 1896 | if (ppsp->dwFlags & PSP_PREMATURE)
|
|---|
| 1897 | {
|
|---|
| 1898 | /* Create the page but don't show it */
|
|---|
| 1899 | PROPSHEET_CreatePage(hwndDlg, psInfo->nPages, psInfo, (PROPSHEETPAGEA*)ppsp);
|
|---|
| 1900 | }
|
|---|
| 1901 |
|
|---|
| 1902 | /*
|
|---|
| 1903 | * Add a new tab to the tab control.
|
|---|
| 1904 | */
|
|---|
| 1905 | item.mask = TCIF_TEXT;
|
|---|
| 1906 | item.pszText = tabtext;
|
|---|
| 1907 | item.cchTextMax = MAX_TABTEXT_LENGTH;
|
|---|
| 1908 |
|
|---|
| 1909 | WideCharToMultiByte(CP_ACP, 0,
|
|---|
| 1910 | (LPCWSTR)psInfo->proppage[psInfo->nPages].pszText,
|
|---|
| 1911 | -1, tabtext, MAX_TABTEXT_LENGTH, NULL, NULL);
|
|---|
| 1912 |
|
|---|
| 1913 | SendMessageA(hwndTabControl, TCM_INSERTITEMA, psInfo->nPages + 1,
|
|---|
| 1914 | (LPARAM)&item);
|
|---|
| 1915 |
|
|---|
| 1916 | psInfo->nPages++;
|
|---|
| 1917 |
|
|---|
| 1918 | /* If it is the only page - show it */
|
|---|
| 1919 | if(psInfo->nPages == 1)
|
|---|
| 1920 | PROPSHEET_ShowPage(hwndDlg, 0, psInfo);
|
|---|
| 1921 |
|
|---|
| 1922 | return TRUE;
|
|---|
| 1923 | }
|
|---|
| 1924 |
|
|---|
| 1925 | /******************************************************************************
|
|---|
| 1926 | * PROPSHEET_RemovePage
|
|---|
| 1927 | */
|
|---|
| 1928 | static BOOL PROPSHEET_RemovePage(HWND hwndDlg,
|
|---|
| 1929 | int index,
|
|---|
| 1930 | HPROPSHEETPAGE hpage)
|
|---|
| 1931 | {
|
|---|
| 1932 | PropSheetInfo * psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|---|
| 1933 | PropSheetInfoStr);
|
|---|
| 1934 | HWND hwndTabControl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|---|
| 1935 | PropPageInfo* oldPages;
|
|---|
| 1936 |
|
|---|
| 1937 | if (!psInfo) {
|
|---|
| 1938 | return FALSE;
|
|---|
| 1939 | }
|
|---|
| 1940 | oldPages = psInfo->proppage;
|
|---|
| 1941 | /*
|
|---|
| 1942 | * hpage takes precedence over index.
|
|---|
| 1943 | */
|
|---|
| 1944 | if (hpage != 0)
|
|---|
| 1945 | {
|
|---|
| 1946 | index = PROPSHEET_GetPageIndex(hpage, psInfo);
|
|---|
| 1947 | }
|
|---|
| 1948 |
|
|---|
| 1949 | /* Make shure that index is within range */
|
|---|
| 1950 | if (index < 0 || index >= psInfo->nPages)
|
|---|
| 1951 | {
|
|---|
| 1952 | TRACE("Could not find page to remove!\n");
|
|---|
| 1953 | return FALSE;
|
|---|
| 1954 | }
|
|---|
| 1955 |
|
|---|
| 1956 | TRACE("total pages %d removing page %d active page %d\n",
|
|---|
| 1957 | psInfo->nPages, index, psInfo->active_page);
|
|---|
| 1958 | /*
|
|---|
| 1959 | * Check if we're removing the active page.
|
|---|
| 1960 | */
|
|---|
| 1961 | if (index == psInfo->active_page)
|
|---|
| 1962 | {
|
|---|
| 1963 | if (psInfo->nPages > 1)
|
|---|
| 1964 | {
|
|---|
| 1965 | if (index > 0)
|
|---|
| 1966 | {
|
|---|
| 1967 | /* activate previous page */
|
|---|
| 1968 | PROPSHEET_ShowPage(hwndDlg, index - 1, psInfo);
|
|---|
| 1969 | }
|
|---|
| 1970 | else
|
|---|
| 1971 | {
|
|---|
| 1972 | /* activate the next page */
|
|---|
| 1973 | PROPSHEET_ShowPage(hwndDlg, index + 1, psInfo);
|
|---|
| 1974 | psInfo->active_page = index;
|
|---|
| 1975 | }
|
|---|
| 1976 | }
|
|---|
| 1977 | else
|
|---|
| 1978 | {
|
|---|
| 1979 | psInfo->active_page = -1;
|
|---|
| 1980 | if (!psInfo->isModeless)
|
|---|
| 1981 | {
|
|---|
| 1982 | EndDialog(hwndDlg, FALSE);
|
|---|
| 1983 | return TRUE;
|
|---|
| 1984 | }
|
|---|
| 1985 | }
|
|---|
| 1986 | }
|
|---|
| 1987 | else if (index < psInfo->active_page)
|
|---|
| 1988 | psInfo->active_page--;
|
|---|
| 1989 |
|
|---|
| 1990 | /* Destroy page dialog window */
|
|---|
| 1991 | DestroyWindow(psInfo->proppage[index].hwndPage);
|
|---|
| 1992 |
|
|---|
| 1993 | /* Free page resources */
|
|---|
| 1994 | if(psInfo->proppage[index].hpage)
|
|---|
| 1995 | {
|
|---|
| 1996 | PROPSHEETPAGEA* psp = (PROPSHEETPAGEA*)psInfo->proppage[index].hpage;
|
|---|
| 1997 |
|
|---|
| 1998 | if ((psp->dwFlags & PSP_USETITLE) && psInfo->proppage[index].pszText)
|
|---|
| 1999 | HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->proppage[index].pszText);
|
|---|
| 2000 |
|
|---|
| 2001 | DestroyPropertySheetPage(psInfo->proppage[index].hpage);
|
|---|
| 2002 | }
|
|---|
| 2003 |
|
|---|
| 2004 | /* Remove the tab */
|
|---|
| 2005 | SendMessageA(hwndTabControl, TCM_DELETEITEM, index, 0);
|
|---|
| 2006 |
|
|---|
| 2007 | psInfo->nPages--;
|
|---|
| 2008 | psInfo->proppage = (PropPageInfo*)COMCTL32_Alloc(sizeof(PropPageInfo) * psInfo->nPages);
|
|---|
| 2009 |
|
|---|
| 2010 | if (index > 0)
|
|---|
| 2011 | memcpy(&psInfo->proppage[0], &oldPages[0], index * sizeof(PropPageInfo));
|
|---|
| 2012 |
|
|---|
| 2013 | if (index < psInfo->nPages)
|
|---|
| 2014 | memcpy(&psInfo->proppage[index], &oldPages[index + 1],
|
|---|
| 2015 | (psInfo->nPages - index) * sizeof(PropPageInfo));
|
|---|
| 2016 |
|
|---|
| 2017 | COMCTL32_Free(oldPages);
|
|---|
| 2018 |
|
|---|
| 2019 | return FALSE;
|
|---|
| 2020 | }
|
|---|
| 2021 |
|
|---|
| 2022 | /******************************************************************************
|
|---|
| 2023 | * PROPSHEET_SetWizButtons
|
|---|
| 2024 | *
|
|---|
| 2025 | * This code will work if (and assumes that) the Next button is on top of the
|
|---|
| 2026 | * Finish button. ie. Finish comes after Next in the Z order.
|
|---|
| 2027 | * This means make sure the dialog template reflects this.
|
|---|
| 2028 | *
|
|---|
| 2029 | */
|
|---|
| 2030 | static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags)
|
|---|
| 2031 | {
|
|---|
| 2032 | HWND hwndBack = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
|
|---|
| 2033 | HWND hwndNext = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
|
|---|
| 2034 | HWND hwndFinish = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
|
|---|
| 2035 |
|
|---|
| 2036 | TRACE("%ld\n", dwFlags);
|
|---|
| 2037 |
|
|---|
| 2038 | EnableWindow(hwndBack, FALSE);
|
|---|
| 2039 | EnableWindow(hwndNext, FALSE);
|
|---|
| 2040 | EnableWindow(hwndFinish, FALSE);
|
|---|
| 2041 |
|
|---|
| 2042 | if (dwFlags & PSWIZB_BACK)
|
|---|
| 2043 | EnableWindow(hwndBack, TRUE);
|
|---|
| 2044 |
|
|---|
| 2045 | if (dwFlags & PSWIZB_NEXT)
|
|---|
| 2046 | {
|
|---|
| 2047 | /* Hide the Finish button */
|
|---|
| 2048 | ShowWindow(hwndFinish, SW_HIDE);
|
|---|
| 2049 |
|
|---|
| 2050 | /* Show and enable the Next button */
|
|---|
| 2051 | ShowWindow(hwndNext, SW_SHOW);
|
|---|
| 2052 | EnableWindow(hwndNext, TRUE);
|
|---|
| 2053 |
|
|---|
| 2054 | /* Set the Next button as the default pushbutton */
|
|---|
| 2055 | SendMessageA(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0);
|
|---|
| 2056 | }
|
|---|
| 2057 |
|
|---|
| 2058 | if ((dwFlags & PSWIZB_FINISH) || (dwFlags & PSWIZB_DISABLEDFINISH))
|
|---|
| 2059 | {
|
|---|
| 2060 | /* Hide the Next button */
|
|---|
| 2061 | ShowWindow(hwndNext, SW_HIDE);
|
|---|
| 2062 |
|
|---|
| 2063 | /* Show the Finish button */
|
|---|
| 2064 | ShowWindow(hwndFinish, SW_SHOW);
|
|---|
| 2065 |
|
|---|
| 2066 | if (dwFlags & PSWIZB_FINISH)
|
|---|
| 2067 | EnableWindow(hwndFinish, TRUE);
|
|---|
| 2068 |
|
|---|
| 2069 | /* Set the Finish button as the default pushbutton */
|
|---|
| 2070 | SendMessageA(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0);
|
|---|
| 2071 | }
|
|---|
| 2072 | }
|
|---|
| 2073 |
|
|---|
| 2074 | /******************************************************************************
|
|---|
| 2075 | * PROPSHEET_GetPageIndex
|
|---|
| 2076 | *
|
|---|
| 2077 | * Given a HPROPSHEETPAGE, returns the index of the corresponding page from
|
|---|
| 2078 | * the array of PropPageInfo.
|
|---|
| 2079 | */
|
|---|
| 2080 | static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage, PropSheetInfo* psInfo)
|
|---|
| 2081 | {
|
|---|
| 2082 | BOOL found = FALSE;
|
|---|
| 2083 | int index = 0;
|
|---|
| 2084 |
|
|---|
| 2085 | while ((index < psInfo->nPages) && (found == FALSE))
|
|---|
| 2086 | {
|
|---|
| 2087 | if (psInfo->proppage[index].hpage == hpage)
|
|---|
| 2088 | found = TRUE;
|
|---|
| 2089 | else
|
|---|
| 2090 | index++;
|
|---|
| 2091 | }
|
|---|
| 2092 |
|
|---|
| 2093 | if (found == FALSE)
|
|---|
| 2094 | index = -1;
|
|---|
| 2095 |
|
|---|
| 2096 | return index;
|
|---|
| 2097 | }
|
|---|
| 2098 |
|
|---|
| 2099 | /******************************************************************************
|
|---|
| 2100 | * PROPSHEET_CleanUp
|
|---|
| 2101 | */
|
|---|
| 2102 | static void PROPSHEET_CleanUp(HWND hwndDlg)
|
|---|
| 2103 | {
|
|---|
| 2104 | int i;
|
|---|
| 2105 | PropSheetInfo* psInfo = (PropSheetInfo*) RemovePropA(hwndDlg,
|
|---|
| 2106 | PropSheetInfoStr);
|
|---|
| 2107 |
|
|---|
| 2108 | TRACE("\n");
|
|---|
| 2109 | if (HIWORD(psInfo->ppshheader->pszCaption))
|
|---|
| 2110 | HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->ppshheader->pszCaption);
|
|---|
| 2111 |
|
|---|
| 2112 | COMCTL32_Free((LPVOID)psInfo->ppshheader);
|
|---|
| 2113 |
|
|---|
| 2114 | for (i = 0; i < psInfo->nPages; i++)
|
|---|
| 2115 | {
|
|---|
| 2116 | PROPSHEETPAGEA* psp = (PROPSHEETPAGEA*)psInfo->proppage[i].hpage;
|
|---|
| 2117 |
|
|---|
| 2118 | if(psInfo->proppage[i].hwndPage)
|
|---|
| 2119 | DestroyWindow(psInfo->proppage[i].hwndPage);
|
|---|
| 2120 |
|
|---|
| 2121 | if(psp)
|
|---|
| 2122 | {
|
|---|
| 2123 | if ((psp->dwFlags & PSP_USETITLE) && psInfo->proppage[i].pszText)
|
|---|
| 2124 | HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->proppage[i].pszText);
|
|---|
| 2125 |
|
|---|
| 2126 | DestroyPropertySheetPage(psInfo->proppage[i].hpage);
|
|---|
| 2127 | }
|
|---|
| 2128 | }
|
|---|
| 2129 |
|
|---|
| 2130 | COMCTL32_Free(psInfo->proppage);
|
|---|
| 2131 | COMCTL32_Free(psInfo->strPropertiesFor);
|
|---|
| 2132 | ImageList_Destroy(psInfo->hImageList);
|
|---|
| 2133 |
|
|---|
| 2134 | GlobalFree((HGLOBAL)psInfo);
|
|---|
| 2135 | }
|
|---|
| 2136 |
|
|---|
| 2137 | /******************************************************************************
|
|---|
| 2138 | * PropertySheetA (COMCTL32.84)(COMCTL32.83)
|
|---|
| 2139 | */
|
|---|
| 2140 | INT WINAPI PropertySheetA(LPCPROPSHEETHEADERA lppsh)
|
|---|
| 2141 | {
|
|---|
| 2142 | int bRet = 0;
|
|---|
| 2143 | PropSheetInfo* psInfo = (PropSheetInfo*) GlobalAlloc(GPTR,
|
|---|
| 2144 | sizeof(PropSheetInfo));
|
|---|
| 2145 | int i;
|
|---|
| 2146 | BYTE* pByte;
|
|---|
| 2147 |
|
|---|
| 2148 | dprintf(("COMCTL32: PropertySheetA"));
|
|---|
| 2149 |
|
|---|
| 2150 | PROPSHEET_CollectSheetInfo(lppsh, psInfo);
|
|---|
| 2151 |
|
|---|
| 2152 | psInfo->proppage = (PropPageInfo*) COMCTL32_Alloc(sizeof(PropPageInfo) *
|
|---|
| 2153 | lppsh->nPages);
|
|---|
| 2154 | pByte = (BYTE*) psInfo->ppshheader->ppsp;
|
|---|
| 2155 |
|
|---|
| 2156 | for (i = 0; i < lppsh->nPages; i++)
|
|---|
| 2157 | {
|
|---|
| 2158 | if (!(lppsh->dwFlags & PSH_PROPSHEETPAGE))
|
|---|
| 2159 | psInfo->proppage[i].hpage = psInfo->ppshheader->phpage[i];
|
|---|
| 2160 | else
|
|---|
| 2161 | {
|
|---|
| 2162 | psInfo->proppage[i].hpage = CreatePropertySheetPageA((LPCPROPSHEETPAGEA)pByte);
|
|---|
| 2163 | pByte += ((LPPROPSHEETPAGEA)pByte)->dwSize;
|
|---|
| 2164 | }
|
|---|
| 2165 |
|
|---|
| 2166 | PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEA)psInfo->proppage[i].hpage,
|
|---|
| 2167 | psInfo, i);
|
|---|
| 2168 | }
|
|---|
| 2169 |
|
|---|
| 2170 | bRet = PROPSHEET_CreateDialog(psInfo);
|
|---|
| 2171 |
|
|---|
| 2172 | return bRet;
|
|---|
| 2173 | }
|
|---|
| 2174 |
|
|---|
| 2175 | /******************************************************************************
|
|---|
| 2176 | * PropertySheet32W (COMCTL32.85)
|
|---|
| 2177 | */
|
|---|
| 2178 | INT WINAPI PropertySheetW(LPCPROPSHEETHEADERW propertySheetHeader)
|
|---|
| 2179 | {
|
|---|
| 2180 | dprintf(("COMCTL32: PropertySheetW - empty stub!"));
|
|---|
| 2181 |
|
|---|
| 2182 | return -1;
|
|---|
| 2183 | }
|
|---|
| 2184 |
|
|---|
| 2185 | /******************************************************************************
|
|---|
| 2186 | * CreatePropertySheetPageA (COMCTL32.19)(COMCTL32.18)
|
|---|
| 2187 | */
|
|---|
| 2188 | HPROPSHEETPAGE WINAPI CreatePropertySheetPageA(
|
|---|
| 2189 | LPCPROPSHEETPAGEA lpPropSheetPage)
|
|---|
| 2190 | {
|
|---|
| 2191 | PROPSHEETPAGEA* ppsp = (PROPSHEETPAGEA*)COMCTL32_Alloc(sizeof(PROPSHEETPAGEA));
|
|---|
| 2192 |
|
|---|
| 2193 | dprintf(("COMCTL32: CreatePropertySheetPageA"));
|
|---|
| 2194 |
|
|---|
| 2195 | *ppsp = *lpPropSheetPage;
|
|---|
| 2196 |
|
|---|
| 2197 | if ( !(ppsp->dwFlags & PSP_DLGINDIRECT) && HIWORD( ppsp->pszTemplate ) )
|
|---|
| 2198 | ppsp->pszTemplate = HEAP_strdupA( GetProcessHeap(), 0, lpPropSheetPage->pszTemplate );
|
|---|
| 2199 |
|
|---|
| 2200 | if ( (ppsp->dwFlags & PSP_USEICONID) && HIWORD( ppsp->pszIcon ) )
|
|---|
| 2201 | ppsp->pszIcon = HEAP_strdupA( GetProcessHeap(), 0, lpPropSheetPage->pszIcon );
|
|---|
| 2202 |
|
|---|
| 2203 |
|
|---|
| 2204 | if ((ppsp->dwFlags & PSP_USETITLE) && HIWORD( ppsp->pszTitle ))
|
|---|
| 2205 | ppsp->pszTitle = HEAP_strdupA( GetProcessHeap(), 0, lpPropSheetPage->pszTitle );
|
|---|
| 2206 | else if ( !(ppsp->dwFlags & PSP_USETITLE) )
|
|---|
| 2207 | ppsp->pszTitle = NULL;
|
|---|
| 2208 |
|
|---|
| 2209 | return (HPROPSHEETPAGE)ppsp;
|
|---|
| 2210 | }
|
|---|
| 2211 |
|
|---|
| 2212 | /******************************************************************************
|
|---|
| 2213 | * CreatePropertySheetPageW (COMCTL32.20)
|
|---|
| 2214 | */
|
|---|
| 2215 | HPROPSHEETPAGE WINAPI CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage)
|
|---|
| 2216 | {
|
|---|
| 2217 | dprintf(("COMCTL32: CreatePropertySheetPageW - empty stub!"));
|
|---|
| 2218 |
|
|---|
| 2219 | return 0;
|
|---|
| 2220 | }
|
|---|
| 2221 |
|
|---|
| 2222 | /******************************************************************************
|
|---|
| 2223 | * DestroyPropertySheetPage (COMCTL32.24)
|
|---|
| 2224 | */
|
|---|
| 2225 | BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
|
|---|
| 2226 | {
|
|---|
| 2227 | PROPSHEETPAGEA *psp = (PROPSHEETPAGEA *)hPropPage;
|
|---|
| 2228 |
|
|---|
| 2229 | dprintf(("COMCTL32: DestroyPropertySheetPage"));
|
|---|
| 2230 |
|
|---|
| 2231 | if (!psp)
|
|---|
| 2232 | return FALSE;
|
|---|
| 2233 |
|
|---|
| 2234 | if ( !(psp->dwFlags & PSP_DLGINDIRECT) && HIWORD( psp->pszTemplate ) )
|
|---|
| 2235 | HeapFree(GetProcessHeap(), 0, (LPVOID)psp->pszTemplate);
|
|---|
| 2236 |
|
|---|
| 2237 | if ( (psp->dwFlags & PSP_USEICONID) && HIWORD( psp->pszIcon ) )
|
|---|
| 2238 | HeapFree(GetProcessHeap(), 0, (LPVOID)psp->pszIcon);
|
|---|
| 2239 |
|
|---|
| 2240 | if ((psp->dwFlags & PSP_USETITLE) && HIWORD( psp->pszTitle ))
|
|---|
| 2241 | HeapFree(GetProcessHeap(), 0, (LPVOID)psp->pszTitle);
|
|---|
| 2242 |
|
|---|
| 2243 | COMCTL32_Free(hPropPage);
|
|---|
| 2244 |
|
|---|
| 2245 | return TRUE;
|
|---|
| 2246 | }
|
|---|
| 2247 |
|
|---|
| 2248 | /******************************************************************************
|
|---|
| 2249 | * PROPSHEET_IsDialogMessage
|
|---|
| 2250 | */
|
|---|
| 2251 | static BOOL PROPSHEET_IsDialogMessage(HWND hwnd, LPMSG lpMsg)
|
|---|
| 2252 | {
|
|---|
| 2253 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd, PropSheetInfoStr);
|
|---|
| 2254 |
|
|---|
| 2255 | if (!psInfo || (hwnd != lpMsg->hwnd && !IsChild(hwnd, lpMsg->hwnd)))
|
|---|
| 2256 | return FALSE;
|
|---|
| 2257 |
|
|---|
| 2258 | if (lpMsg->message == WM_KEYDOWN && (GetKeyState(VK_CONTROL) & 0x8000))
|
|---|
| 2259 | {
|
|---|
| 2260 | int new_page = 0;
|
|---|
| 2261 | INT dlgCode = SendMessageA(lpMsg->hwnd, WM_GETDLGCODE, 0, (LPARAM)lpMsg);
|
|---|
| 2262 |
|
|---|
| 2263 | if (!(dlgCode & DLGC_WANTMESSAGE))
|
|---|
| 2264 | {
|
|---|
| 2265 | switch (lpMsg->wParam)
|
|---|
| 2266 | {
|
|---|
| 2267 | case VK_TAB:
|
|---|
| 2268 | if (GetKeyState(VK_SHIFT) & 0x8000)
|
|---|
| 2269 | new_page = -1;
|
|---|
| 2270 | else
|
|---|
| 2271 | new_page = 1;
|
|---|
| 2272 | break;
|
|---|
| 2273 |
|
|---|
| 2274 | case VK_NEXT: new_page = 1; break;
|
|---|
| 2275 | case VK_PRIOR: new_page = -1; break;
|
|---|
| 2276 | }
|
|---|
| 2277 | }
|
|---|
| 2278 |
|
|---|
| 2279 | if (new_page)
|
|---|
| 2280 | {
|
|---|
| 2281 | if (PROPSHEET_CanSetCurSel(hwnd) != FALSE)
|
|---|
| 2282 | {
|
|---|
| 2283 | new_page += psInfo->active_page;
|
|---|
| 2284 |
|
|---|
| 2285 | if (new_page < 0)
|
|---|
| 2286 | new_page = psInfo->nPages - 1;
|
|---|
| 2287 | else if (new_page >= psInfo->nPages)
|
|---|
| 2288 | new_page = 0;
|
|---|
| 2289 |
|
|---|
| 2290 | PROPSHEET_SetCurSel(hwnd, new_page, 0);
|
|---|
| 2291 | }
|
|---|
| 2292 |
|
|---|
| 2293 | return TRUE;
|
|---|
| 2294 | }
|
|---|
| 2295 | }
|
|---|
| 2296 |
|
|---|
| 2297 | return IsDialogMessageA(hwnd, lpMsg);
|
|---|
| 2298 | }
|
|---|
| 2299 |
|
|---|
| 2300 | /******************************************************************************
|
|---|
| 2301 | * PROPSHEET_DialogProc
|
|---|
| 2302 | */
|
|---|
| 2303 | BOOL WINAPI
|
|---|
| 2304 | PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|---|
| 2305 | {
|
|---|
| 2306 | switch (uMsg)
|
|---|
| 2307 | {
|
|---|
| 2308 | case WM_INITDIALOG:
|
|---|
| 2309 | {
|
|---|
| 2310 | PropSheetInfo* psInfo = (PropSheetInfo*) lParam;
|
|---|
| 2311 | char* strCaption = (char*)COMCTL32_Alloc(MAX_CAPTION_LENGTH);
|
|---|
| 2312 | HWND hwndTabCtrl = GetDlgItem(hwnd, IDC_TABCONTROL);
|
|---|
| 2313 | LPCPROPSHEETPAGEA ppshpage;
|
|---|
| 2314 | int idx;
|
|---|
| 2315 |
|
|---|
| 2316 | SetPropA(hwnd, PropSheetInfoStr, (HANDLE)psInfo);
|
|---|
| 2317 |
|
|---|
| 2318 | /*
|
|---|
| 2319 | * Small icon in the title bar.
|
|---|
| 2320 | */
|
|---|
| 2321 | if ((psInfo->ppshheader->dwFlags & PSH_USEICONID) ||
|
|---|
| 2322 | (psInfo->ppshheader->dwFlags & PSH_USEHICON))
|
|---|
| 2323 | {
|
|---|
| 2324 | HICON hIcon;
|
|---|
| 2325 | int icon_cx = GetSystemMetrics(SM_CXSMICON);
|
|---|
| 2326 | int icon_cy = GetSystemMetrics(SM_CYSMICON);
|
|---|
| 2327 |
|
|---|
| 2328 | if (psInfo->ppshheader->dwFlags & PSH_USEICONID)
|
|---|
| 2329 | hIcon = LoadImageA(psInfo->ppshheader->hInstance,
|
|---|
| 2330 | psInfo->ppshheader->pszIcon,
|
|---|
| 2331 | IMAGE_ICON,
|
|---|
| 2332 | icon_cx, icon_cy,
|
|---|
| 2333 | LR_DEFAULTCOLOR);
|
|---|
| 2334 | else
|
|---|
| 2335 | hIcon = psInfo->ppshheader->hIcon;
|
|---|
| 2336 |
|
|---|
| 2337 | SendMessageA(hwnd, WM_SETICON, 0, hIcon);
|
|---|
| 2338 | }
|
|---|
| 2339 |
|
|---|
| 2340 | if (psInfo->ppshheader->dwFlags & PSH_USEHICON)
|
|---|
| 2341 | SendMessageA(hwnd, WM_SETICON, 0, psInfo->ppshheader->hIcon);
|
|---|
| 2342 |
|
|---|
| 2343 | psInfo->strPropertiesFor = strCaption;
|
|---|
| 2344 |
|
|---|
| 2345 | GetWindowTextA(hwnd, psInfo->strPropertiesFor, MAX_CAPTION_LENGTH);
|
|---|
| 2346 |
|
|---|
| 2347 | PROPSHEET_CreateTabControl(hwnd, psInfo);
|
|---|
| 2348 |
|
|---|
| 2349 | if (psInfo->ppshheader->dwFlags & PSH_WIZARD)
|
|---|
| 2350 | {
|
|---|
| 2351 | if (PROPSHEET_IsTooSmallWizard(hwnd, psInfo))
|
|---|
| 2352 | {
|
|---|
| 2353 | PROPSHEET_AdjustSizeWizard(hwnd, psInfo);
|
|---|
| 2354 | PROPSHEET_AdjustButtonsWizard(hwnd, psInfo);
|
|---|
| 2355 | }
|
|---|
| 2356 | }
|
|---|
| 2357 | else
|
|---|
| 2358 | {
|
|---|
| 2359 | if (PROPSHEET_SizeMismatch(hwnd, psInfo))
|
|---|
| 2360 | {
|
|---|
| 2361 | PROPSHEET_AdjustSize(hwnd, psInfo);
|
|---|
| 2362 | PROPSHEET_AdjustButtons(hwnd, psInfo);
|
|---|
| 2363 | }
|
|---|
| 2364 | }
|
|---|
| 2365 |
|
|---|
| 2366 | if (psInfo->useCallback)
|
|---|
| 2367 | (*(psInfo->ppshheader->pfnCallback))(hwnd,
|
|---|
| 2368 | PSCB_INITIALIZED, (LPARAM)0);
|
|---|
| 2369 |
|
|---|
| 2370 | idx = psInfo->active_page;
|
|---|
| 2371 | ppshpage = (LPCPROPSHEETPAGEA)psInfo->proppage[idx].hpage;
|
|---|
| 2372 | psInfo->active_page = -1;
|
|---|
| 2373 |
|
|---|
| 2374 | PROPSHEET_SetCurSel(hwnd, idx, psInfo->proppage[idx].hpage);
|
|---|
| 2375 |
|
|---|
| 2376 | if (!(psInfo->ppshheader->dwFlags & PSH_WIZARD))
|
|---|
| 2377 | SendMessageA(hwndTabCtrl, TCM_SETCURSEL, psInfo->active_page, 0);
|
|---|
| 2378 |
|
|---|
| 2379 | if (!HIWORD(psInfo->ppshheader->pszCaption) &&
|
|---|
| 2380 | psInfo->ppshheader->hInstance)
|
|---|
| 2381 | {
|
|---|
| 2382 | char szText[256];
|
|---|
| 2383 |
|
|---|
| 2384 | if (LoadStringA(psInfo->ppshheader->hInstance,
|
|---|
| 2385 | (UINT)psInfo->ppshheader->pszCaption, szText, 255))
|
|---|
| 2386 | PROPSHEET_SetTitleA(hwnd, psInfo->ppshheader->dwFlags, szText);
|
|---|
| 2387 | }
|
|---|
| 2388 | else
|
|---|
| 2389 | {
|
|---|
| 2390 | PROPSHEET_SetTitleA(hwnd, psInfo->ppshheader->dwFlags,
|
|---|
| 2391 | psInfo->ppshheader->pszCaption);
|
|---|
| 2392 | }
|
|---|
| 2393 |
|
|---|
| 2394 | return TRUE;
|
|---|
| 2395 | }
|
|---|
| 2396 |
|
|---|
| 2397 | case WM_DESTROY:
|
|---|
| 2398 | PROPSHEET_CleanUp(hwnd);
|
|---|
| 2399 | return TRUE;
|
|---|
| 2400 |
|
|---|
| 2401 | case WM_CLOSE:
|
|---|
| 2402 | PROPSHEET_Cancel(hwnd, 1);
|
|---|
| 2403 | return TRUE;
|
|---|
| 2404 |
|
|---|
| 2405 | case WM_COMMAND:
|
|---|
| 2406 | {
|
|---|
| 2407 | WORD wID = LOWORD(wParam);
|
|---|
| 2408 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd,PropSheetInfoStr);
|
|---|
| 2409 |
|
|---|
| 2410 | switch (wID)
|
|---|
| 2411 | {
|
|---|
| 2412 | case IDOK:
|
|---|
| 2413 | case IDC_APPLY_BUTTON:
|
|---|
| 2414 | PROPSHEET_Apply(hwnd, wID == IDOK ? 1: 0);
|
|---|
| 2415 | break;
|
|---|
| 2416 |
|
|---|
| 2417 | case IDC_BACK_BUTTON:
|
|---|
| 2418 | PROPSHEET_Back(hwnd);
|
|---|
| 2419 | break;
|
|---|
| 2420 |
|
|---|
| 2421 | case IDC_NEXT_BUTTON:
|
|---|
| 2422 | PROPSHEET_Next(hwnd);
|
|---|
| 2423 | break;
|
|---|
| 2424 |
|
|---|
| 2425 | case IDC_FINISH_BUTTON:
|
|---|
| 2426 | PROPSHEET_Finish(hwnd);
|
|---|
| 2427 | break;
|
|---|
| 2428 |
|
|---|
| 2429 | case IDCANCEL:
|
|---|
| 2430 | PROPSHEET_Cancel(hwnd, 0);
|
|---|
| 2431 | break;
|
|---|
| 2432 |
|
|---|
| 2433 | case IDHELP:
|
|---|
| 2434 | PROPSHEET_Help(hwnd);
|
|---|
| 2435 | break;
|
|---|
| 2436 |
|
|---|
| 2437 | default:
|
|---|
| 2438 | if(psInfo->active_page != -1)
|
|---|
| 2439 | {
|
|---|
| 2440 | return SendMessageA(psInfo->proppage[psInfo->active_page].hwndPage,
|
|---|
| 2441 | uMsg, wParam, lParam);
|
|---|
| 2442 | }
|
|---|
| 2443 | }
|
|---|
| 2444 |
|
|---|
| 2445 | return TRUE;
|
|---|
| 2446 | }
|
|---|
| 2447 |
|
|---|
| 2448 | case WM_NOTIFY:
|
|---|
| 2449 | {
|
|---|
| 2450 | NMHDR* pnmh = (LPNMHDR) lParam;
|
|---|
| 2451 |
|
|---|
| 2452 | if (pnmh->code == TCN_SELCHANGE)
|
|---|
| 2453 | {
|
|---|
| 2454 | int index = SendMessageA(pnmh->hwndFrom, TCM_GETCURSEL, 0, 0);
|
|---|
| 2455 | PROPSHEET_SetCurSel(hwnd, index, 0);
|
|---|
| 2456 | }
|
|---|
| 2457 |
|
|---|
| 2458 | if(pnmh->code == TCN_SELCHANGING)
|
|---|
| 2459 | {
|
|---|
| 2460 | BOOL bRet = PROPSHEET_CanSetCurSel(hwnd);
|
|---|
| 2461 | SetWindowLongA(hwnd, DWL_MSGRESULT, !bRet);
|
|---|
| 2462 | return TRUE;
|
|---|
| 2463 | }
|
|---|
| 2464 |
|
|---|
| 2465 |
|
|---|
| 2466 | return 0;
|
|---|
| 2467 | }
|
|---|
| 2468 |
|
|---|
| 2469 | case PSM_GETCURRENTPAGEHWND:
|
|---|
| 2470 | {
|
|---|
| 2471 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd,
|
|---|
| 2472 | PropSheetInfoStr);
|
|---|
| 2473 | HWND hwndPage = 0;
|
|---|
| 2474 |
|
|---|
| 2475 | if (psInfo->activeValid && psInfo->active_page != -1)
|
|---|
| 2476 | hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|---|
| 2477 |
|
|---|
| 2478 | SetWindowLongA(hwnd, DWL_MSGRESULT, hwndPage);
|
|---|
| 2479 |
|
|---|
| 2480 | return TRUE;
|
|---|
| 2481 | }
|
|---|
| 2482 |
|
|---|
| 2483 | case PSM_CHANGED:
|
|---|
| 2484 | PROPSHEET_Changed(hwnd, (HWND)wParam);
|
|---|
| 2485 | return TRUE;
|
|---|
| 2486 |
|
|---|
| 2487 | case PSM_UNCHANGED:
|
|---|
| 2488 | PROPSHEET_UnChanged(hwnd, (HWND)wParam);
|
|---|
| 2489 | return TRUE;
|
|---|
| 2490 |
|
|---|
| 2491 | case PSM_GETTABCONTROL:
|
|---|
| 2492 | {
|
|---|
| 2493 | HWND hwndTabCtrl = GetDlgItem(hwnd, IDC_TABCONTROL);
|
|---|
| 2494 |
|
|---|
| 2495 | SetWindowLongA(hwnd, DWL_MSGRESULT, hwndTabCtrl);
|
|---|
| 2496 |
|
|---|
| 2497 | return TRUE;
|
|---|
| 2498 | }
|
|---|
| 2499 |
|
|---|
| 2500 | case PSM_SETCURSEL:
|
|---|
| 2501 | {
|
|---|
| 2502 | BOOL msgResult;
|
|---|
| 2503 |
|
|---|
| 2504 | msgResult = PROPSHEET_CanSetCurSel(hwnd);
|
|---|
| 2505 | if(msgResult != FALSE)
|
|---|
| 2506 | {
|
|---|
| 2507 | msgResult = PROPSHEET_SetCurSel(hwnd,
|
|---|
| 2508 | (int)wParam,
|
|---|
| 2509 | (HPROPSHEETPAGE)lParam);
|
|---|
| 2510 | }
|
|---|
| 2511 |
|
|---|
| 2512 | SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
|
|---|
| 2513 |
|
|---|
| 2514 | return TRUE;
|
|---|
| 2515 | }
|
|---|
| 2516 |
|
|---|
| 2517 | case PSM_CANCELTOCLOSE:
|
|---|
| 2518 | {
|
|---|
| 2519 | char buf[MAX_BUTTONTEXT_LENGTH];
|
|---|
| 2520 | HWND hwndOK = GetDlgItem(hwnd, IDOK);
|
|---|
| 2521 | HWND hwndCancel = GetDlgItem(hwnd, IDCANCEL);
|
|---|
| 2522 |
|
|---|
| 2523 | EnableWindow(hwndCancel, FALSE);
|
|---|
| 2524 | if (LoadStringA(COMCTL32_hModule, IDS_CLOSE, buf, sizeof(buf)))
|
|---|
| 2525 | SetWindowTextA(hwndOK, buf);
|
|---|
| 2526 |
|
|---|
| 2527 | return FALSE;
|
|---|
| 2528 | }
|
|---|
| 2529 |
|
|---|
| 2530 | case PSM_RESTARTWINDOWS:
|
|---|
| 2531 | {
|
|---|
| 2532 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd,
|
|---|
| 2533 | PropSheetInfoStr);
|
|---|
| 2534 |
|
|---|
| 2535 | psInfo->restartWindows = TRUE;
|
|---|
| 2536 | return TRUE;
|
|---|
| 2537 | }
|
|---|
| 2538 |
|
|---|
| 2539 | case PSM_REBOOTSYSTEM:
|
|---|
| 2540 | {
|
|---|
| 2541 | PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd,
|
|---|
| 2542 | PropSheetInfoStr);
|
|---|
| 2543 |
|
|---|
| 2544 | psInfo->rebootSystem = TRUE;
|
|---|
| 2545 | return TRUE;
|
|---|
| 2546 | }
|
|---|
| 2547 |
|
|---|
| 2548 | case PSM_SETTITLEA:
|
|---|
| 2549 | PROPSHEET_SetTitleA(hwnd, (DWORD) wParam, (LPCSTR) lParam);
|
|---|
| 2550 | return TRUE;
|
|---|
| 2551 |
|
|---|
| 2552 | case PSM_APPLY:
|
|---|
| 2553 | {
|
|---|
| 2554 | BOOL msgResult = PROPSHEET_Apply(hwnd, 0);
|
|---|
| 2555 |
|
|---|
| 2556 | SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
|
|---|
| 2557 |
|
|---|
| 2558 | return TRUE;
|
|---|
| 2559 | }
|
|---|
| 2560 |
|
|---|
| 2561 | case PSM_QUERYSIBLINGS:
|
|---|
| 2562 | {
|
|---|
| 2563 | LRESULT msgResult = PROPSHEET_QuerySiblings(hwnd, wParam, lParam);
|
|---|
| 2564 |
|
|---|
| 2565 | SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
|
|---|
| 2566 |
|
|---|
| 2567 | return TRUE;
|
|---|
| 2568 | }
|
|---|
| 2569 |
|
|---|
| 2570 | case PSM_ADDPAGE:
|
|---|
| 2571 | {
|
|---|
| 2572 | /*
|
|---|
| 2573 | * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
|
|---|
| 2574 | * a return value. This is not true. PSM_ADDPAGE returns TRUE
|
|---|
| 2575 | * on success or FALSE otherwise, as specified on MSDN Online.
|
|---|
| 2576 | * Also see the MFC code for
|
|---|
| 2577 | * CPropertySheet::AddPage(CPropertyPage* pPage).
|
|---|
| 2578 | */
|
|---|
| 2579 |
|
|---|
| 2580 | BOOL msgResult = PROPSHEET_AddPage(hwnd, (HPROPSHEETPAGE)lParam);
|
|---|
| 2581 |
|
|---|
| 2582 | SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
|
|---|
| 2583 |
|
|---|
| 2584 | return TRUE;
|
|---|
| 2585 | }
|
|---|
| 2586 |
|
|---|
| 2587 | case PSM_REMOVEPAGE:
|
|---|
| 2588 | PROPSHEET_RemovePage(hwnd, (int)wParam, (HPROPSHEETPAGE)lParam);
|
|---|
| 2589 | return TRUE;
|
|---|
| 2590 |
|
|---|
| 2591 | case PSM_ISDIALOGMESSAGE:
|
|---|
| 2592 | {
|
|---|
| 2593 | BOOL msgResult = PROPSHEET_IsDialogMessage(hwnd, (LPMSG)lParam);
|
|---|
| 2594 | SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
|
|---|
| 2595 | return TRUE;
|
|---|
| 2596 | }
|
|---|
| 2597 |
|
|---|
| 2598 | case PSM_PRESSBUTTON:
|
|---|
| 2599 | PROPSHEET_PressButton(hwnd, (int)wParam);
|
|---|
| 2600 | return TRUE;
|
|---|
| 2601 |
|
|---|
| 2602 | case PSM_SETFINISHTEXTA:
|
|---|
| 2603 | PROPSHEET_SetFinishTextA(hwnd, (LPCSTR) lParam);
|
|---|
| 2604 | return TRUE;
|
|---|
| 2605 |
|
|---|
| 2606 | case PSM_SETWIZBUTTONS:
|
|---|
| 2607 | PROPSHEET_SetWizButtons(hwnd, (DWORD)lParam);
|
|---|
| 2608 | return TRUE;
|
|---|
| 2609 |
|
|---|
| 2610 | case PSM_SETTITLEW:
|
|---|
| 2611 | //FIXME("Unimplemented msg PSM_SETTITLE32W\n");
|
|---|
| 2612 | return 0;
|
|---|
| 2613 | case PSM_SETCURSELID:
|
|---|
| 2614 | //FIXME("Unimplemented msg PSM_SETCURSELID\n");
|
|---|
| 2615 | return 0;
|
|---|
| 2616 | case PSM_SETFINISHTEXTW:
|
|---|
| 2617 | //FIXME("Unimplemented msg PSM_SETFINISHTEXT32W\n");
|
|---|
| 2618 | return 0;
|
|---|
| 2619 |
|
|---|
| 2620 | default:
|
|---|
| 2621 | return FALSE;
|
|---|
| 2622 | }
|
|---|
| 2623 | }
|
|---|
| 2624 |
|
|---|