1998-12-10 16:49:22 +01:00
|
|
|
/*
|
|
|
|
* Property Sheets
|
|
|
|
*
|
|
|
|
* Copyright 1998 Francis Beaudet
|
1999-04-22 11:24:47 +02:00
|
|
|
* Copyright 1999 Thuy Nguyen
|
1998-12-10 16:49:22 +01:00
|
|
|
*
|
|
|
|
* TODO:
|
1999-09-19 14:14:38 +02:00
|
|
|
* - Tab order
|
1999-05-01 12:27:05 +02:00
|
|
|
* - Unicode property sheets
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
#include <string.h>
|
1999-03-16 11:53:11 +01:00
|
|
|
#include "winbase.h"
|
1998-12-10 16:49:22 +01:00
|
|
|
#include "commctrl.h"
|
1999-02-11 17:22:12 +01:00
|
|
|
#include "prsht.h"
|
1999-11-28 22:01:47 +01:00
|
|
|
#include "dialog.h"
|
|
|
|
#include "win.h"
|
1999-04-22 11:24:47 +02:00
|
|
|
#include "winnls.h"
|
1999-05-22 12:52:31 +02:00
|
|
|
#include "comctl32.h"
|
1999-06-12 17:45:58 +02:00
|
|
|
#include "debugtools.h"
|
1999-08-18 20:25:46 +02:00
|
|
|
#include "heap.h"
|
1998-12-10 16:49:22 +01:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Data structures
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
WORD dlgVer;
|
|
|
|
WORD signature;
|
|
|
|
DWORD helpID;
|
|
|
|
DWORD exStyle;
|
|
|
|
DWORD style;
|
|
|
|
} MyDLGTEMPLATEEX;
|
|
|
|
|
|
|
|
typedef struct tagPropPageInfo
|
|
|
|
{
|
1999-05-01 12:27:05 +02:00
|
|
|
HPROPSHEETPAGE hpage; /* to keep track of pages not passed to PropertySheet */
|
1999-04-22 11:24:47 +02:00
|
|
|
HWND hwndPage;
|
|
|
|
BOOL isDirty;
|
|
|
|
LPCWSTR pszText;
|
|
|
|
BOOL hasHelp;
|
|
|
|
BOOL useCallback;
|
1999-11-28 22:01:47 +01:00
|
|
|
BOOL hasIcon;
|
1999-04-22 11:24:47 +02:00
|
|
|
} PropPageInfo;
|
|
|
|
|
|
|
|
typedef struct tagPropSheetInfo
|
|
|
|
{
|
2000-07-08 14:48:13 +02:00
|
|
|
HWND hwnd;
|
|
|
|
PROPSHEETHEADERA ppshheader;
|
1999-04-22 11:24:47 +02:00
|
|
|
LPSTR strPropertiesFor;
|
1999-05-01 12:27:05 +02:00
|
|
|
int nPages;
|
1999-04-22 11:24:47 +02:00
|
|
|
int active_page;
|
|
|
|
BOOL isModeless;
|
|
|
|
BOOL hasHelp;
|
|
|
|
BOOL hasApply;
|
|
|
|
BOOL useCallback;
|
|
|
|
BOOL restartWindows;
|
|
|
|
BOOL rebootSystem;
|
1999-11-28 22:01:47 +01:00
|
|
|
BOOL activeValid;
|
1999-04-22 11:24:47 +02:00
|
|
|
PropPageInfo* proppage;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int width;
|
|
|
|
int height;
|
1999-08-14 17:51:10 +02:00
|
|
|
HIMAGELIST hImageList;
|
1999-04-22 11:24:47 +02:00
|
|
|
} PropSheetInfo;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
} PADDING_INFO;
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Defines and global variables
|
|
|
|
*/
|
1999-05-01 12:27:05 +02:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
const char * PropSheetInfoStr = "PropertySheetInfo";
|
|
|
|
|
|
|
|
#define MAX_CAPTION_LENGTH 255
|
1999-05-01 12:27:05 +02:00
|
|
|
#define MAX_TABTEXT_LENGTH 255
|
1999-11-28 22:01:47 +01:00
|
|
|
#define MAX_BUTTONTEXT_LENGTH 64
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Prototypes
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_CreateDialog(PropSheetInfo* psInfo);
|
2000-02-25 21:49:49 +01:00
|
|
|
static BOOL PROPSHEET_SizeMismatch(HWND hwndDlg, PropSheetInfo* psInfo);
|
1999-04-22 11:24:47 +02:00
|
|
|
static BOOL PROPSHEET_AdjustSize(HWND hwndDlg, PropSheetInfo* psInfo);
|
|
|
|
static BOOL PROPSHEET_AdjustButtons(HWND hwndParent, PropSheetInfo* psInfo);
|
|
|
|
static BOOL PROPSHEET_CollectSheetInfo(LPCPROPSHEETHEADERA lppsh,
|
|
|
|
PropSheetInfo * psInfo);
|
1999-05-01 12:27:05 +02:00
|
|
|
static BOOL PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEA lppsp,
|
|
|
|
PropSheetInfo * psInfo,
|
|
|
|
int index);
|
1999-04-22 11:24:47 +02:00
|
|
|
static BOOL PROPSHEET_CreateTabControl(HWND hwndParent,
|
|
|
|
PropSheetInfo * psInfo);
|
|
|
|
static int PROPSHEET_CreatePage(HWND hwndParent, int index,
|
1999-05-01 12:27:05 +02:00
|
|
|
const PropSheetInfo * psInfo,
|
1999-11-28 22:01:47 +01:00
|
|
|
LPCPROPSHEETPAGEA ppshpage);
|
1999-04-22 11:24:47 +02:00
|
|
|
static BOOL PROPSHEET_ShowPage(HWND hwndDlg, int index, PropSheetInfo * psInfo);
|
|
|
|
static PADDING_INFO PROPSHEET_GetPaddingInfo(HWND hwndDlg);
|
1999-09-19 14:14:38 +02:00
|
|
|
static BOOL PROPSHEET_Back(HWND hwndDlg);
|
|
|
|
static BOOL PROPSHEET_Next(HWND hwndDlg);
|
|
|
|
static BOOL PROPSHEET_Finish(HWND hwndDlg);
|
1999-11-28 22:01:47 +01:00
|
|
|
static BOOL PROPSHEET_Apply(HWND hwndDlg, LPARAM lParam);
|
|
|
|
static void PROPSHEET_Cancel(HWND hwndDlg, LPARAM lParam);
|
1999-05-01 12:27:05 +02:00
|
|
|
static void PROPSHEET_Help(HWND hwndDlg);
|
1999-04-22 11:24:47 +02:00
|
|
|
static void PROPSHEET_Changed(HWND hwndDlg, HWND hwndDirtyPage);
|
|
|
|
static void PROPSHEET_UnChanged(HWND hwndDlg, HWND hwndCleanPage);
|
|
|
|
static void PROPSHEET_PressButton(HWND hwndDlg, int buttonID);
|
1999-09-19 14:14:38 +02:00
|
|
|
static void PROPSHEET_SetFinishTextA(HWND hwndDlg, LPCSTR lpszText);
|
1999-04-22 11:24:47 +02:00
|
|
|
static void PROPSHEET_SetTitleA(HWND hwndDlg, DWORD dwStyle, LPCSTR lpszText);
|
1999-10-13 17:54:08 +02:00
|
|
|
static BOOL PROPSHEET_CanSetCurSel(HWND hwndDlg);
|
1999-04-22 11:24:47 +02:00
|
|
|
static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
|
|
|
|
int index,
|
|
|
|
HPROPSHEETPAGE hpage);
|
|
|
|
static LRESULT PROPSHEET_QuerySiblings(HWND hwndDlg,
|
|
|
|
WPARAM wParam, LPARAM lParam);
|
|
|
|
static BOOL PROPSHEET_AddPage(HWND hwndDlg,
|
|
|
|
HPROPSHEETPAGE hpage);
|
|
|
|
|
|
|
|
static BOOL PROPSHEET_RemovePage(HWND hwndDlg,
|
|
|
|
int index,
|
|
|
|
HPROPSHEETPAGE hpage);
|
|
|
|
static void PROPSHEET_CleanUp();
|
1999-05-01 12:27:05 +02:00
|
|
|
static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage, PropSheetInfo* psInfo);
|
1999-09-19 14:14:38 +02:00
|
|
|
static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags);
|
|
|
|
static PADDING_INFO PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg);
|
1999-11-28 22:01:47 +01:00
|
|
|
static BOOL PROPSHEET_IsDialogMessage(HWND hwnd, LPMSG lpMsg);
|
|
|
|
static INT PROPSHEET_DoDialogBox( HWND hwnd, HWND owner);
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
BOOL WINAPI
|
|
|
|
PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
1999-04-19 16:56:29 +02:00
|
|
|
DEFAULT_DEBUG_CHANNEL(propsheet)
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_CollectSheetInfo
|
|
|
|
*
|
|
|
|
* Collect relevant data.
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_CollectSheetInfo(LPCPROPSHEETHEADERA lppsh,
|
|
|
|
PropSheetInfo * psInfo)
|
|
|
|
{
|
2000-07-08 14:48:13 +02:00
|
|
|
DWORD dwSize = min(lppsh->dwSize,sizeof(PROPSHEETHEADERA));
|
1999-04-22 11:24:47 +02:00
|
|
|
DWORD dwFlags = lppsh->dwFlags;
|
|
|
|
|
|
|
|
psInfo->hasHelp = dwFlags & PSH_HASHELP;
|
|
|
|
psInfo->hasApply = !(dwFlags & PSH_NOAPPLYNOW);
|
|
|
|
psInfo->useCallback = dwFlags & PSH_USECALLBACK;
|
|
|
|
psInfo->isModeless = dwFlags & PSH_MODELESS;
|
1999-11-28 22:01:47 +01:00
|
|
|
|
2000-07-08 14:48:13 +02:00
|
|
|
memcpy(&psInfo->ppshheader,lppsh,dwSize);
|
1999-11-28 22:01:47 +01:00
|
|
|
|
|
|
|
if (HIWORD(lppsh->pszCaption))
|
2000-07-08 14:48:13 +02:00
|
|
|
psInfo->ppshheader.pszCaption = HEAP_strdupA( GetProcessHeap(),
|
1999-11-28 22:01:47 +01:00
|
|
|
0, lppsh->pszCaption );
|
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
psInfo->nPages = lppsh->nPages;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
if (dwFlags & PSH_USEPSTARTPAGE)
|
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("PSH_USEPSTARTPAGE is on");
|
1999-04-22 11:24:47 +02:00
|
|
|
psInfo->active_page = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
psInfo->active_page = lppsh->u2.nStartPage;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if (psInfo->active_page < 0 || psInfo->active_page >= psInfo->nPages)
|
|
|
|
psInfo->active_page = 0;
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
psInfo->restartWindows = FALSE;
|
|
|
|
psInfo->rebootSystem = FALSE;
|
1999-08-14 17:51:10 +02:00
|
|
|
psInfo->hImageList = 0;
|
1999-11-28 22:01:47 +01:00
|
|
|
psInfo->activeValid = FALSE;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_CollectPageInfo
|
|
|
|
*
|
|
|
|
* Collect property sheet data.
|
|
|
|
* With code taken from DIALOG_ParseTemplate32.
|
|
|
|
*/
|
1999-05-01 12:27:05 +02:00
|
|
|
BOOL PROPSHEET_CollectPageInfo(LPCPROPSHEETPAGEA lppsp,
|
|
|
|
PropSheetInfo * psInfo,
|
|
|
|
int index)
|
1999-04-22 11:24:47 +02:00
|
|
|
{
|
|
|
|
DLGTEMPLATE* pTemplate;
|
|
|
|
const WORD* p;
|
|
|
|
DWORD dwFlags;
|
|
|
|
int width, height;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
psInfo->proppage[index].hpage = (HPROPSHEETPAGE)lppsp;
|
1999-05-01 12:27:05 +02:00
|
|
|
psInfo->proppage[index].hwndPage = 0;
|
|
|
|
psInfo->proppage[index].isDirty = FALSE;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
/*
|
|
|
|
* Process property page flags.
|
|
|
|
*/
|
|
|
|
dwFlags = lppsp->dwFlags;
|
|
|
|
psInfo->proppage[index].useCallback = dwFlags & PSP_USECALLBACK;
|
|
|
|
psInfo->proppage[index].hasHelp = dwFlags & PSP_HASHELP;
|
1999-11-28 22:01:47 +01:00
|
|
|
psInfo->proppage[index].hasIcon = dwFlags & (PSP_USEHICON | PSP_USEICONID);
|
1999-05-01 12:27:05 +02:00
|
|
|
|
|
|
|
/* as soon as we have a page with the help flag, set the sheet flag on */
|
|
|
|
if (psInfo->proppage[index].hasHelp)
|
|
|
|
psInfo->hasHelp = TRUE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process page template.
|
|
|
|
*/
|
|
|
|
if (dwFlags & PSP_DLGINDIRECT)
|
|
|
|
pTemplate = (DLGTEMPLATE*)lppsp->u1.pResource;
|
|
|
|
else
|
1999-04-22 11:24:47 +02:00
|
|
|
{
|
1999-05-01 12:27:05 +02:00
|
|
|
HRSRC hResource = FindResourceA(lppsp->hInstance,
|
|
|
|
lppsp->u1.pszTemplate,
|
|
|
|
RT_DIALOGA);
|
|
|
|
HGLOBAL hTemplate = LoadResource(lppsp->hInstance,
|
|
|
|
hResource);
|
|
|
|
pTemplate = (LPDLGTEMPLATEA)LockResource(hTemplate);
|
|
|
|
}
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
/*
|
|
|
|
* Extract the size of the page and the caption.
|
|
|
|
*/
|
2000-02-25 21:49:49 +01:00
|
|
|
if (!pTemplate)
|
|
|
|
return FALSE;
|
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
p = (const WORD *)pTemplate;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
if (((MyDLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF)
|
|
|
|
{
|
|
|
|
/* DIALOGEX template */
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
p++; /* dlgVer */
|
|
|
|
p++; /* signature */
|
|
|
|
p += 2; /* help ID */
|
|
|
|
p += 2; /* ext style */
|
|
|
|
p += 2; /* style */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* DIALOG template */
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
p += 2; /* style */
|
|
|
|
p += 2; /* ext style */
|
|
|
|
}
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
p++; /* nb items */
|
|
|
|
p++; /* x */
|
|
|
|
p++; /* y */
|
|
|
|
width = (WORD)*p; p++;
|
|
|
|
height = (WORD)*p; p++;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
/* remember the largest width and height */
|
|
|
|
if (width > psInfo->width)
|
|
|
|
psInfo->width = width;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
if (height > psInfo->height)
|
|
|
|
psInfo->height = height;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
/* menu */
|
|
|
|
switch ((WORD)*p)
|
|
|
|
{
|
|
|
|
case 0x0000:
|
|
|
|
p++;
|
|
|
|
break;
|
|
|
|
case 0xffff:
|
|
|
|
p += 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
p += lstrlenW( (LPCWSTR)p ) + 1;
|
|
|
|
break;
|
|
|
|
}
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
/* class */
|
|
|
|
switch ((WORD)*p)
|
|
|
|
{
|
|
|
|
case 0x0000:
|
|
|
|
p++;
|
|
|
|
break;
|
|
|
|
case 0xffff:
|
|
|
|
p += 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
p += lstrlenW( (LPCWSTR)p ) + 1;
|
|
|
|
break;
|
1999-04-22 11:24:47 +02:00
|
|
|
}
|
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
/* Extract the caption */
|
|
|
|
psInfo->proppage[index].pszText = (LPCWSTR)p;
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("Tab %d %s\n",index,debugstr_w((LPCWSTR)p));
|
1999-05-01 12:27:05 +02:00
|
|
|
p += lstrlenW((LPCWSTR)p) + 1;
|
|
|
|
|
1999-08-18 20:25:46 +02:00
|
|
|
if (dwFlags & PSP_USETITLE)
|
|
|
|
{
|
1999-10-23 20:59:01 +02:00
|
|
|
if ( !HIWORD( lppsp->pszTitle ) )
|
|
|
|
{
|
|
|
|
char szTitle[256];
|
|
|
|
|
|
|
|
if ( !LoadStringA( lppsp->hInstance, (UINT) lppsp->pszTitle, szTitle, 256 ) )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
psInfo->proppage[index].pszText = HEAP_strdupAtoW( GetProcessHeap(),
|
|
|
|
0, szTitle );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
psInfo->proppage[index].pszText = HEAP_strdupAtoW(GetProcessHeap(),
|
|
|
|
0,
|
|
|
|
lppsp->pszTitle);
|
1999-08-18 20:25:46 +02:00
|
|
|
}
|
|
|
|
|
1999-08-14 17:51:10 +02:00
|
|
|
/*
|
|
|
|
* Build the image list for icons
|
|
|
|
*/
|
1999-10-23 20:59:01 +02:00
|
|
|
if ((dwFlags & PSP_USEHICON) || (dwFlags & PSP_USEICONID))
|
1999-08-14 17:51:10 +02:00
|
|
|
{
|
|
|
|
HICON hIcon;
|
|
|
|
int icon_cx = GetSystemMetrics(SM_CXSMICON);
|
|
|
|
int icon_cy = GetSystemMetrics(SM_CYSMICON);
|
|
|
|
|
|
|
|
if (dwFlags & PSP_USEICONID)
|
|
|
|
hIcon = LoadImageA(lppsp->hInstance, lppsp->u2.pszIcon, IMAGE_ICON,
|
|
|
|
icon_cx, icon_cy, LR_DEFAULTCOLOR);
|
|
|
|
else
|
|
|
|
hIcon = lppsp->u2.hIcon;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if ( hIcon )
|
|
|
|
{
|
|
|
|
if (psInfo->hImageList == 0 )
|
|
|
|
psInfo->hImageList = ImageList_Create(icon_cx, icon_cy, ILC_COLOR, 1, 1);
|
|
|
|
|
|
|
|
ImageList_AddIcon(psInfo->hImageList, hIcon);
|
|
|
|
}
|
1999-08-14 17:51:10 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_DoDialogBox
|
|
|
|
*
|
|
|
|
* Copied from windows/dialog.c:DIALOG_DoDialogBox
|
|
|
|
*/
|
|
|
|
static INT PROPSHEET_DoDialogBox( HWND hwnd, HWND owner)
|
|
|
|
{
|
|
|
|
WND * wndPtr;
|
|
|
|
DIALOGINFO * dlgInfo;
|
|
|
|
MSG msg;
|
|
|
|
INT retval;
|
|
|
|
|
|
|
|
/* Owner must be a top-level window */
|
|
|
|
owner = WIN_GetTopParent( owner );
|
|
|
|
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return -1;
|
|
|
|
dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
|
|
|
|
|
|
|
|
if (!dlgInfo->flags & DF_END) /* was EndDialog called in WM_INITDIALOG ? */
|
|
|
|
{
|
|
|
|
EnableWindow( owner, FALSE );
|
|
|
|
ShowWindow( hwnd, SW_SHOW );
|
|
|
|
while (GetMessageA(&msg, 0, 0, 0))
|
|
|
|
{
|
|
|
|
if (!PROPSHEET_IsDialogMessage( hwnd, &msg))
|
|
|
|
{
|
|
|
|
TranslateMessage( &msg );
|
|
|
|
DispatchMessageA( &msg );
|
|
|
|
}
|
|
|
|
if (dlgInfo->flags & DF_END) break;
|
|
|
|
}
|
|
|
|
EnableWindow( owner, TRUE );
|
|
|
|
}
|
|
|
|
retval = dlgInfo->idResult;
|
|
|
|
WIN_ReleaseWndPtr(wndPtr);
|
|
|
|
DestroyWindow( hwnd );
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_CreateDialog
|
|
|
|
*
|
|
|
|
* Creates the actual property sheet.
|
|
|
|
*/
|
|
|
|
BOOL PROPSHEET_CreateDialog(PropSheetInfo* psInfo)
|
|
|
|
{
|
|
|
|
LRESULT ret;
|
|
|
|
LPCVOID template;
|
1999-09-04 13:09:20 +02:00
|
|
|
LPVOID temp = 0;
|
1999-04-25 20:31:35 +02:00
|
|
|
HRSRC hRes;
|
1999-09-04 13:09:20 +02:00
|
|
|
DWORD resSize;
|
1999-09-19 14:14:38 +02:00
|
|
|
WORD resID = IDD_PROPSHEET;
|
|
|
|
|
2000-07-08 14:48:13 +02:00
|
|
|
if (psInfo->ppshheader.dwFlags & PSH_WIZARD)
|
1999-09-19 14:14:38 +02:00
|
|
|
resID = IDD_WIZARD;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
if(!(hRes = FindResourceA(COMCTL32_hModule,
|
1999-09-19 14:14:38 +02:00
|
|
|
MAKEINTRESOURCEA(resID),
|
1999-05-01 12:27:05 +02:00
|
|
|
RT_DIALOGA)))
|
1999-04-25 20:31:35 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if(!(template = (LPVOID)LoadResource(COMCTL32_hModule, hRes)))
|
|
|
|
return FALSE;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-09-04 13:09:20 +02:00
|
|
|
/*
|
|
|
|
* Make a copy of the dialog template.
|
|
|
|
*/
|
|
|
|
resSize = SizeofResource(COMCTL32_hModule, hRes);
|
|
|
|
|
|
|
|
temp = COMCTL32_Alloc(resSize);
|
|
|
|
|
|
|
|
if (!temp)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
memcpy(temp, template, resSize);
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
if (psInfo->useCallback)
|
2000-07-08 14:48:13 +02:00
|
|
|
(*(psInfo->ppshheader.pfnCallback))(0, PSCB_PRECREATE, (LPARAM)temp);
|
1999-04-22 11:24:47 +02:00
|
|
|
|
2000-07-08 14:48:13 +02:00
|
|
|
ret = CreateDialogIndirectParamA(psInfo->ppshheader.hInstance,
|
1999-09-04 13:09:20 +02:00
|
|
|
(LPDLGTEMPLATEA) temp,
|
2000-07-08 14:48:13 +02:00
|
|
|
psInfo->ppshheader.hwndParent,
|
1999-04-22 11:24:47 +02:00
|
|
|
(DLGPROC) PROPSHEET_DialogProc,
|
|
|
|
(LPARAM)psInfo);
|
|
|
|
|
2000-07-08 14:48:13 +02:00
|
|
|
if (!(psInfo->ppshheader.dwFlags & PSH_MODELESS))
|
|
|
|
ret = PROPSHEET_DoDialogBox((HWND)ret, psInfo->ppshheader.hwndParent);
|
1999-11-28 22:01:47 +01:00
|
|
|
|
1999-09-04 13:09:20 +02:00
|
|
|
COMCTL32_Free(temp);
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-02-25 21:49:49 +01:00
|
|
|
* PROPSHEET_SizeMismatch
|
1999-04-22 11:24:47 +02:00
|
|
|
*
|
2000-02-25 21:49:49 +01:00
|
|
|
* Verify that the tab control and the "largest" property sheet page dlg. template
|
|
|
|
* match in size.
|
1999-04-22 11:24:47 +02:00
|
|
|
*/
|
2000-02-25 21:49:49 +01:00
|
|
|
static BOOL PROPSHEET_SizeMismatch(HWND hwndDlg, PropSheetInfo* psInfo)
|
1999-04-22 11:24:47 +02:00
|
|
|
{
|
|
|
|
HWND hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|
|
|
RECT rcOrigTab, rcPage;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Original tab size.
|
|
|
|
*/
|
|
|
|
GetClientRect(hwndTabCtrl, &rcOrigTab);
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("orig tab %d %d %d %d\n", rcOrigTab.left, rcOrigTab.top,
|
1999-04-22 11:24:47 +02:00
|
|
|
rcOrigTab.right, rcOrigTab.bottom);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Biggest page size.
|
|
|
|
*/
|
|
|
|
rcPage.left = psInfo->x;
|
|
|
|
rcPage.top = psInfo->y;
|
|
|
|
rcPage.right = psInfo->width;
|
|
|
|
rcPage.bottom = psInfo->height;
|
|
|
|
|
|
|
|
MapDialogRect(hwndDlg, &rcPage);
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("biggest page %d %d %d %d\n", rcPage.left, rcPage.top,
|
1999-04-22 11:24:47 +02:00
|
|
|
rcPage.right, rcPage.bottom);
|
|
|
|
|
2000-02-25 21:49:49 +01:00
|
|
|
if ( (rcPage.right - rcPage.left) != (rcOrigTab.right - rcOrigTab.left) )
|
1999-04-22 11:24:47 +02:00
|
|
|
return TRUE;
|
2000-02-25 21:49:49 +01:00
|
|
|
if ( (rcPage.bottom - rcPage.top) != (rcOrigTab.bottom - rcOrigTab.top) )
|
1999-04-22 11:24:47 +02:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_IsTooSmallWizard
|
|
|
|
*
|
|
|
|
* Verify that the default property sheet is big enough.
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_IsTooSmallWizard(HWND hwndDlg, PropSheetInfo* psInfo)
|
|
|
|
{
|
|
|
|
RECT rcSheetRect, rcPage, rcLine, rcSheetClient;
|
|
|
|
HWND hwndLine = GetDlgItem(hwndDlg, IDC_SUNKEN_LINE);
|
|
|
|
PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndDlg);
|
|
|
|
|
|
|
|
GetClientRect(hwndDlg, &rcSheetClient);
|
|
|
|
GetWindowRect(hwndDlg, &rcSheetRect);
|
|
|
|
GetWindowRect(hwndLine, &rcLine);
|
|
|
|
|
|
|
|
/* Remove the space below the sunken line */
|
|
|
|
rcSheetClient.bottom -= (rcSheetRect.bottom - rcLine.top);
|
|
|
|
|
|
|
|
/* Remove the buffer zone all around the edge */
|
|
|
|
rcSheetClient.bottom -= (padding.y * 2);
|
|
|
|
rcSheetClient.right -= (padding.x * 2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Biggest page size.
|
|
|
|
*/
|
|
|
|
rcPage.left = psInfo->x;
|
|
|
|
rcPage.top = psInfo->y;
|
|
|
|
rcPage.right = psInfo->width;
|
|
|
|
rcPage.bottom = psInfo->height;
|
|
|
|
|
|
|
|
MapDialogRect(hwndDlg, &rcPage);
|
|
|
|
TRACE("biggest page %d %d %d %d\n", rcPage.left, rcPage.top,
|
|
|
|
rcPage.right, rcPage.bottom);
|
|
|
|
|
|
|
|
if (rcPage.right > rcSheetClient.right)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (rcPage.bottom > rcSheetClient.bottom)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_AdjustSize
|
|
|
|
*
|
|
|
|
* Resizes the property sheet and the tab control to fit the largest page.
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_AdjustSize(HWND hwndDlg, PropSheetInfo* psInfo)
|
|
|
|
{
|
|
|
|
HWND hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|
|
|
HWND hwndButton = GetDlgItem(hwndDlg, IDOK);
|
2000-02-25 21:49:49 +01:00
|
|
|
RECT rc,tabRect;
|
1999-04-22 11:24:47 +02:00
|
|
|
int tabOffsetX, tabOffsetY, buttonHeight;
|
|
|
|
PADDING_INFO padding = PROPSHEET_GetPaddingInfo(hwndDlg);
|
2000-02-25 21:49:49 +01:00
|
|
|
WND * wndPtr = WIN_FindWndPtr( hwndDlg );
|
|
|
|
DIALOGINFO * dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
/* Get the height of buttons */
|
|
|
|
GetClientRect(hwndButton, &rc);
|
|
|
|
buttonHeight = rc.bottom;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Biggest page size.
|
|
|
|
*/
|
|
|
|
rc.left = psInfo->x;
|
|
|
|
rc.top = psInfo->y;
|
|
|
|
rc.right = psInfo->width;
|
|
|
|
rc.bottom = psInfo->height;
|
|
|
|
|
|
|
|
MapDialogRect(hwndDlg, &rc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Resize the tab control.
|
|
|
|
*/
|
2000-02-25 21:49:49 +01:00
|
|
|
GetClientRect(hwndTabCtrl,&tabRect);
|
|
|
|
|
|
|
|
SendMessageA(hwndTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM)&tabRect);
|
|
|
|
|
|
|
|
if ((rc.bottom - rc.top) < (tabRect.bottom - tabRect.top))
|
|
|
|
{
|
|
|
|
rc.bottom = rc.top + tabRect.bottom - tabRect.top;
|
|
|
|
psInfo->height = MulDiv((rc.bottom - rc.top),8,dlgInfo->yBaseUnit);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((rc.right - rc.left) < (tabRect.right - tabRect.left))
|
|
|
|
{
|
|
|
|
rc.right = rc.left + tabRect.right - tabRect.left;
|
|
|
|
psInfo->width = MulDiv((rc.right - rc.left),4,dlgInfo->xBaseUnit);
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
SendMessageA(hwndTabCtrl, TCM_ADJUSTRECT, TRUE, (LPARAM)&rc);
|
|
|
|
|
|
|
|
tabOffsetX = -(rc.left);
|
|
|
|
tabOffsetY = -(rc.top);
|
|
|
|
|
|
|
|
rc.right -= rc.left;
|
|
|
|
rc.bottom -= rc.top;
|
|
|
|
SetWindowPos(hwndTabCtrl, 0, 0, 0, rc.right, rc.bottom,
|
|
|
|
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
GetClientRect(hwndTabCtrl, &rc);
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("tab client rc %d %d %d %d\n",
|
1999-04-22 11:24:47 +02:00
|
|
|
rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
|
|
|
|
rc.right += ((padding.x * 2) + tabOffsetX);
|
|
|
|
rc.bottom += (buttonHeight + (3 * padding.y) + tabOffsetY);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Resize the property sheet.
|
|
|
|
*/
|
|
|
|
SetWindowPos(hwndDlg, 0, 0, 0, rc.right, rc.bottom,
|
|
|
|
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
|
2000-02-25 21:49:49 +01:00
|
|
|
WIN_ReleaseWndPtr(wndPtr);
|
1999-04-22 11:24:47 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_AdjustSizeWizard
|
|
|
|
*
|
|
|
|
* Resizes the property sheet to fit the largest page.
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_AdjustSizeWizard(HWND hwndDlg, PropSheetInfo* psInfo)
|
|
|
|
{
|
|
|
|
HWND hwndButton = GetDlgItem(hwndDlg, IDCANCEL);
|
|
|
|
HWND hwndLine = GetDlgItem(hwndDlg, IDC_SUNKEN_LINE);
|
2000-02-25 21:49:49 +01:00
|
|
|
HWND hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|
|
|
RECT rc,tabRect;
|
1999-09-19 14:14:38 +02:00
|
|
|
int buttonHeight, lineHeight;
|
|
|
|
PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndDlg);
|
2000-02-25 21:49:49 +01:00
|
|
|
WND * wndPtr = WIN_FindWndPtr( hwndDlg );
|
|
|
|
DIALOGINFO * dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
|
1999-09-19 14:14:38 +02:00
|
|
|
|
|
|
|
/* Get the height of buttons */
|
|
|
|
GetClientRect(hwndButton, &rc);
|
|
|
|
buttonHeight = rc.bottom;
|
|
|
|
|
|
|
|
GetClientRect(hwndLine, &rc);
|
|
|
|
lineHeight = rc.bottom;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Biggest page size.
|
|
|
|
*/
|
|
|
|
rc.left = psInfo->x;
|
|
|
|
rc.top = psInfo->y;
|
|
|
|
rc.right = psInfo->width;
|
|
|
|
rc.bottom = psInfo->height;
|
|
|
|
|
|
|
|
MapDialogRect(hwndDlg, &rc);
|
|
|
|
|
2000-02-25 21:49:49 +01:00
|
|
|
GetClientRect(hwndTabCtrl,&tabRect);
|
|
|
|
|
|
|
|
if ((rc.bottom - rc.top) < (tabRect.bottom - tabRect.top))
|
|
|
|
{
|
|
|
|
rc.bottom = rc.top + tabRect.bottom - tabRect.top;
|
|
|
|
psInfo->height = MulDiv((rc.bottom - rc.top), 8, dlgInfo->yBaseUnit);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((rc.right - rc.left) < (tabRect.right - tabRect.left))
|
|
|
|
{
|
|
|
|
rc.right = rc.left + tabRect.right - tabRect.left;
|
|
|
|
psInfo->width = MulDiv((rc.right - rc.left), 4, dlgInfo->xBaseUnit);
|
|
|
|
}
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
TRACE("Biggest page %d %d %d %d\n", rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
|
|
|
|
/* Make room */
|
|
|
|
rc.right += (padding.x * 2);
|
|
|
|
rc.bottom += (buttonHeight + (5 * padding.y) + lineHeight);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Resize the property sheet.
|
|
|
|
*/
|
|
|
|
SetWindowPos(hwndDlg, 0, 0, 0, rc.right, rc.bottom,
|
|
|
|
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
|
2000-02-25 21:49:49 +01:00
|
|
|
WIN_ReleaseWndPtr(wndPtr);
|
1999-09-19 14:14:38 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_AdjustButtons
|
|
|
|
*
|
|
|
|
* Adjusts the buttons' positions.
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_AdjustButtons(HWND hwndParent, PropSheetInfo* psInfo)
|
|
|
|
{
|
|
|
|
HWND hwndButton = GetDlgItem(hwndParent, IDOK);
|
|
|
|
RECT rcSheet;
|
|
|
|
int x, y;
|
|
|
|
int num_buttons = 2;
|
|
|
|
int buttonWidth, buttonHeight;
|
|
|
|
PADDING_INFO padding = PROPSHEET_GetPaddingInfo(hwndParent);
|
|
|
|
|
|
|
|
if (psInfo->hasApply)
|
|
|
|
num_buttons++;
|
|
|
|
|
|
|
|
if (psInfo->hasHelp)
|
|
|
|
num_buttons++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Obtain the size of the buttons.
|
|
|
|
*/
|
|
|
|
GetClientRect(hwndButton, &rcSheet);
|
|
|
|
buttonWidth = rcSheet.right;
|
|
|
|
buttonHeight = rcSheet.bottom;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the size of the property sheet.
|
|
|
|
*/
|
|
|
|
GetClientRect(hwndParent, &rcSheet);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All buttons will be at this y coordinate.
|
|
|
|
*/
|
|
|
|
y = rcSheet.bottom - (padding.y + buttonHeight);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Position OK button.
|
|
|
|
*/
|
|
|
|
hwndButton = GetDlgItem(hwndParent, IDOK);
|
|
|
|
|
|
|
|
x = rcSheet.right - ((padding.x + buttonWidth) * num_buttons);
|
|
|
|
|
|
|
|
SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Position Cancel button.
|
|
|
|
*/
|
|
|
|
hwndButton = GetDlgItem(hwndParent, IDCANCEL);
|
|
|
|
|
|
|
|
x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 1));
|
|
|
|
|
|
|
|
SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Position Apply button.
|
|
|
|
*/
|
|
|
|
hwndButton = GetDlgItem(hwndParent, IDC_APPLY_BUTTON);
|
|
|
|
|
|
|
|
if (psInfo->hasApply)
|
|
|
|
{
|
|
|
|
if (psInfo->hasHelp)
|
|
|
|
x = rcSheet.right - ((padding.x + buttonWidth) * 2);
|
|
|
|
else
|
|
|
|
x = rcSheet.right - (padding.x + buttonWidth);
|
|
|
|
|
|
|
|
SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
EnableWindow(hwndButton, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ShowWindow(hwndButton, SW_HIDE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Position Help button.
|
|
|
|
*/
|
|
|
|
hwndButton = GetDlgItem(hwndParent, IDHELP);
|
|
|
|
|
|
|
|
if (psInfo->hasHelp)
|
|
|
|
{
|
|
|
|
x = rcSheet.right - (padding.x + buttonWidth);
|
|
|
|
|
|
|
|
SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ShowWindow(hwndButton, SW_HIDE);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_AdjustButtonsWizard
|
|
|
|
*
|
|
|
|
* Adjusts the buttons' positions.
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_AdjustButtonsWizard(HWND hwndParent,
|
|
|
|
PropSheetInfo* psInfo)
|
|
|
|
{
|
|
|
|
HWND hwndButton = GetDlgItem(hwndParent, IDCANCEL);
|
|
|
|
HWND hwndLine = GetDlgItem(hwndParent, IDC_SUNKEN_LINE);
|
|
|
|
RECT rcSheet;
|
|
|
|
int x, y;
|
|
|
|
int num_buttons = 3;
|
|
|
|
int buttonWidth, buttonHeight, lineHeight, lineWidth;
|
|
|
|
PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndParent);
|
|
|
|
|
|
|
|
if (psInfo->hasHelp)
|
|
|
|
num_buttons++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Obtain the size of the buttons.
|
|
|
|
*/
|
|
|
|
GetClientRect(hwndButton, &rcSheet);
|
|
|
|
buttonWidth = rcSheet.right;
|
|
|
|
buttonHeight = rcSheet.bottom;
|
|
|
|
|
|
|
|
GetClientRect(hwndLine, &rcSheet);
|
|
|
|
lineHeight = rcSheet.bottom;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the size of the property sheet.
|
|
|
|
*/
|
|
|
|
GetClientRect(hwndParent, &rcSheet);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All buttons will be at this y coordinate.
|
|
|
|
*/
|
|
|
|
y = rcSheet.bottom - (padding.y + buttonHeight);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Position the Next and the Finish buttons.
|
|
|
|
*/
|
|
|
|
hwndButton = GetDlgItem(hwndParent, IDC_NEXT_BUTTON);
|
|
|
|
|
|
|
|
x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 1));
|
|
|
|
|
|
|
|
SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
hwndButton = GetDlgItem(hwndParent, IDC_FINISH_BUTTON);
|
|
|
|
|
|
|
|
SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
ShowWindow(hwndButton, SW_HIDE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Position the Back button.
|
|
|
|
*/
|
|
|
|
hwndButton = GetDlgItem(hwndParent, IDC_BACK_BUTTON);
|
|
|
|
|
|
|
|
x -= buttonWidth;
|
|
|
|
|
|
|
|
SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Position the Cancel button.
|
|
|
|
*/
|
|
|
|
hwndButton = GetDlgItem(hwndParent, IDCANCEL);
|
|
|
|
|
|
|
|
x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 2));
|
|
|
|
|
|
|
|
SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Position Help button.
|
|
|
|
*/
|
|
|
|
hwndButton = GetDlgItem(hwndParent, IDHELP);
|
|
|
|
|
|
|
|
if (psInfo->hasHelp)
|
|
|
|
{
|
|
|
|
x = rcSheet.right - (padding.x + buttonWidth);
|
|
|
|
|
|
|
|
SetWindowPos(hwndButton, 0, x, y, 0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ShowWindow(hwndButton, SW_HIDE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Position and resize the sunken line.
|
|
|
|
*/
|
|
|
|
x = padding.x;
|
|
|
|
y = rcSheet.bottom - ((padding.y * 2) + buttonHeight + lineHeight);
|
|
|
|
|
|
|
|
GetClientRect(hwndParent, &rcSheet);
|
|
|
|
lineWidth = rcSheet.right - (padding.x * 2);
|
|
|
|
|
|
|
|
SetWindowPos(hwndLine, 0, x, y, lineWidth, 2,
|
|
|
|
SWP_NOZORDER | SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_GetPaddingInfo
|
|
|
|
*
|
|
|
|
* Returns the layout information.
|
|
|
|
*/
|
|
|
|
static PADDING_INFO PROPSHEET_GetPaddingInfo(HWND hwndDlg)
|
|
|
|
{
|
|
|
|
HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|
|
|
RECT rcTab;
|
|
|
|
POINT tl;
|
|
|
|
PADDING_INFO padding;
|
|
|
|
|
|
|
|
GetWindowRect(hwndTab, &rcTab);
|
|
|
|
|
|
|
|
tl.x = rcTab.left;
|
|
|
|
tl.y = rcTab.top;
|
|
|
|
|
|
|
|
ScreenToClient(hwndDlg, &tl);
|
|
|
|
|
|
|
|
padding.x = tl.x;
|
|
|
|
padding.y = tl.y;
|
|
|
|
|
|
|
|
return padding;
|
|
|
|
}
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_GetPaddingInfoWizard
|
|
|
|
*
|
|
|
|
* Returns the layout information.
|
|
|
|
* Horizontal spacing is the distance between the Cancel and Help buttons.
|
|
|
|
* Vertical spacing is the distance between the line and the buttons.
|
|
|
|
*/
|
|
|
|
static PADDING_INFO PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg)
|
|
|
|
{
|
|
|
|
PADDING_INFO padding;
|
|
|
|
RECT rc;
|
|
|
|
HWND hwndControl;
|
|
|
|
POINT ptHelp, ptCancel, ptLine;
|
|
|
|
|
|
|
|
/* Help button */
|
|
|
|
hwndControl = GetDlgItem(hwndDlg, IDHELP);
|
|
|
|
GetWindowRect(hwndControl, &rc);
|
|
|
|
|
|
|
|
ptHelp.x = rc.left;
|
|
|
|
ptHelp.y = rc.top;
|
|
|
|
|
|
|
|
ScreenToClient(hwndDlg, &ptHelp);
|
|
|
|
|
|
|
|
/* Cancel button */
|
|
|
|
hwndControl = GetDlgItem(hwndDlg, IDCANCEL);
|
|
|
|
GetWindowRect(hwndControl, &rc);
|
|
|
|
|
|
|
|
ptCancel.x = rc.right;
|
|
|
|
ptCancel.y = rc.top;
|
|
|
|
|
|
|
|
ScreenToClient(hwndDlg, &ptCancel);
|
|
|
|
|
|
|
|
/* Line */
|
|
|
|
hwndControl = GetDlgItem(hwndDlg, IDC_SUNKEN_LINE);
|
|
|
|
GetWindowRect(hwndControl, &rc);
|
|
|
|
|
|
|
|
ptLine.x = 0;
|
|
|
|
ptLine.y = rc.bottom;
|
|
|
|
|
|
|
|
ScreenToClient(hwndDlg, &ptLine);
|
|
|
|
|
|
|
|
padding.x = ptHelp.x - ptCancel.x;
|
|
|
|
padding.y = ptHelp.y - ptLine.y;
|
|
|
|
|
|
|
|
return padding;
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_CreateTabControl
|
|
|
|
*
|
|
|
|
* Insert the tabs in the tab control.
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_CreateTabControl(HWND hwndParent,
|
|
|
|
PropSheetInfo * psInfo)
|
|
|
|
{
|
|
|
|
HWND hwndTabCtrl = GetDlgItem(hwndParent, IDC_TABCONTROL);
|
|
|
|
TCITEMA item;
|
|
|
|
int i, nTabs;
|
1999-11-28 22:01:47 +01:00
|
|
|
int iImage = 0;
|
1999-05-01 12:27:05 +02:00
|
|
|
char tabtext[MAX_TABTEXT_LENGTH] = "Tab text";
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
item.mask = TCIF_TEXT;
|
|
|
|
item.pszText = tabtext;
|
1999-05-01 12:27:05 +02:00
|
|
|
item.cchTextMax = MAX_TABTEXT_LENGTH;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
2000-02-25 21:49:49 +01:00
|
|
|
nTabs = psInfo->nPages;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-08-14 17:51:10 +02:00
|
|
|
/*
|
|
|
|
* Set the image list for icons.
|
|
|
|
*/
|
|
|
|
if (psInfo->hImageList)
|
|
|
|
{
|
|
|
|
SendMessageA(hwndTabCtrl, TCM_SETIMAGELIST, 0, (LPARAM)psInfo->hImageList);
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
for (i = 0; i < nTabs; i++)
|
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
if ( psInfo->proppage[i].hasIcon )
|
|
|
|
{
|
|
|
|
item.mask |= TCIF_IMAGE;
|
|
|
|
item.iImage = iImage++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item.mask &= ~TCIF_IMAGE;
|
|
|
|
}
|
1999-08-14 17:51:10 +02:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0,
|
|
|
|
(LPCWSTR)psInfo->proppage[i].pszText,
|
1999-05-01 12:27:05 +02:00
|
|
|
-1, tabtext, MAX_TABTEXT_LENGTH, NULL, NULL);
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
SendMessageA(hwndTabCtrl, TCM_INSERTITEMA, (WPARAM)i, (LPARAM)&item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_CreatePage
|
|
|
|
*
|
1999-05-01 12:27:05 +02:00
|
|
|
* Creates a page.
|
1999-04-22 11:24:47 +02:00
|
|
|
*/
|
|
|
|
static int PROPSHEET_CreatePage(HWND hwndParent,
|
|
|
|
int index,
|
1999-05-01 12:27:05 +02:00
|
|
|
const PropSheetInfo * psInfo,
|
1999-11-28 22:01:47 +01:00
|
|
|
LPCPROPSHEETPAGEA ppshpage)
|
1999-04-22 11:24:47 +02:00
|
|
|
{
|
|
|
|
DLGTEMPLATE* pTemplate;
|
|
|
|
HWND hwndPage;
|
|
|
|
RECT rc;
|
|
|
|
PropPageInfo* ppInfo = psInfo->proppage;
|
1999-09-19 14:14:38 +02:00
|
|
|
PADDING_INFO padding;
|
2000-02-25 21:49:49 +01:00
|
|
|
UINT pageWidth,pageHeight;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("index %d\n", index);
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
if (ppshpage->dwFlags & PSP_DLGINDIRECT)
|
|
|
|
pTemplate = (DLGTEMPLATE*)ppshpage->u1.pResource;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HRSRC hResource = FindResourceA(ppshpage->hInstance,
|
|
|
|
ppshpage->u1.pszTemplate,
|
|
|
|
RT_DIALOGA);
|
|
|
|
HGLOBAL hTemplate = LoadResource(ppshpage->hInstance, hResource);
|
|
|
|
pTemplate = (LPDLGTEMPLATEA)LockResource(hTemplate);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((MyDLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF)
|
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
((MyDLGTEMPLATEEX*)pTemplate)->style |= WS_CHILD | DS_CONTROL;
|
1999-04-22 11:24:47 +02:00
|
|
|
((MyDLGTEMPLATEEX*)pTemplate)->style &= ~DS_MODALFRAME;
|
|
|
|
((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_CAPTION;
|
|
|
|
((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_SYSMENU;
|
|
|
|
((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_POPUP;
|
1999-07-20 16:56:08 +02:00
|
|
|
((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_DISABLED;
|
1999-11-28 22:01:47 +01:00
|
|
|
((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_VISIBLE;
|
1999-04-22 11:24:47 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
pTemplate->style |= WS_CHILD | DS_CONTROL;
|
1999-04-22 11:24:47 +02:00
|
|
|
pTemplate->style &= ~DS_MODALFRAME;
|
|
|
|
pTemplate->style &= ~WS_CAPTION;
|
|
|
|
pTemplate->style &= ~WS_SYSMENU;
|
|
|
|
pTemplate->style &= ~WS_POPUP;
|
1999-07-20 16:56:08 +02:00
|
|
|
pTemplate->style &= ~WS_DISABLED;
|
1999-11-28 22:01:47 +01:00
|
|
|
pTemplate->style &= ~WS_VISIBLE;
|
1999-04-22 11:24:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (psInfo->proppage[index].useCallback)
|
|
|
|
(*(ppshpage->pfnCallback))(hwndParent,
|
|
|
|
PSPCB_CREATE,
|
|
|
|
(LPPROPSHEETPAGEA)ppshpage);
|
|
|
|
|
1999-05-08 17:38:57 +02:00
|
|
|
hwndPage = CreateDialogIndirectParamA(ppshpage->hInstance,
|
|
|
|
pTemplate,
|
|
|
|
hwndParent,
|
|
|
|
ppshpage->pfnDlgProc,
|
1999-05-08 20:28:13 +02:00
|
|
|
(LPARAM)ppshpage);
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
ppInfo[index].hwndPage = hwndPage;
|
|
|
|
|
|
|
|
rc.left = psInfo->x;
|
|
|
|
rc.top = psInfo->y;
|
|
|
|
rc.right = psInfo->width;
|
|
|
|
rc.bottom = psInfo->height;
|
|
|
|
|
|
|
|
MapDialogRect(hwndParent, &rc);
|
|
|
|
|
2000-02-25 21:49:49 +01:00
|
|
|
pageWidth = rc.right - rc.left;
|
|
|
|
pageHeight = rc.bottom - rc.top;
|
|
|
|
|
2000-07-08 14:48:13 +02:00
|
|
|
if (psInfo->ppshheader.dwFlags & PSH_WIZARD)
|
1999-09-19 14:14:38 +02:00
|
|
|
padding = PROPSHEET_GetPaddingInfoWizard(hwndParent);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Ask the Tab control to fit this page in.
|
|
|
|
*/
|
|
|
|
|
|
|
|
HWND hwndTabCtrl = GetDlgItem(hwndParent, IDC_TABCONTROL);
|
|
|
|
SendMessageA(hwndTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM)&rc);
|
|
|
|
padding = PROPSHEET_GetPaddingInfo(hwndParent);
|
|
|
|
}
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-10-31 03:24:29 +01:00
|
|
|
SetWindowPos(hwndPage, HWND_TOP,
|
1999-04-22 11:24:47 +02:00
|
|
|
rc.left + padding.x,
|
|
|
|
rc.top + padding.y,
|
2000-02-25 21:49:49 +01:00
|
|
|
pageWidth, pageHeight, 0);
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_ShowPage
|
|
|
|
*
|
|
|
|
* Displays or creates the specified page.
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_ShowPage(HWND hwndDlg, int index, PropSheetInfo * psInfo)
|
|
|
|
{
|
|
|
|
if (index == psInfo->active_page)
|
2000-02-26 19:28:38 +01:00
|
|
|
{
|
|
|
|
if (GetTopWindow(hwndDlg) != psInfo->proppage[index].hwndPage)
|
1999-11-28 22:01:47 +01:00
|
|
|
SetWindowPos(psInfo->proppage[index].hwndPage, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
2000-02-26 19:28:38 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if (psInfo->proppage[index].hwndPage == 0)
|
1999-05-01 12:27:05 +02:00
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
LPCPROPSHEETPAGEA ppshpage;
|
2000-02-26 19:28:38 +01:00
|
|
|
PSHNOTIFY psn;
|
1999-11-28 22:01:47 +01:00
|
|
|
|
|
|
|
ppshpage = (LPCPROPSHEETPAGEA)psInfo->proppage[index].hpage;
|
|
|
|
PROPSHEET_CreatePage(hwndDlg, index, psInfo, ppshpage);
|
|
|
|
|
2000-02-26 19:28:38 +01:00
|
|
|
psn.hdr.hwndFrom = hwndDlg;
|
|
|
|
psn.hdr.code = PSN_SETACTIVE;
|
|
|
|
psn.hdr.idFrom = 0;
|
|
|
|
psn.lParam = 0;
|
1999-11-28 22:01:47 +01:00
|
|
|
|
2000-02-26 19:28:38 +01:00
|
|
|
/* Send the notification before showing the page. */
|
|
|
|
SendMessageA(psInfo->proppage[index].hwndPage,
|
|
|
|
WM_NOTIFY, 0, (LPARAM) &psn);
|
1999-11-28 22:01:47 +01:00
|
|
|
|
2000-02-26 19:28:38 +01:00
|
|
|
/*
|
|
|
|
* TODO: check return value.
|
|
|
|
*/
|
|
|
|
}
|
1999-11-28 22:01:47 +01:00
|
|
|
|
2000-02-25 21:49:49 +01:00
|
|
|
if (psInfo->active_page != -1)
|
|
|
|
ShowWindow(psInfo->proppage[psInfo->active_page].hwndPage, SW_HIDE);
|
1999-11-28 22:01:47 +01:00
|
|
|
|
2000-02-25 21:49:49 +01:00
|
|
|
ShowWindow(psInfo->proppage[index].hwndPage, SW_SHOW);
|
1999-04-22 11:24:47 +02:00
|
|
|
|
2000-07-08 14:48:13 +02:00
|
|
|
if (!(psInfo->ppshheader.dwFlags & PSH_WIZARD))
|
2000-02-26 19:28:38 +01:00
|
|
|
{
|
|
|
|
HWND hwndTabCtrl;
|
|
|
|
|
|
|
|
/* Synchronize current selection with tab control */
|
|
|
|
hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
|
|
|
SendMessageA(hwndTabCtrl, TCM_SETCURSEL, index, 0);
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
psInfo->active_page = index;
|
1999-11-28 22:01:47 +01:00
|
|
|
psInfo->activeValid = TRUE;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_Back
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_Back(HWND hwndDlg)
|
|
|
|
{
|
|
|
|
BOOL res;
|
1999-11-28 22:01:47 +01:00
|
|
|
PSHNOTIFY psn;
|
1999-09-19 14:14:38 +02:00
|
|
|
HWND hwndPage;
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|
|
|
PropSheetInfoStr);
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if (psInfo->active_page < 0)
|
1999-11-13 21:49:12 +01:00
|
|
|
return FALSE;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
psn.hdr.code = PSN_WIZBACK;
|
|
|
|
psn.hdr.hwndFrom = hwndDlg;
|
|
|
|
psn.hdr.idFrom = 0;
|
|
|
|
psn.lParam = 0;
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn) == -1)
|
1999-09-19 14:14:38 +02:00
|
|
|
return FALSE;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if (psInfo->active_page > 0)
|
1999-10-13 17:54:08 +02:00
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
res = PROPSHEET_CanSetCurSel(hwndDlg);
|
|
|
|
if(res != FALSE)
|
|
|
|
{
|
|
|
|
res = PROPSHEET_SetCurSel(hwndDlg, psInfo->active_page - 1, 0);
|
|
|
|
}
|
1999-10-13 17:54:08 +02:00
|
|
|
}
|
1999-09-19 14:14:38 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_Next
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_Next(HWND hwndDlg)
|
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
PSHNOTIFY psn;
|
1999-09-19 14:14:38 +02:00
|
|
|
HWND hwndPage;
|
|
|
|
LRESULT msgResult = 0;
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|
|
|
PropSheetInfoStr);
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if (psInfo->active_page < 0)
|
1999-11-13 21:49:12 +01:00
|
|
|
return FALSE;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
psn.hdr.code = PSN_WIZNEXT;
|
|
|
|
psn.hdr.hwndFrom = hwndDlg;
|
|
|
|
psn.hdr.idFrom = 0;
|
|
|
|
psn.lParam = 0;
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
1999-09-19 14:14:38 +02:00
|
|
|
|
|
|
|
TRACE("msg result %ld\n", msgResult);
|
|
|
|
|
|
|
|
if (msgResult == -1)
|
|
|
|
return FALSE;
|
|
|
|
|
1999-10-13 17:54:08 +02:00
|
|
|
if(PROPSHEET_CanSetCurSel(hwndDlg) != FALSE)
|
|
|
|
{
|
|
|
|
PROPSHEET_SetCurSel(hwndDlg, psInfo->active_page + 1, 0);
|
|
|
|
}
|
1999-09-19 14:14:38 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_Finish
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_Finish(HWND hwndDlg)
|
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
PSHNOTIFY psn;
|
1999-09-19 14:14:38 +02:00
|
|
|
HWND hwndPage;
|
|
|
|
LRESULT msgResult = 0;
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|
|
|
PropSheetInfoStr);
|
|
|
|
|
1999-11-13 21:49:12 +01:00
|
|
|
if (psInfo->active_page < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
psn.hdr.code = PSN_WIZFINISH;
|
|
|
|
psn.hdr.hwndFrom = hwndDlg;
|
|
|
|
psn.hdr.idFrom = 0;
|
|
|
|
psn.lParam = 0;
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
1999-09-19 14:14:38 +02:00
|
|
|
|
|
|
|
TRACE("msg result %ld\n", msgResult);
|
|
|
|
|
|
|
|
if (msgResult != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (psInfo->isModeless)
|
1999-11-28 22:01:47 +01:00
|
|
|
psInfo->activeValid = FALSE;
|
1999-09-19 14:14:38 +02:00
|
|
|
else
|
|
|
|
EndDialog(hwndDlg, TRUE);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_Apply
|
|
|
|
*/
|
1999-11-28 22:01:47 +01:00
|
|
|
static BOOL PROPSHEET_Apply(HWND hwndDlg, LPARAM lParam)
|
1999-04-22 11:24:47 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
HWND hwndPage;
|
1999-11-28 22:01:47 +01:00
|
|
|
PSHNOTIFY psn;
|
1999-04-22 11:24:47 +02:00
|
|
|
LRESULT msgResult;
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|
|
|
PropSheetInfoStr);
|
|
|
|
|
1999-11-13 21:49:12 +01:00
|
|
|
if (psInfo->active_page < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
psn.hdr.hwndFrom = hwndDlg;
|
|
|
|
psn.hdr.idFrom = 0;
|
|
|
|
psn.lParam = 0;
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Send PSN_KILLACTIVE to the current page.
|
|
|
|
*/
|
1999-11-28 22:01:47 +01:00
|
|
|
psn.hdr.code = PSN_KILLACTIVE;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn) != FALSE)
|
1999-04-22 11:24:47 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send PSN_APPLY to all pages.
|
|
|
|
*/
|
1999-11-28 22:01:47 +01:00
|
|
|
psn.hdr.code = PSN_APPLY;
|
|
|
|
psn.lParam = lParam;
|
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
for (i = 0; i < psInfo->nPages; i++)
|
1999-04-22 11:24:47 +02:00
|
|
|
{
|
|
|
|
hwndPage = psInfo->proppage[i].hwndPage;
|
1999-11-28 22:01:47 +01:00
|
|
|
if (hwndPage)
|
|
|
|
{
|
|
|
|
msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
|
|
|
if (msgResult == PSNRET_INVALID_NOCHANGEPAGE)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if(lParam)
|
|
|
|
{
|
|
|
|
psInfo->activeValid = FALSE;
|
|
|
|
}
|
|
|
|
else if(psInfo->active_page >= 0)
|
|
|
|
{
|
|
|
|
psn.hdr.code = PSN_SETACTIVE;
|
|
|
|
psn.lParam = 0;
|
|
|
|
hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|
|
|
SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
1999-04-22 11:24:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_Cancel
|
|
|
|
*/
|
1999-11-28 22:01:47 +01:00
|
|
|
static void PROPSHEET_Cancel(HWND hwndDlg, LPARAM lParam)
|
1999-04-22 11:24:47 +02:00
|
|
|
{
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|
|
|
PropSheetInfoStr);
|
1999-11-13 21:49:12 +01:00
|
|
|
HWND hwndPage;
|
1999-11-28 22:01:47 +01:00
|
|
|
PSHNOTIFY psn;
|
|
|
|
int i;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-11-13 21:49:12 +01:00
|
|
|
if (psInfo->active_page < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
1999-11-28 22:01:47 +01:00
|
|
|
psn.hdr.code = PSN_QUERYCANCEL;
|
|
|
|
psn.hdr.hwndFrom = hwndDlg;
|
|
|
|
psn.hdr.idFrom = 0;
|
|
|
|
psn.lParam = 0;
|
|
|
|
|
|
|
|
if (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn))
|
1999-04-22 11:24:47 +02:00
|
|
|
return;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
psn.hdr.code = PSN_RESET;
|
|
|
|
psn.lParam = lParam;
|
|
|
|
|
|
|
|
for (i = 0; i < psInfo->nPages; i++)
|
|
|
|
{
|
|
|
|
hwndPage = psInfo->proppage[i].hwndPage;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if (hwndPage)
|
|
|
|
SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
|
|
|
}
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
if (psInfo->isModeless)
|
1999-11-28 22:01:47 +01:00
|
|
|
{
|
|
|
|
/* makes PSM_GETCURRENTPAGEHWND return NULL */
|
|
|
|
psInfo->activeValid = FALSE;
|
|
|
|
}
|
1999-04-22 11:24:47 +02:00
|
|
|
else
|
|
|
|
EndDialog(hwndDlg, FALSE);
|
|
|
|
}
|
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_Help
|
|
|
|
*/
|
|
|
|
static void PROPSHEET_Help(HWND hwndDlg)
|
|
|
|
{
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|
|
|
PropSheetInfoStr);
|
1999-11-13 21:49:12 +01:00
|
|
|
HWND hwndPage;
|
1999-11-28 22:01:47 +01:00
|
|
|
PSHNOTIFY psn;
|
1999-05-01 12:27:05 +02:00
|
|
|
|
1999-11-13 21:49:12 +01:00
|
|
|
if (psInfo->active_page < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
1999-11-28 22:01:47 +01:00
|
|
|
psn.hdr.code = PSN_HELP;
|
|
|
|
psn.hdr.hwndFrom = hwndDlg;
|
|
|
|
psn.hdr.idFrom = 0;
|
|
|
|
psn.lParam = 0;
|
|
|
|
|
|
|
|
SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
1999-05-01 12:27:05 +02:00
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_Changed
|
|
|
|
*/
|
|
|
|
static void PROPSHEET_Changed(HWND hwndDlg, HWND hwndDirtyPage)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|
|
|
PropSheetInfoStr);
|
|
|
|
|
1999-07-03 18:01:42 +02:00
|
|
|
if (!psInfo) return;
|
1999-04-22 11:24:47 +02:00
|
|
|
/*
|
|
|
|
* Set the dirty flag of this page.
|
|
|
|
*/
|
1999-05-01 12:27:05 +02:00
|
|
|
for (i = 0; i < psInfo->nPages; i++)
|
1999-04-22 11:24:47 +02:00
|
|
|
{
|
|
|
|
if (psInfo->proppage[i].hwndPage == hwndDirtyPage)
|
|
|
|
psInfo->proppage[i].isDirty = TRUE;
|
|
|
|
}
|
1999-01-24 20:14:58 +01:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/*
|
|
|
|
* Enable the Apply button.
|
|
|
|
*/
|
|
|
|
if (psInfo->hasApply)
|
|
|
|
{
|
|
|
|
HWND hwndApplyBtn = GetDlgItem(hwndDlg, IDC_APPLY_BUTTON);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
EnableWindow(hwndApplyBtn, TRUE);
|
|
|
|
}
|
|
|
|
}
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_UnChanged
|
|
|
|
*/
|
|
|
|
static void PROPSHEET_UnChanged(HWND hwndDlg, HWND hwndCleanPage)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
BOOL noPageDirty = TRUE;
|
|
|
|
HWND hwndApplyBtn = GetDlgItem(hwndDlg, IDC_APPLY_BUTTON);
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|
|
|
PropSheetInfoStr);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-10-23 20:59:01 +02:00
|
|
|
if ( !psInfo ) return;
|
1999-05-01 12:27:05 +02:00
|
|
|
for (i = 0; i < psInfo->nPages; i++)
|
1999-04-22 11:24:47 +02:00
|
|
|
{
|
|
|
|
/* set the specified page as clean */
|
|
|
|
if (psInfo->proppage[i].hwndPage == hwndCleanPage)
|
|
|
|
psInfo->proppage[i].isDirty = FALSE;
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/* look to see if there's any dirty pages */
|
|
|
|
if (psInfo->proppage[i].isDirty)
|
|
|
|
noPageDirty = FALSE;
|
|
|
|
}
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/*
|
|
|
|
* Disable Apply button.
|
|
|
|
*/
|
|
|
|
if (noPageDirty)
|
|
|
|
EnableWindow(hwndApplyBtn, FALSE);
|
|
|
|
}
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_PressButton
|
|
|
|
*/
|
|
|
|
static void PROPSHEET_PressButton(HWND hwndDlg, int buttonID)
|
|
|
|
{
|
|
|
|
switch (buttonID)
|
|
|
|
{
|
|
|
|
case PSBTN_APPLYNOW:
|
|
|
|
SendMessageA(hwndDlg, WM_COMMAND, IDC_APPLY_BUTTON, 0);
|
|
|
|
break;
|
|
|
|
case PSBTN_BACK:
|
1999-09-19 14:14:38 +02:00
|
|
|
PROPSHEET_Back(hwndDlg);
|
1999-04-22 11:24:47 +02:00
|
|
|
break;
|
|
|
|
case PSBTN_CANCEL:
|
|
|
|
SendMessageA(hwndDlg, WM_COMMAND, IDCANCEL, 0);
|
|
|
|
break;
|
|
|
|
case PSBTN_FINISH:
|
1999-09-19 14:14:38 +02:00
|
|
|
PROPSHEET_Finish(hwndDlg);
|
1999-04-22 11:24:47 +02:00
|
|
|
break;
|
|
|
|
case PSBTN_HELP:
|
|
|
|
SendMessageA(hwndDlg, WM_COMMAND, IDHELP, 0);
|
|
|
|
break;
|
|
|
|
case PSBTN_NEXT:
|
1999-09-19 14:14:38 +02:00
|
|
|
PROPSHEET_Next(hwndDlg);
|
1999-04-22 11:24:47 +02:00
|
|
|
break;
|
|
|
|
case PSBTN_OK:
|
|
|
|
SendMessageA(hwndDlg, WM_COMMAND, IDOK, 0);
|
|
|
|
break;
|
|
|
|
default:
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("Invalid button index %d\n", buttonID);
|
1999-04-22 11:24:47 +02:00
|
|
|
}
|
|
|
|
}
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-10-13 17:54:08 +02:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* BOOL PROPSHEET_CanSetCurSel [Internal]
|
|
|
|
*
|
1999-10-31 03:24:29 +01:00
|
|
|
* Test weither the current page can be changed by sending a PSN_KILLACTIVE
|
1999-10-13 17:54:08 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hwndDlg [I] handle to a Dialog hWnd
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE if Current Selection can change
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_CanSetCurSel(HWND hwndDlg)
|
|
|
|
{
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|
|
|
PropSheetInfoStr);
|
|
|
|
HWND hwndPage;
|
1999-11-28 22:01:47 +01:00
|
|
|
PSHNOTIFY psn;
|
1999-10-31 03:24:29 +01:00
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if (!psInfo)
|
1999-11-13 21:49:12 +01:00
|
|
|
return FALSE;
|
1999-11-28 22:01:47 +01:00
|
|
|
|
|
|
|
if (psInfo->active_page < 0)
|
|
|
|
return TRUE;
|
|
|
|
|
1999-10-13 17:54:08 +02:00
|
|
|
/*
|
|
|
|
* Notify the current page.
|
|
|
|
*/
|
|
|
|
hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
1999-11-28 22:01:47 +01:00
|
|
|
psn.hdr.code = PSN_KILLACTIVE;
|
|
|
|
psn.hdr.hwndFrom = hwndDlg;
|
|
|
|
psn.hdr.idFrom = 0;
|
|
|
|
psn.lParam = 0;
|
1999-10-13 17:54:08 +02:00
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
return !SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
1999-10-13 17:54:08 +02:00
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_SetCurSel
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
|
|
|
|
int index,
|
|
|
|
HPROPSHEETPAGE hpage)
|
|
|
|
{
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|
|
|
PropSheetInfoStr);
|
|
|
|
HWND hwndPage;
|
|
|
|
HWND hwndHelp = GetDlgItem(hwndDlg, IDHELP);
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
/* hpage takes precedence over index */
|
1999-04-22 11:24:47 +02:00
|
|
|
if (hpage != NULL)
|
1999-07-24 12:16:53 +02:00
|
|
|
index = PROPSHEET_GetPageIndex(hpage, psInfo);
|
|
|
|
|
1999-11-13 21:49:12 +01:00
|
|
|
if (index < 0 || index >= psInfo->nPages)
|
|
|
|
{
|
|
|
|
TRACE("Could not find page to select!\n");
|
|
|
|
return FALSE;
|
1999-07-24 12:16:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hwndPage = psInfo->proppage[index].hwndPage;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
2000-02-26 19:28:38 +01:00
|
|
|
/*
|
|
|
|
* Notify the new page if it's already created.
|
|
|
|
* If not it will get created and notified in PROPSHEET_ShowPage.
|
|
|
|
*/
|
|
|
|
if (hwndPage)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
PSHNOTIFY psn;
|
|
|
|
|
|
|
|
psn.hdr.code = PSN_SETACTIVE;
|
|
|
|
psn.hdr.hwndFrom = hwndDlg;
|
|
|
|
psn.hdr.idFrom = 0;
|
|
|
|
psn.lParam = 0;
|
|
|
|
|
|
|
|
result = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO: check return value.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/*
|
|
|
|
* Display the new page.
|
|
|
|
*/
|
|
|
|
PROPSHEET_ShowPage(hwndDlg, index, psInfo);
|
|
|
|
|
|
|
|
if (psInfo->proppage[index].hasHelp)
|
|
|
|
EnableWindow(hwndHelp, TRUE);
|
|
|
|
else
|
|
|
|
EnableWindow(hwndHelp, FALSE);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_SetTitleA
|
|
|
|
*/
|
|
|
|
static void PROPSHEET_SetTitleA(HWND hwndDlg, DWORD dwStyle, LPCSTR lpszText)
|
|
|
|
{
|
1999-11-07 06:28:32 +01:00
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg, PropSheetInfoStr);
|
|
|
|
char szTitle[256];
|
|
|
|
|
|
|
|
if (HIWORD(lpszText) == 0) {
|
2000-07-08 14:48:13 +02:00
|
|
|
if (!LoadStringA(psInfo->ppshheader.hInstance,
|
1999-11-07 06:28:32 +01:00
|
|
|
LOWORD(lpszText), szTitle, sizeof(szTitle)-1))
|
|
|
|
return;
|
|
|
|
lpszText = szTitle;
|
|
|
|
}
|
1999-04-22 11:24:47 +02:00
|
|
|
if (dwStyle & PSH_PROPTITLE)
|
|
|
|
{
|
|
|
|
char* dest;
|
|
|
|
int lentitle = strlen(lpszText);
|
|
|
|
int lenprop = strlen(psInfo->strPropertiesFor);
|
|
|
|
|
|
|
|
dest = COMCTL32_Alloc(lentitle + lenprop + 1);
|
|
|
|
strcpy(dest, psInfo->strPropertiesFor);
|
|
|
|
strcat(dest, lpszText);
|
|
|
|
|
|
|
|
SetWindowTextA(hwndDlg, dest);
|
|
|
|
COMCTL32_Free(dest);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetWindowTextA(hwndDlg, lpszText);
|
|
|
|
}
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_SetFinishTextA
|
|
|
|
*/
|
|
|
|
static void PROPSHEET_SetFinishTextA(HWND hwndDlg, LPCSTR lpszText)
|
|
|
|
{
|
|
|
|
HWND hwndButton = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
|
|
|
|
|
|
|
|
/* Set text, show and enable the Finish button */
|
|
|
|
SetWindowTextA(hwndButton, lpszText);
|
|
|
|
ShowWindow(hwndButton, SW_SHOW);
|
|
|
|
EnableWindow(hwndButton, TRUE);
|
|
|
|
|
|
|
|
/* Make it default pushbutton */
|
|
|
|
SendMessageA(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0);
|
|
|
|
|
|
|
|
/* Hide Back button */
|
|
|
|
hwndButton = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
|
|
|
|
ShowWindow(hwndButton, SW_HIDE);
|
|
|
|
|
|
|
|
/* Hide Next button */
|
|
|
|
hwndButton = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
|
|
|
|
ShowWindow(hwndButton, SW_HIDE);
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_QuerySiblings
|
|
|
|
*/
|
|
|
|
static LRESULT PROPSHEET_QuerySiblings(HWND hwndDlg,
|
|
|
|
WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
HWND hwndPage;
|
|
|
|
LRESULT msgResult = 0;
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|
|
|
PropSheetInfoStr);
|
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
while ((i < psInfo->nPages) && (msgResult == 0))
|
1999-04-22 11:24:47 +02:00
|
|
|
{
|
|
|
|
hwndPage = psInfo->proppage[i].hwndPage;
|
|
|
|
msgResult = SendMessageA(hwndPage, PSM_QUERYSIBLINGS, wParam, lParam);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return msgResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_AddPage
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_AddPage(HWND hwndDlg,
|
|
|
|
HPROPSHEETPAGE hpage)
|
|
|
|
{
|
1999-05-01 12:27:05 +02:00
|
|
|
PropSheetInfo * psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
1999-04-22 11:24:47 +02:00
|
|
|
PropSheetInfoStr);
|
|
|
|
HWND hwndTabControl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
1999-05-01 12:27:05 +02:00
|
|
|
TCITEMA item;
|
|
|
|
char tabtext[MAX_TABTEXT_LENGTH] = "Tab text";
|
|
|
|
LPCPROPSHEETPAGEA ppsp = (LPCPROPSHEETPAGEA)hpage;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
/*
|
|
|
|
* Allocate and fill in a new PropPageInfo entry.
|
|
|
|
*/
|
1999-04-22 11:24:47 +02:00
|
|
|
psInfo->proppage = (PropPageInfo*) COMCTL32_ReAlloc(psInfo->proppage,
|
|
|
|
sizeof(PropPageInfo) *
|
|
|
|
(psInfo->nPages + 1));
|
2000-02-25 21:49:49 +01:00
|
|
|
if (!PROPSHEET_CollectPageInfo(ppsp, psInfo, psInfo->nPages))
|
|
|
|
return FALSE;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
psInfo->proppage[psInfo->nPages].hpage = hpage;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if (ppsp->dwFlags & PSP_PREMATURE)
|
|
|
|
{
|
|
|
|
/* Create the page but don't show it */
|
|
|
|
PROPSHEET_CreatePage(hwndDlg, psInfo->nPages, psInfo, ppsp);
|
|
|
|
}
|
1999-05-01 12:27:05 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add a new tab to the tab control.
|
|
|
|
*/
|
|
|
|
item.mask = TCIF_TEXT;
|
|
|
|
item.pszText = tabtext;
|
|
|
|
item.cchTextMax = MAX_TABTEXT_LENGTH;
|
|
|
|
|
|
|
|
WideCharToMultiByte(CP_ACP, 0,
|
|
|
|
(LPCWSTR)psInfo->proppage[psInfo->nPages].pszText,
|
|
|
|
-1, tabtext, MAX_TABTEXT_LENGTH, NULL, NULL);
|
|
|
|
|
|
|
|
SendMessageA(hwndTabControl, TCM_INSERTITEMA, psInfo->nPages + 1,
|
|
|
|
(LPARAM)&item);
|
|
|
|
|
|
|
|
psInfo->nPages++;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
/* If it is the only page - show it */
|
|
|
|
if(psInfo->nPages == 1)
|
|
|
|
PROPSHEET_ShowPage(hwndDlg, 0, psInfo);
|
|
|
|
|
1999-10-31 19:29:47 +01:00
|
|
|
return TRUE;
|
1999-04-22 11:24:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_RemovePage
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_RemovePage(HWND hwndDlg,
|
|
|
|
int index,
|
|
|
|
HPROPSHEETPAGE hpage)
|
|
|
|
{
|
|
|
|
PropSheetInfo * psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
|
|
|
|
PropSheetInfoStr);
|
|
|
|
HWND hwndTabControl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
|
1999-10-13 14:31:52 +02:00
|
|
|
PropPageInfo* oldPages;
|
1999-05-01 12:27:05 +02:00
|
|
|
|
1999-10-13 14:31:52 +02:00
|
|
|
if (!psInfo) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
oldPages = psInfo->proppage;
|
1999-05-01 12:27:05 +02:00
|
|
|
/*
|
|
|
|
* hpage takes precedence over index.
|
|
|
|
*/
|
|
|
|
if (hpage != 0)
|
|
|
|
{
|
|
|
|
index = PROPSHEET_GetPageIndex(hpage, psInfo);
|
1999-10-24 01:59:47 +02:00
|
|
|
}
|
1999-05-01 12:27:05 +02:00
|
|
|
|
1999-10-24 01:59:47 +02:00
|
|
|
/* Make shure that index is within range */
|
|
|
|
if (index < 0 || index >= psInfo->nPages)
|
1999-11-28 22:01:47 +01:00
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("Could not find page to remove!\n");
|
1999-05-01 12:27:05 +02:00
|
|
|
return FALSE;
|
1999-11-28 22:01:47 +01:00
|
|
|
}
|
1999-05-01 12:27:05 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("total pages %d removing page %d active page %d\n",
|
1999-05-01 12:27:05 +02:00
|
|
|
psInfo->nPages, index, psInfo->active_page);
|
|
|
|
/*
|
|
|
|
* Check if we're removing the active page.
|
|
|
|
*/
|
|
|
|
if (index == psInfo->active_page)
|
|
|
|
{
|
|
|
|
if (psInfo->nPages > 1)
|
|
|
|
{
|
|
|
|
if (index > 0)
|
|
|
|
{
|
|
|
|
/* activate previous page */
|
|
|
|
PROPSHEET_ShowPage(hwndDlg, index - 1, psInfo);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* activate the next page */
|
|
|
|
PROPSHEET_ShowPage(hwndDlg, index + 1, psInfo);
|
2000-06-07 04:01:28 +02:00
|
|
|
psInfo->active_page = index;
|
1999-05-01 12:27:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
psInfo->active_page = -1;
|
|
|
|
if (!psInfo->isModeless)
|
|
|
|
{
|
|
|
|
EndDialog(hwndDlg, FALSE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-05-01 12:27:05 +02:00
|
|
|
}
|
|
|
|
}
|
1999-11-28 22:01:47 +01:00
|
|
|
else if (index < psInfo->active_page)
|
1999-05-01 12:27:05 +02:00
|
|
|
psInfo->active_page--;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
/* Destroy page dialog window */
|
|
|
|
DestroyWindow(psInfo->proppage[index].hwndPage);
|
|
|
|
|
|
|
|
/* Free page resources */
|
|
|
|
if(psInfo->proppage[index].hpage)
|
|
|
|
{
|
|
|
|
PROPSHEETPAGEA* psp = (PROPSHEETPAGEA*)psInfo->proppage[index].hpage;
|
|
|
|
|
|
|
|
if ((psp->dwFlags & PSP_USETITLE) && psInfo->proppage[index].pszText)
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->proppage[index].pszText);
|
|
|
|
|
|
|
|
DestroyPropertySheetPage(psInfo->proppage[index].hpage);
|
|
|
|
}
|
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
/* Remove the tab */
|
|
|
|
SendMessageA(hwndTabControl, TCM_DELETEITEM, index, 0);
|
|
|
|
|
|
|
|
psInfo->nPages--;
|
|
|
|
psInfo->proppage = COMCTL32_Alloc(sizeof(PropPageInfo) * psInfo->nPages);
|
|
|
|
|
|
|
|
if (index > 0)
|
|
|
|
memcpy(&psInfo->proppage[0], &oldPages[0], index * sizeof(PropPageInfo));
|
|
|
|
|
|
|
|
if (index < psInfo->nPages)
|
|
|
|
memcpy(&psInfo->proppage[index], &oldPages[index + 1],
|
|
|
|
(psInfo->nPages - index) * sizeof(PropPageInfo));
|
|
|
|
|
|
|
|
COMCTL32_Free(oldPages);
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_SetWizButtons
|
|
|
|
*
|
|
|
|
* This code will work if (and assumes that) the Next button is on top of the
|
|
|
|
* Finish button. ie. Finish comes after Next in the Z order.
|
|
|
|
* This means make sure the dialog template reflects this.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags)
|
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
HWND hwndBack = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
|
|
|
|
HWND hwndNext = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
|
|
|
|
HWND hwndFinish = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
|
1999-09-19 14:14:38 +02:00
|
|
|
|
|
|
|
TRACE("%ld\n", dwFlags);
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
EnableWindow(hwndBack, FALSE);
|
|
|
|
EnableWindow(hwndNext, FALSE);
|
|
|
|
EnableWindow(hwndFinish, FALSE);
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
if (dwFlags & PSWIZB_BACK)
|
1999-11-28 22:01:47 +01:00
|
|
|
EnableWindow(hwndBack, TRUE);
|
1999-09-19 14:14:38 +02:00
|
|
|
|
|
|
|
if (dwFlags & PSWIZB_NEXT)
|
|
|
|
{
|
|
|
|
/* Hide the Finish button */
|
1999-11-28 22:01:47 +01:00
|
|
|
ShowWindow(hwndFinish, SW_HIDE);
|
1999-09-19 14:14:38 +02:00
|
|
|
|
|
|
|
/* Show and enable the Next button */
|
1999-11-28 22:01:47 +01:00
|
|
|
ShowWindow(hwndNext, SW_SHOW);
|
|
|
|
EnableWindow(hwndNext, TRUE);
|
1999-09-19 14:14:38 +02:00
|
|
|
|
|
|
|
/* Set the Next button as the default pushbutton */
|
|
|
|
SendMessageA(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((dwFlags & PSWIZB_FINISH) || (dwFlags & PSWIZB_DISABLEDFINISH))
|
|
|
|
{
|
|
|
|
/* Hide the Next button */
|
1999-11-28 22:01:47 +01:00
|
|
|
ShowWindow(hwndNext, SW_HIDE);
|
1999-09-19 14:14:38 +02:00
|
|
|
|
|
|
|
/* Show the Finish button */
|
1999-11-28 22:01:47 +01:00
|
|
|
ShowWindow(hwndFinish, SW_SHOW);
|
1999-09-19 14:14:38 +02:00
|
|
|
|
|
|
|
if (dwFlags & PSWIZB_FINISH)
|
1999-11-28 22:01:47 +01:00
|
|
|
EnableWindow(hwndFinish, TRUE);
|
1999-09-19 14:14:38 +02:00
|
|
|
|
|
|
|
/* Set the Finish button as the default pushbutton */
|
|
|
|
SendMessageA(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_GetPageIndex
|
|
|
|
*
|
|
|
|
* Given a HPROPSHEETPAGE, returns the index of the corresponding page from
|
|
|
|
* the array of PropPageInfo.
|
|
|
|
*/
|
|
|
|
static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage, PropSheetInfo* psInfo)
|
|
|
|
{
|
|
|
|
BOOL found = FALSE;
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
while ((index < psInfo->nPages) && (found == FALSE))
|
|
|
|
{
|
|
|
|
if (psInfo->proppage[index].hpage == hpage)
|
|
|
|
found = TRUE;
|
|
|
|
else
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found == FALSE)
|
|
|
|
index = -1;
|
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_CleanUp
|
|
|
|
*/
|
|
|
|
static void PROPSHEET_CleanUp(HWND hwndDlg)
|
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
int i;
|
1999-04-22 11:24:47 +02:00
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) RemovePropA(hwndDlg,
|
|
|
|
PropSheetInfoStr);
|
1999-08-14 17:51:10 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
2000-07-08 14:48:13 +02:00
|
|
|
if (HIWORD(psInfo->ppshheader.pszCaption))
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->ppshheader.pszCaption);
|
1999-11-28 22:01:47 +01:00
|
|
|
|
|
|
|
for (i = 0; i < psInfo->nPages; i++)
|
|
|
|
{
|
|
|
|
PROPSHEETPAGEA* psp = (PROPSHEETPAGEA*)psInfo->proppage[i].hpage;
|
|
|
|
|
|
|
|
if(psInfo->proppage[i].hwndPage)
|
|
|
|
DestroyWindow(psInfo->proppage[i].hwndPage);
|
|
|
|
|
|
|
|
if(psp)
|
|
|
|
{
|
|
|
|
if ((psp->dwFlags & PSP_USETITLE) && psInfo->proppage[i].pszText)
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->proppage[i].pszText);
|
|
|
|
|
|
|
|
DestroyPropertySheetPage(psInfo->proppage[i].hpage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
COMCTL32_Free(psInfo->proppage);
|
|
|
|
COMCTL32_Free(psInfo->strPropertiesFor);
|
1999-08-14 17:51:10 +02:00
|
|
|
ImageList_Destroy(psInfo->hImageList);
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
GlobalFree((HGLOBAL)psInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* PropertySheetA (COMCTL32.84)(COMCTL32.83)
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI PropertySheetA(LPCPROPSHEETHEADERA lppsh)
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
1999-04-22 11:24:47 +02:00
|
|
|
int bRet = 0;
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GlobalAlloc(GPTR,
|
|
|
|
sizeof(PropSheetInfo));
|
2000-02-25 21:49:49 +01:00
|
|
|
int i, n;
|
1999-11-28 22:01:47 +01:00
|
|
|
BYTE* pByte;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
PROPSHEET_CollectSheetInfo(lppsh, psInfo);
|
1999-05-01 12:27:05 +02:00
|
|
|
|
|
|
|
psInfo->proppage = (PropPageInfo*) COMCTL32_Alloc(sizeof(PropPageInfo) *
|
|
|
|
lppsh->nPages);
|
2000-07-08 14:48:13 +02:00
|
|
|
pByte = (BYTE*) psInfo->ppshheader.u3.ppsp;
|
1999-05-01 12:27:05 +02:00
|
|
|
|
2000-02-25 21:49:49 +01:00
|
|
|
for (n = i = 0; i < lppsh->nPages; i++, n++)
|
1999-05-01 12:27:05 +02:00
|
|
|
{
|
|
|
|
if (!(lppsh->dwFlags & PSH_PROPSHEETPAGE))
|
2000-07-08 14:48:13 +02:00
|
|
|
psInfo->proppage[n].hpage = psInfo->ppshheader.u3.phpage[i];
|
1999-11-28 22:01:47 +01:00
|
|
|
else
|
|
|
|
{
|
2000-02-25 21:49:49 +01:00
|
|
|
psInfo->proppage[n].hpage = CreatePropertySheetPageA((LPCPROPSHEETPAGEA)pByte);
|
1999-11-28 22:01:47 +01:00
|
|
|
pByte += ((LPPROPSHEETPAGEA)pByte)->dwSize;
|
|
|
|
}
|
|
|
|
|
2000-02-25 21:49:49 +01:00
|
|
|
if (!PROPSHEET_CollectPageInfo((LPCPROPSHEETPAGEA)psInfo->proppage[n].hpage,
|
|
|
|
psInfo, n))
|
|
|
|
{
|
|
|
|
if (lppsh->dwFlags & PSH_PROPSHEETPAGE)
|
|
|
|
DestroyPropertySheetPage(psInfo->proppage[n].hpage);
|
|
|
|
n--;
|
|
|
|
psInfo->nPages--;
|
|
|
|
}
|
1999-05-01 12:27:05 +02:00
|
|
|
}
|
1998-12-10 16:49:22 +01:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
bRet = PROPSHEET_CreateDialog(psInfo);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
return bRet;
|
1998-12-10 16:49:22 +01:00
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
2000-03-28 22:22:59 +02:00
|
|
|
* PropertySheetW (COMCTL32.85)
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI PropertySheetW(LPCPROPSHEETHEADERW propertySheetHeader)
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p): stub\n", propertySheetHeader);
|
1998-12-10 16:49:22 +01:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
1999-05-01 12:27:05 +02:00
|
|
|
* CreatePropertySheetPageA (COMCTL32.19)(COMCTL32.18)
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
1999-05-01 12:27:05 +02:00
|
|
|
HPROPSHEETPAGE WINAPI CreatePropertySheetPageA(
|
|
|
|
LPCPROPSHEETPAGEA lpPropSheetPage)
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
1999-05-01 12:27:05 +02:00
|
|
|
PROPSHEETPAGEA* ppsp = COMCTL32_Alloc(sizeof(PROPSHEETPAGEA));
|
1998-12-10 16:49:22 +01:00
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
*ppsp = *lpPropSheetPage;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if ( !(ppsp->dwFlags & PSP_DLGINDIRECT) && HIWORD( ppsp->u1.pszTemplate ) )
|
|
|
|
ppsp->u1.pszTemplate = HEAP_strdupA( GetProcessHeap(), 0, lpPropSheetPage->u1.pszTemplate );
|
|
|
|
|
|
|
|
if ( (ppsp->dwFlags & PSP_USEICONID) && HIWORD( ppsp->u2.pszIcon ) )
|
|
|
|
ppsp->u2.pszIcon = HEAP_strdupA( GetProcessHeap(), 0, lpPropSheetPage->u2.pszIcon );
|
|
|
|
|
|
|
|
|
|
|
|
if ((ppsp->dwFlags & PSP_USETITLE) && HIWORD( ppsp->pszTitle ))
|
|
|
|
ppsp->pszTitle = HEAP_strdupA( GetProcessHeap(), 0, lpPropSheetPage->pszTitle );
|
|
|
|
else if ( !(ppsp->dwFlags & PSP_USETITLE) )
|
|
|
|
ppsp->pszTitle = NULL;
|
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
return (HPROPSHEETPAGE)ppsp;
|
1998-12-10 16:49:22 +01:00
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
1999-05-01 12:27:05 +02:00
|
|
|
* CreatePropertySheetPageW (COMCTL32.20)
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HPROPSHEETPAGE WINAPI CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage)
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("(%p): stub\n", lpPropSheetPage);
|
1998-12-10 16:49:22 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
1999-05-01 12:27:05 +02:00
|
|
|
* DestroyPropertySheetPage (COMCTL32.24)
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
PROPSHEETPAGEA *psp = (PROPSHEETPAGEA *)hPropPage;
|
|
|
|
|
|
|
|
if (!psp)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ( !(psp->dwFlags & PSP_DLGINDIRECT) && HIWORD( psp->u1.pszTemplate ) )
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)psp->u1.pszTemplate);
|
|
|
|
|
|
|
|
if ( (psp->dwFlags & PSP_USEICONID) && HIWORD( psp->u2.pszIcon ) )
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)psp->u2.pszIcon);
|
|
|
|
|
|
|
|
if ((psp->dwFlags & PSP_USETITLE) && HIWORD( psp->pszTitle ))
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)psp->pszTitle);
|
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
COMCTL32_Free(hPropPage);
|
|
|
|
|
|
|
|
return TRUE;
|
1998-12-10 16:49:22 +01:00
|
|
|
}
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_IsDialogMessage
|
|
|
|
*/
|
|
|
|
static BOOL PROPSHEET_IsDialogMessage(HWND hwnd, LPMSG lpMsg)
|
|
|
|
{
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd, PropSheetInfoStr);
|
|
|
|
|
|
|
|
if (!psInfo || (hwnd != lpMsg->hwnd && !IsChild(hwnd, lpMsg->hwnd)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (lpMsg->message == WM_KEYDOWN && (GetKeyState(VK_CONTROL) & 0x8000))
|
|
|
|
{
|
|
|
|
int new_page = 0;
|
|
|
|
INT dlgCode = SendMessageA(lpMsg->hwnd, WM_GETDLGCODE, 0, (LPARAM)lpMsg);
|
|
|
|
|
|
|
|
if (!(dlgCode & DLGC_WANTMESSAGE))
|
|
|
|
{
|
|
|
|
switch (lpMsg->wParam)
|
|
|
|
{
|
|
|
|
case VK_TAB:
|
|
|
|
if (GetKeyState(VK_SHIFT) & 0x8000)
|
|
|
|
new_page = -1;
|
|
|
|
else
|
|
|
|
new_page = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_NEXT: new_page = 1; break;
|
|
|
|
case VK_PRIOR: new_page = -1; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_page)
|
|
|
|
{
|
|
|
|
if (PROPSHEET_CanSetCurSel(hwnd) != FALSE)
|
|
|
|
{
|
|
|
|
new_page += psInfo->active_page;
|
|
|
|
|
|
|
|
if (new_page < 0)
|
|
|
|
new_page = psInfo->nPages - 1;
|
|
|
|
else if (new_page >= psInfo->nPages)
|
|
|
|
new_page = 0;
|
|
|
|
|
|
|
|
PROPSHEET_SetCurSel(hwnd, new_page, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return IsDialogMessageA(hwnd, lpMsg);
|
|
|
|
}
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* PROPSHEET_DialogProc
|
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
|
|
|
PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) lParam;
|
|
|
|
char* strCaption = (char*)COMCTL32_Alloc(MAX_CAPTION_LENGTH);
|
|
|
|
HWND hwndTabCtrl = GetDlgItem(hwnd, IDC_TABCONTROL);
|
1999-05-01 12:27:05 +02:00
|
|
|
LPCPROPSHEETPAGEA ppshpage;
|
1999-11-28 22:01:47 +01:00
|
|
|
int idx;
|
1999-04-22 11:24:47 +02:00
|
|
|
|
1999-11-13 21:49:12 +01:00
|
|
|
SetPropA(hwnd, PropSheetInfoStr, (HANDLE)psInfo);
|
|
|
|
|
2000-07-08 14:48:13 +02:00
|
|
|
/*
|
|
|
|
* psInfo->hwnd is not being used by WINE code - it exists
|
|
|
|
* for compatibility with "real" Windoze. The same about
|
|
|
|
* SetWindowLong - WINE is only using the PropSheetInfoStr
|
|
|
|
* property.
|
|
|
|
*/
|
|
|
|
psInfo->hwnd = hwnd;
|
|
|
|
SetWindowLongA(hwnd,DWL_USER,(LONG)psInfo);
|
|
|
|
|
1999-08-18 20:25:46 +02:00
|
|
|
/*
|
|
|
|
* Small icon in the title bar.
|
|
|
|
*/
|
2000-07-08 14:48:13 +02:00
|
|
|
if ((psInfo->ppshheader.dwFlags & PSH_USEICONID) ||
|
|
|
|
(psInfo->ppshheader.dwFlags & PSH_USEHICON))
|
1999-08-18 20:25:46 +02:00
|
|
|
{
|
|
|
|
HICON hIcon;
|
|
|
|
int icon_cx = GetSystemMetrics(SM_CXSMICON);
|
|
|
|
int icon_cy = GetSystemMetrics(SM_CYSMICON);
|
|
|
|
|
2000-07-08 14:48:13 +02:00
|
|
|
if (psInfo->ppshheader.dwFlags & PSH_USEICONID)
|
|
|
|
hIcon = LoadImageA(psInfo->ppshheader.hInstance,
|
|
|
|
psInfo->ppshheader.u1.pszIcon,
|
1999-08-18 20:25:46 +02:00
|
|
|
IMAGE_ICON,
|
|
|
|
icon_cx, icon_cy,
|
|
|
|
LR_DEFAULTCOLOR);
|
|
|
|
else
|
2000-07-08 14:48:13 +02:00
|
|
|
hIcon = psInfo->ppshheader.u1.hIcon;
|
1999-08-18 20:25:46 +02:00
|
|
|
|
|
|
|
SendMessageA(hwnd, WM_SETICON, 0, hIcon);
|
|
|
|
}
|
|
|
|
|
2000-07-08 14:48:13 +02:00
|
|
|
if (psInfo->ppshheader.dwFlags & PSH_USEHICON)
|
|
|
|
SendMessageA(hwnd, WM_SETICON, 0, psInfo->ppshheader.u1.hIcon);
|
1999-08-18 20:25:46 +02:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
psInfo->strPropertiesFor = strCaption;
|
|
|
|
|
|
|
|
GetWindowTextA(hwnd, psInfo->strPropertiesFor, MAX_CAPTION_LENGTH);
|
|
|
|
|
1999-10-31 03:24:29 +01:00
|
|
|
PROPSHEET_CreateTabControl(hwnd, psInfo);
|
|
|
|
|
2000-07-08 14:48:13 +02:00
|
|
|
if (psInfo->ppshheader.dwFlags & PSH_WIZARD)
|
1999-09-19 14:14:38 +02:00
|
|
|
{
|
|
|
|
if (PROPSHEET_IsTooSmallWizard(hwnd, psInfo))
|
|
|
|
{
|
|
|
|
PROPSHEET_AdjustSizeWizard(hwnd, psInfo);
|
|
|
|
PROPSHEET_AdjustButtonsWizard(hwnd, psInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
1999-04-22 11:24:47 +02:00
|
|
|
{
|
2000-02-25 21:49:49 +01:00
|
|
|
if (PROPSHEET_SizeMismatch(hwnd, psInfo))
|
1999-09-19 14:14:38 +02:00
|
|
|
{
|
|
|
|
PROPSHEET_AdjustSize(hwnd, psInfo);
|
|
|
|
PROPSHEET_AdjustButtons(hwnd, psInfo);
|
|
|
|
}
|
1999-04-22 11:24:47 +02:00
|
|
|
}
|
|
|
|
|
1999-10-23 18:57:28 +02:00
|
|
|
if (psInfo->useCallback)
|
2000-07-08 14:48:13 +02:00
|
|
|
(*(psInfo->ppshheader.pfnCallback))(hwnd,
|
1999-10-23 18:57:28 +02:00
|
|
|
PSCB_INITIALIZED, (LPARAM)0);
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
idx = psInfo->active_page;
|
|
|
|
ppshpage = (LPCPROPSHEETPAGEA)psInfo->proppage[idx].hpage;
|
|
|
|
psInfo->active_page = -1;
|
|
|
|
|
|
|
|
PROPSHEET_SetCurSel(hwnd, idx, psInfo->proppage[idx].hpage);
|
1999-09-19 14:14:38 +02:00
|
|
|
|
2000-07-08 14:48:13 +02:00
|
|
|
if (!(psInfo->ppshheader.dwFlags & PSH_WIZARD))
|
2000-02-26 19:28:38 +01:00
|
|
|
SendMessageA(hwndTabCtrl, TCM_SETCURSEL, psInfo->active_page, 0);
|
1999-04-22 11:24:47 +02:00
|
|
|
|
2000-07-08 14:48:13 +02:00
|
|
|
if (!HIWORD(psInfo->ppshheader.pszCaption) &&
|
|
|
|
psInfo->ppshheader.hInstance)
|
1999-10-23 18:57:28 +02:00
|
|
|
{
|
|
|
|
char szText[256];
|
|
|
|
|
2000-07-08 14:48:13 +02:00
|
|
|
if (LoadStringA(psInfo->ppshheader.hInstance,
|
|
|
|
(UINT)psInfo->ppshheader.pszCaption, szText, 255))
|
|
|
|
PROPSHEET_SetTitleA(hwnd, psInfo->ppshheader.dwFlags, szText);
|
1999-10-23 18:57:28 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-07-08 14:48:13 +02:00
|
|
|
PROPSHEET_SetTitleA(hwnd, psInfo->ppshheader.dwFlags,
|
|
|
|
psInfo->ppshheader.pszCaption);
|
1999-10-23 18:57:28 +02:00
|
|
|
}
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
PROPSHEET_CleanUp(hwnd);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_CLOSE:
|
1999-11-28 22:01:47 +01:00
|
|
|
PROPSHEET_Cancel(hwnd, 1);
|
1999-04-22 11:24:47 +02:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
{
|
|
|
|
WORD wID = LOWORD(wParam);
|
|
|
|
|
|
|
|
switch (wID)
|
|
|
|
{
|
|
|
|
case IDOK:
|
|
|
|
case IDC_APPLY_BUTTON:
|
|
|
|
{
|
|
|
|
HWND hwndApplyBtn = GetDlgItem(hwnd, IDC_APPLY_BUTTON);
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if (PROPSHEET_Apply(hwnd, wID == IDOK ? 1: 0) == FALSE)
|
1999-04-22 11:24:47 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (wID == IDOK)
|
|
|
|
{
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd,
|
|
|
|
PropSheetInfoStr);
|
|
|
|
int result = TRUE;
|
|
|
|
|
|
|
|
if (psInfo->restartWindows)
|
|
|
|
result = ID_PSRESTARTWINDOWS;
|
|
|
|
|
|
|
|
/* reboot system takes precedence over restart windows */
|
|
|
|
if (psInfo->rebootSystem)
|
|
|
|
result = ID_PSREBOOTSYSTEM;
|
|
|
|
|
|
|
|
if (psInfo->isModeless)
|
1999-11-28 22:01:47 +01:00
|
|
|
psInfo->activeValid = FALSE;
|
1999-04-22 11:24:47 +02:00
|
|
|
else
|
|
|
|
EndDialog(hwnd, result);
|
|
|
|
}
|
1999-11-28 22:01:47 +01:00
|
|
|
else
|
|
|
|
EnableWindow(hwndApplyBtn, FALSE);
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
case IDC_BACK_BUTTON:
|
|
|
|
PROPSHEET_Back(hwnd);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_NEXT_BUTTON:
|
|
|
|
PROPSHEET_Next(hwnd);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_FINISH_BUTTON:
|
|
|
|
PROPSHEET_Finish(hwnd);
|
|
|
|
break;
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
case IDCANCEL:
|
1999-11-28 22:01:47 +01:00
|
|
|
PROPSHEET_Cancel(hwnd, 0);
|
1999-04-22 11:24:47 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDHELP:
|
1999-05-01 12:27:05 +02:00
|
|
|
PROPSHEET_Help(hwnd);
|
1999-04-22 11:24:47 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
NMHDR* pnmh = (LPNMHDR) lParam;
|
|
|
|
|
|
|
|
if (pnmh->code == TCN_SELCHANGE)
|
|
|
|
{
|
|
|
|
int index = SendMessageA(pnmh->hwndFrom, TCM_GETCURSEL, 0, 0);
|
1999-07-24 12:16:53 +02:00
|
|
|
PROPSHEET_SetCurSel(hwnd, index, 0);
|
1999-04-22 11:24:47 +02:00
|
|
|
}
|
|
|
|
|
1999-10-13 17:54:08 +02:00
|
|
|
if(pnmh->code == TCN_SELCHANGING)
|
|
|
|
{
|
|
|
|
BOOL bRet = PROPSHEET_CanSetCurSel(hwnd);
|
|
|
|
SetWindowLongA(hwnd, DWL_MSGRESULT, !bRet);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PSM_GETCURRENTPAGEHWND:
|
|
|
|
{
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd,
|
|
|
|
PropSheetInfoStr);
|
|
|
|
HWND hwndPage = 0;
|
|
|
|
|
1999-11-28 22:01:47 +01:00
|
|
|
if (psInfo->activeValid && psInfo->active_page != -1)
|
1999-04-22 11:24:47 +02:00
|
|
|
hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
|
|
|
|
|
|
|
|
SetWindowLongA(hwnd, DWL_MSGRESULT, hwndPage);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PSM_CHANGED:
|
|
|
|
PROPSHEET_Changed(hwnd, (HWND)wParam);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case PSM_UNCHANGED:
|
|
|
|
PROPSHEET_UnChanged(hwnd, (HWND)wParam);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case PSM_GETTABCONTROL:
|
|
|
|
{
|
|
|
|
HWND hwndTabCtrl = GetDlgItem(hwnd, IDC_TABCONTROL);
|
|
|
|
|
|
|
|
SetWindowLongA(hwnd, DWL_MSGRESULT, hwndTabCtrl);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PSM_SETCURSEL:
|
|
|
|
{
|
|
|
|
BOOL msgResult;
|
|
|
|
|
1999-10-13 17:54:08 +02:00
|
|
|
msgResult = PROPSHEET_CanSetCurSel(hwnd);
|
|
|
|
if(msgResult != FALSE)
|
|
|
|
{
|
|
|
|
msgResult = PROPSHEET_SetCurSel(hwnd,
|
|
|
|
(int)wParam,
|
|
|
|
(HPROPSHEETPAGE)lParam);
|
|
|
|
}
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PSM_CANCELTOCLOSE:
|
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
char buf[MAX_BUTTONTEXT_LENGTH];
|
1999-04-22 11:24:47 +02:00
|
|
|
HWND hwndOK = GetDlgItem(hwnd, IDOK);
|
|
|
|
HWND hwndCancel = GetDlgItem(hwnd, IDCANCEL);
|
|
|
|
|
|
|
|
EnableWindow(hwndCancel, FALSE);
|
1999-11-28 22:01:47 +01:00
|
|
|
if (LoadStringA(COMCTL32_hModule, IDS_CLOSE, buf, sizeof(buf)))
|
|
|
|
SetWindowTextA(hwndOK, buf);
|
|
|
|
|
|
|
|
return FALSE;
|
1999-04-22 11:24:47 +02:00
|
|
|
}
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
case PSM_RESTARTWINDOWS:
|
|
|
|
{
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd,
|
|
|
|
PropSheetInfoStr);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
psInfo->restartWindows = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PSM_REBOOTSYSTEM:
|
|
|
|
{
|
|
|
|
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd,
|
|
|
|
PropSheetInfoStr);
|
|
|
|
|
|
|
|
psInfo->rebootSystem = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PSM_SETTITLEA:
|
|
|
|
PROPSHEET_SetTitleA(hwnd, (DWORD) wParam, (LPCSTR) lParam);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case PSM_APPLY:
|
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
BOOL msgResult = PROPSHEET_Apply(hwnd, 0);
|
1999-04-22 11:24:47 +02:00
|
|
|
|
|
|
|
SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PSM_QUERYSIBLINGS:
|
|
|
|
{
|
|
|
|
LRESULT msgResult = PROPSHEET_QuerySiblings(hwnd, wParam, lParam);
|
|
|
|
|
|
|
|
SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
case PSM_ADDPAGE:
|
1999-10-31 19:29:47 +01:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
|
|
|
|
* a return value. This is not true. PSM_ADDPAGE returns TRUE
|
|
|
|
* on success or FALSE otherwise, as specified on MSDN Online.
|
|
|
|
* Also see the MFC code for
|
|
|
|
* CPropertySheet::AddPage(CPropertyPage* pPage).
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL msgResult = PROPSHEET_AddPage(hwnd, (HPROPSHEETPAGE)lParam);
|
|
|
|
|
|
|
|
SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
|
|
|
|
|
1999-05-01 12:27:05 +02:00
|
|
|
return TRUE;
|
1999-10-31 19:29:47 +01:00
|
|
|
}
|
1999-05-01 12:27:05 +02:00
|
|
|
|
|
|
|
case PSM_REMOVEPAGE:
|
|
|
|
PROPSHEET_RemovePage(hwnd, (int)wParam, (HPROPSHEETPAGE)lParam);
|
|
|
|
return TRUE;
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
case PSM_ISDIALOGMESSAGE:
|
|
|
|
{
|
1999-11-28 22:01:47 +01:00
|
|
|
BOOL msgResult = PROPSHEET_IsDialogMessage(hwnd, (LPMSG)lParam);
|
|
|
|
SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
|
|
|
|
return TRUE;
|
1999-04-22 11:24:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
case PSM_PRESSBUTTON:
|
|
|
|
PROPSHEET_PressButton(hwnd, (int)wParam);
|
|
|
|
return TRUE;
|
|
|
|
|
1999-09-19 14:14:38 +02:00
|
|
|
case PSM_SETFINISHTEXTA:
|
|
|
|
PROPSHEET_SetFinishTextA(hwnd, (LPCSTR) lParam);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case PSM_SETWIZBUTTONS:
|
|
|
|
PROPSHEET_SetWizButtons(hwnd, (DWORD)lParam);
|
|
|
|
return TRUE;
|
|
|
|
|
1999-04-22 11:24:47 +02:00
|
|
|
case PSM_SETTITLEW:
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("Unimplemented msg PSM_SETTITLE32W\n");
|
1999-04-22 11:24:47 +02:00
|
|
|
return 0;
|
|
|
|
case PSM_SETCURSELID:
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("Unimplemented msg PSM_SETCURSELID\n");
|
1999-04-22 11:24:47 +02:00
|
|
|
return 0;
|
|
|
|
case PSM_SETFINISHTEXTW:
|
1999-06-12 17:45:58 +02:00
|
|
|
FIXME("Unimplemented msg PSM_SETFINISHTEXT32W\n");
|
1999-04-22 11:24:47 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-01-17 17:32:32 +01:00
|
|
|
}
|
1999-04-22 11:24:47 +02:00
|
|
|
|