2007-10-19 23:21:45 +00:00
|
|
|
/*
|
2007-09-26 06:20:16 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Display Control Panel
|
|
|
|
* FILE: dll/cpl/desk/advmon.c
|
|
|
|
* PURPOSE: Advanced monitor/display settings
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "desk.h"
|
|
|
|
|
|
|
|
#define MAX_ADVANCED_PAGES 32
|
|
|
|
|
|
|
|
static BOOL CALLBACK
|
|
|
|
PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
|
|
|
|
{
|
|
|
|
PROPSHEETHEADER *ppsh = (PROPSHEETHEADER *)lParam;
|
|
|
|
if (ppsh != NULL && ppsh->nPages < MAX_ADVANCED_PAGES)
|
|
|
|
{
|
|
|
|
ppsh->phpage[ppsh->nPages++] = hpage;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
InitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc, LPARAM lParam)
|
|
|
|
{
|
|
|
|
HPROPSHEETPAGE hPage;
|
|
|
|
PROPSHEETPAGE psp;
|
|
|
|
|
|
|
|
if (ppsh->nPages < MAX_ADVANCED_PAGES)
|
|
|
|
{
|
|
|
|
ZeroMemory(&psp, sizeof(psp));
|
|
|
|
psp.dwSize = sizeof(psp);
|
|
|
|
psp.dwFlags = PSP_DEFAULT;
|
|
|
|
psp.hInstance = hApplet;
|
|
|
|
psp.pszTemplate = MAKEINTRESOURCE(idDlg);
|
|
|
|
psp.pfnDlgProc = DlgProc;
|
|
|
|
psp.lParam = lParam;
|
|
|
|
|
|
|
|
hPage = CreatePropertySheetPage(&psp);
|
|
|
|
if (hPage != NULL)
|
|
|
|
{
|
|
|
|
return PropSheetAddPage(hPage, (LPARAM)ppsh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
BuildAdvPropTitle(IDataObject *pdo, LPTSTR lpBuffer, DWORD dwBufferLen)
|
|
|
|
{
|
|
|
|
UINT uiMonitorName, uiDisplayName;
|
|
|
|
LPTSTR lpMonitorName, lpDisplayName;
|
|
|
|
TCHAR szFormatBuff[32];
|
|
|
|
|
|
|
|
if (!LoadString(hApplet, IDS_ADVANCEDTITLEFMT, szFormatBuff, sizeof(szFormatBuff) / sizeof(szFormatBuff[0])))
|
|
|
|
{
|
|
|
|
szFormatBuff[0] = _T('\0');
|
|
|
|
}
|
|
|
|
|
2007-09-26 19:23:50 +00:00
|
|
|
uiMonitorName = RegisterClipboardFormat(DESK_EXT_MONITORNAME);
|
|
|
|
uiDisplayName = RegisterClipboardFormat(DESK_EXT_DISPLAYNAME);
|
2007-09-26 06:20:16 +00:00
|
|
|
|
2007-09-26 19:42:39 +00:00
|
|
|
lpMonitorName = QueryDeskCplString(pdo, uiMonitorName);
|
|
|
|
lpDisplayName = QueryDeskCplString(pdo, uiDisplayName);
|
2007-09-26 06:20:16 +00:00
|
|
|
|
|
|
|
_sntprintf(lpBuffer, dwBufferLen, szFormatBuff, lpMonitorName, lpDisplayName);
|
|
|
|
|
|
|
|
if (lpMonitorName != NULL)
|
|
|
|
LocalFree((HLOCAL)lpMonitorName);
|
|
|
|
if (lpDisplayName != NULL)
|
|
|
|
LocalFree((HLOCAL)lpDisplayName);
|
|
|
|
}
|
|
|
|
|
2007-10-01 13:23:28 +00:00
|
|
|
|
|
|
|
typedef HPSXA (WINAPI * CPSEAE)(HKEY,LPCWSTR,UINT,IDataObject*);
|
|
|
|
|
2007-09-26 06:20:16 +00:00
|
|
|
BOOL
|
|
|
|
DisplayAdvancedSettings(HWND hWndParent, PDISPLAY_DEVICE_ENTRY DisplayDevice)
|
|
|
|
{
|
|
|
|
TCHAR szCaption[128];
|
|
|
|
HPROPSHEETPAGE hpsp[MAX_ADVANCED_PAGES];
|
|
|
|
PROPSHEETHEADER psh;
|
|
|
|
HPSXA hpsxaDev, hpsxaDisp;
|
|
|
|
BOOL Ret;
|
|
|
|
IDataObject *pdo;
|
2008-10-16 08:50:56 +00:00
|
|
|
#ifdef _MSC_VER
|
2007-10-01 13:23:28 +00:00
|
|
|
HMODULE hShell32 = NULL;
|
2011-09-19 13:18:33 +00:00
|
|
|
CPSEAE msvc_SHCreatePropSheetExtArrayEx;
|
2011-09-22 06:09:11 +00:00
|
|
|
#endif
|
2007-09-26 06:20:16 +00:00
|
|
|
|
|
|
|
/* FIXME: Build the "%s and %s" caption string for the monitor and adapter name */
|
|
|
|
szCaption[0] = _T('\0');
|
|
|
|
|
|
|
|
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
|
|
|
|
psh.dwSize = sizeof(PROPSHEETHEADER);
|
|
|
|
psh.dwFlags = PSH_PROPTITLE;
|
|
|
|
psh.hwndParent = hWndParent;
|
|
|
|
psh.hInstance = hApplet;
|
|
|
|
psh.pszCaption = szCaption;
|
|
|
|
psh.phpage = hpsp;
|
|
|
|
|
|
|
|
InitPropSheetPage(&psh, IDD_ADVANCED_GENERAL, AdvGeneralPageProc, (LPARAM)DisplayDevice);
|
|
|
|
|
|
|
|
pdo = CreateDevSettings(DisplayDevice);
|
|
|
|
|
|
|
|
if (pdo != NULL)
|
|
|
|
BuildAdvPropTitle(pdo, szCaption, sizeof(szCaption) / sizeof(szCaption[0]));
|
|
|
|
|
2007-10-01 13:23:28 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
hShell32 = LoadLibrary(_T("shell32.dll"));
|
|
|
|
if(hShell32 == NULL)
|
|
|
|
return FALSE;
|
|
|
|
msvc_SHCreatePropSheetExtArrayEx = (CPSEAE)GetProcAddress(hShell32, (LPCSTR)194);
|
|
|
|
hpsxaDev = msvc_SHCreatePropSheetExtArrayEx(HKEY_LOCAL_MACHINE, REGSTR_PATH_CONTROLSFOLDER TEXT("\\Device"), MAX_ADVANCED_PAGES - psh.nPages, pdo);
|
|
|
|
#else
|
2007-09-26 06:20:16 +00:00
|
|
|
hpsxaDev = SHCreatePropSheetExtArrayEx(HKEY_LOCAL_MACHINE, REGSTR_PATH_CONTROLSFOLDER TEXT("\\Device"), MAX_ADVANCED_PAGES - psh.nPages, pdo);
|
2007-10-01 13:23:28 +00:00
|
|
|
#endif
|
2007-09-26 06:20:16 +00:00
|
|
|
if (hpsxaDev != NULL)
|
|
|
|
SHAddFromPropSheetExtArray(hpsxaDev, PropSheetAddPage, (LPARAM)&psh);
|
|
|
|
|
2007-10-01 13:23:28 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
hpsxaDisp = msvc_SHCreatePropSheetExtArrayEx(HKEY_LOCAL_MACHINE, REGSTR_PATH_CONTROLSFOLDER TEXT("\\Device"), MAX_ADVANCED_PAGES - psh.nPages, pdo);
|
|
|
|
#else
|
2007-09-26 06:20:16 +00:00
|
|
|
hpsxaDisp = SHCreatePropSheetExtArrayEx(HKEY_LOCAL_MACHINE, REGSTR_PATH_CONTROLSFOLDER TEXT("\\Display"), MAX_ADVANCED_PAGES - psh.nPages, pdo);
|
2007-10-01 13:23:28 +00:00
|
|
|
#endif
|
2007-09-26 06:20:16 +00:00
|
|
|
if (hpsxaDisp != NULL)
|
|
|
|
SHAddFromPropSheetExtArray(hpsxaDisp, PropSheetAddPage, (LPARAM)&psh);
|
|
|
|
|
|
|
|
Ret = (LONG)(PropertySheet(&psh) != -1);
|
|
|
|
|
|
|
|
if (hpsxaDisp != NULL)
|
|
|
|
SHDestroyPropSheetExtArray(hpsxaDisp);
|
|
|
|
|
|
|
|
if (hpsxaDev != NULL)
|
|
|
|
SHDestroyPropSheetExtArray(hpsxaDev);
|
|
|
|
|
|
|
|
IDataObject_Release(pdo);
|
|
|
|
|
2008-10-16 08:50:56 +00:00
|
|
|
#ifdef _MSC_VER
|
2007-10-01 13:23:28 +00:00
|
|
|
if (hShell32)
|
|
|
|
FreeLibrary(hShell32);
|
2008-10-16 08:50:56 +00:00
|
|
|
#endif
|
2007-10-01 13:23:28 +00:00
|
|
|
|
2007-09-26 06:20:16 +00:00
|
|
|
return Ret;
|
|
|
|
}
|