ReactOS  0.4.13-dev-235-g7373cb3
advmon.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Display Control Panel
4  * FILE: dll/cpl/desk/advmon.c
5  * PURPOSE: Advanced monitor/display settings
6  */
7 
8 #include "desk.h"
9 
10 #define MAX_ADVANCED_PAGES 32
11 
12 static BOOL CALLBACK
14 {
16  if (ppsh != NULL && ppsh->nPages < MAX_ADVANCED_PAGES)
17  {
18  ppsh->phpage[ppsh->nPages++] = hpage;
19  return TRUE;
20  }
21 
22  return FALSE;
23 }
24 
25 static BOOL
27 {
28  HPROPSHEETPAGE hPage;
29  PROPSHEETPAGE psp;
30 
31  if (ppsh->nPages < MAX_ADVANCED_PAGES)
32  {
33  ZeroMemory(&psp, sizeof(psp));
34  psp.dwSize = sizeof(psp);
35  psp.dwFlags = PSP_DEFAULT;
36  psp.hInstance = hApplet;
37  psp.pszTemplate = MAKEINTRESOURCE(idDlg);
38  psp.pfnDlgProc = DlgProc;
39  psp.lParam = lParam;
40 
41  hPage = CreatePropertySheetPage(&psp);
42  if (hPage != NULL)
43  {
44  return PropSheetAddPage(hPage, (LPARAM)ppsh);
45  }
46  }
47 
48  return FALSE;
49 }
50 
51 static VOID
53 {
54  UINT uiMonitorName, uiDisplayName;
55  LPTSTR lpMonitorName, lpDisplayName;
56  TCHAR szFormatBuff[32];
57 
58  if (!LoadString(hApplet, IDS_ADVANCEDTITLEFMT, szFormatBuff, sizeof(szFormatBuff) / sizeof(szFormatBuff[0])))
59  {
60  szFormatBuff[0] = _T('\0');
61  }
62 
65 
66  lpMonitorName = QueryDeskCplString(pdo, uiMonitorName);
67  lpDisplayName = QueryDeskCplString(pdo, uiDisplayName);
68 
69  _sntprintf(lpBuffer, dwBufferLen, szFormatBuff, lpMonitorName, lpDisplayName);
70 
71  if (lpMonitorName != NULL)
72  LocalFree((HLOCAL)lpMonitorName);
73  if (lpDisplayName != NULL)
75 }
76 
77 
78 typedef HPSXA (WINAPI * CPSEAE)(HKEY,LPCWSTR,UINT,IDataObject*);
79 
80 BOOL
82 {
83  TCHAR szCaption[128];
85  PROPSHEETHEADER psh;
86  HPSXA hpsxaDev, hpsxaDisp;
87  BOOL Ret;
88  IDataObject *pdo;
89 #ifdef _MSC_VER
91  CPSEAE msvc_SHCreatePropSheetExtArrayEx;
92 #endif
93 
94  /* FIXME: Build the "%s and %s" caption string for the monitor and adapter name */
95  szCaption[0] = _T('\0');
96 
97  ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
98  psh.dwSize = sizeof(PROPSHEETHEADER);
99  psh.dwFlags = PSH_PROPTITLE;
100  psh.hwndParent = hWndParent;
101  psh.hInstance = hApplet;
102  psh.pszCaption = szCaption;
103  psh.phpage = hpsp;
104 
106 
107  pdo = CreateDevSettings(DisplayDevice);
108 
109  if (pdo != NULL)
110  BuildAdvPropTitle(pdo, szCaption, sizeof(szCaption) / sizeof(szCaption[0]));
111 
112 #ifdef _MSC_VER
113  hShell32 = LoadLibrary(_T("shell32.dll"));
114  if (hShell32 == NULL)
115  return FALSE;
116  msvc_SHCreatePropSheetExtArrayEx = (CPSEAE)GetProcAddress(hShell32, (LPCSTR)194);
117  hpsxaDev = msvc_SHCreatePropSheetExtArrayEx(HKEY_LOCAL_MACHINE, REGSTR_PATH_CONTROLSFOLDER TEXT("\\Device"), MAX_ADVANCED_PAGES - psh.nPages, pdo);
118 #else
120 #endif
121  if (hpsxaDev != NULL)
123 
124 #ifdef _MSC_VER
125  hpsxaDisp = msvc_SHCreatePropSheetExtArrayEx(HKEY_LOCAL_MACHINE, REGSTR_PATH_CONTROLSFOLDER TEXT("\\Device"), MAX_ADVANCED_PAGES - psh.nPages, pdo);
126 #else
128 #endif
129  if (hpsxaDisp != NULL)
131 
132  Ret = (LONG)(PropertySheet(&psh) != -1);
133 
134  if (hpsxaDisp != NULL)
135  SHDestroyPropSheetExtArray(hpsxaDisp);
136 
137  if (hpsxaDev != NULL)
138  SHDestroyPropSheetExtArray(hpsxaDev);
139 
140  IDataObject_Release(pdo);
141 
142 #ifdef _MSC_VER
143  if (hShell32)
145 #endif
146 
147  return Ret;
148 }
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:1755
WORD idDlg
Definition: desk.c:109
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define TRUE
Definition: types.h:120
#define DESK_EXT_DISPLAYNAME
Definition: deskcplx.h:9
#define MAX_ADVANCED_PAGES
Definition: advmon.c:10
#define LoadLibrary
Definition: winbase.h:3676
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:1577
BOOL DisplayAdvancedSettings(HWND hWndParent, PDISPLAY_DEVICE_ENTRY DisplayDevice)
Definition: advmon.c:81
#define REGSTR_PATH_CONTROLSFOLDER
Definition: regstr.h:76
#define CALLBACK
Definition: compat.h:27
Definition: precomp.h:67
#define ZeroMemory
Definition: winbase.h:1635
HINSTANCE hApplet
Definition: access.c:17
#define IDD_ADVANCED_GENERAL
Definition: resource.h:16
CHAR * LPTSTR
Definition: xmlstorage.h:192
HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY, LPCWSTR, UINT, IDataObject *)
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
HPSXA(WINAPI * CPSEAE)(HKEY, LPCWSTR, UINT, IDataObject *)
Definition: advmon.c:78
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
#define PROPSHEETHEADER
Definition: prsht.h:374
LONG_PTR LPARAM
Definition: windef.h:208
const char * LPCSTR
Definition: xmlstorage.h:183
static BOOL DisplayAdvancedSettingsInitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc, LPARAM lParam)
Definition: advmon.c:26
#define CreatePropertySheetPage
Definition: prsht.h:381
char TCHAR
Definition: xmlstorage.h:189
#define PSP_DEFAULT
Definition: prsht.h:22
#define _T(x)
Definition: vfdio.h:22
#define FreeLibrary(x)
Definition: compat.h:405
#define PSH_PROPTITLE
Definition: prsht.h:40
#define WINAPI
Definition: msvc.h:8
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID BuildAdvPropTitle(IDataObject *pdo, LPTSTR lpBuffer, DWORD dwBufferLen)
Definition: advmon.c:52
#define _sntprintf
Definition: xmlstorage.h:201
static BOOL CALLBACK PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
Definition: advmon.c:13
#define RegisterClipboardFormat
Definition: winuser.h:5704
INT_PTR(CALLBACK * DLGPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2849
#define IDS_ADVANCEDTITLEFMT
Definition: resource.h:147
#define TEXT(s)
Definition: k32.h:26
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
unsigned int UINT
Definition: ndis.h:50
#define PropertySheet
Definition: prsht.h:382
static __inline LPTSTR QueryDeskCplString(IDataObject *pdo, UINT cfFormat)
Definition: deskcplx.h:84
HANDLE HKEY
Definition: registry.h:24
IDataObject * CreateDevSettings(PDISPLAY_DEVICE_ENTRY DisplayDeviceInfo)
Definition: devsett.c:887
#define GetProcAddress(x, y)
Definition: compat.h:410
INT_PTR CALLBACK AdvGeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: general.c:115
#define DESK_EXT_MONITORNAME
Definition: deskcplx.h:13
_In_ LPCSTR _Out_writes_to_opt_ cchDisplayName LPSTR lpDisplayName
Definition: winbase.h:2730
LPARAM lParam
Definition: combotst.c:139
DLGPROC DlgProc
Definition: desk.c:110
static HMODULE hShell32
Definition: string.c:34
#define LoadString
Definition: winuser.h:5685
#define PROPSHEETPAGE
Definition: prsht.h:371
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12