ReactOS 0.4.15-dev-7918-g2a2556c
deskmon.c File Reference
#include "precomp.h"
#include <tchar.h>
#include <winreg.h>
#include <cfgmgr32.h>
#include <debug.h>
#include "resource.h"
Include dependency graph for deskmon.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define FUNC_DEVICEPROPERTIES   "DevicePropertiesA"
 

Typedefs

typedef INT_PTR(WINAPIPDEVICEPROPERTIES) (HWND, LPCSTR, LPCSTR, BOOL)
 

Functions

static LPTSTR GetMonitorDevInstID (LPCTSTR lpDeviceID)
 Converts a Hardware ID (DeviceID from EnumDisplayDevices) to an unique Device Instance ID.
 
static VOID ShowMonitorProperties (PDESKMONITOR This)
 
static VOID UpdateMonitorSelection (PDESKMONITOR This)
 
static VOID UpdatePruningControls (PDESKMONITOR This)
 
static VOID GetPruningSettings (PDESKMONITOR This)
 
static VOID UpdateRefreshFrequencyList (PDESKMONITOR This)
 
static VOID InitMonitorDialog (PDESKMONITOR This)
 
static VOID UpdatePruningSelection (PDESKMONITOR This)
 
static VOID UpdateRefreshRateSelection (PDESKMONITOR This)
 
static LONG ApplyMonitorChanges (PDESKMONITOR This)
 
static VOID ResetMonitorChanges (PDESKMONITOR This)
 
static INT_PTR CALLBACK MonitorDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID IDeskMonitor_Destroy (PDESKMONITOR This)
 
ULONG IDeskMonitor_AddRef (PDESKMONITOR This)
 
ULONG IDeskMonitor_Release (PDESKMONITOR This)
 
HRESULT STDMETHODCALLTYPE IDeskMonitor_QueryInterface (PDESKMONITOR This, REFIID iid, PVOID *pvObject)
 
HRESULT IDeskMonitor_Initialize (PDESKMONITOR This, LPCITEMIDLIST pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID)
 
HRESULT IDeskMonitor_AddPages (PDESKMONITOR This, LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
 
HRESULT IDeskMonitor_ReplacePage (PDESKMONITOR This, EXPPS uPageID, LPFNADDPROPSHEETPAGE pfnReplacePage, LPARAM lParam)
 
HRESULT IDeskMonitor_Constructor (REFIID riid, LPVOID *ppv)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
 

Variables

static HINSTANCE hInstance
 
static BOOL bFoundAdapter
 
static DEVINST diAdapter
 

Macro Definition Documentation

◆ FUNC_DEVICEPROPERTIES

#define FUNC_DEVICEPROPERTIES   "DevicePropertiesA"

Definition at line 21 of file deskmon.c.

◆ NDEBUG

#define NDEBUG

Definition at line 7 of file deskmon.c.

Typedef Documentation

◆ PDEVICEPROPERTIES

typedef INT_PTR(WINAPI * PDEVICEPROPERTIES) (HWND, LPCSTR, LPCSTR, BOOL)

Definition at line 20 of file deskmon.c.

Function Documentation

◆ ApplyMonitorChanges()

static LONG ApplyMonitorChanges ( PDESKMONITOR  This)
static

Definition at line 570 of file deskmon.c.

571{
572 LONG lChangeRet;
573
574 if (This->DeskExtInterface != NULL)
575 {
576 /* Change the display settings through desk.cpl */
577 lChangeRet = DeskCplExtDisplaySaveSettings(This->DeskExtInterface,
578 This->hwndDlg);
579 if (lChangeRet == DISP_CHANGE_SUCCESSFUL)
580 {
581 /* Save the new mode */
582 This->lpDevModeOnInit = This->DeskExtInterface->GetCurrentMode(This->DeskExtInterface->Context);
583 This->lpSelDevMode = This->lpDevModeOnInit;
584 return PSNRET_NOERROR;
585 }
586 else if (lChangeRet == DISP_CHANGE_RESTART)
587 {
588 /* Notify desk.cpl that the user needs to reboot */
590 return PSNRET_NOERROR;
591 }
592 }
593
595
597}
static __inline LONG DeskCplExtDisplaySaveSettings(PDESK_EXT_INTERFACE DeskExtInterface, HWND hwndDlg)
Definition: deskcplx.h:122
static VOID InitMonitorDialog(PDESKMONITOR This)
Definition: deskmon.c:345
#define NULL
Definition: types.h:112
long LONG
Definition: pedump.c:60
#define PSNRET_INVALID_NOCHANGEPAGE
Definition: prsht.h:131
#define PSNRET_NOERROR
Definition: prsht.h:129
#define PropSheet_RestartWindows(d)
Definition: prsht.h:352
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190
HWND WINAPI GetParent(_In_ HWND)
#define DISP_CHANGE_RESTART
Definition: winuser.h:191

Referenced by MonitorDlgProc().

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  dwReason,
LPVOID  lpvReserved 
)

Definition at line 873 of file deskmon.c.

876{
877 switch (dwReason)
878 {
880 hInstance = hinstDLL;
882 break;
883 }
884
885 return TRUE;
886}
DWORD dwReason
Definition: misc.cpp:154
static HINSTANCE hInstance
Definition: deskmon.c:12
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85

◆ GetMonitorDevInstID()

static LPTSTR GetMonitorDevInstID ( LPCTSTR  lpDeviceID)
static

Converts a Hardware ID (DeviceID from EnumDisplayDevices) to an unique Device Instance ID.

Parameters
[in]lpDeviceIDA pointer to a null-terminated string containing a Hardware ID concatenated with driver key. e.g. "Monitor\Default_Monitor\{4D36E96E-E325-11CE-BFC1-08002BE10318}\0000"
Returns
A pointer to a null-terminated string containing an unique Device Instance ID or NULL in case of error. e.g. "DISPLAY\DEFAULT_MONITOR\4&2ABFAA30&0&00000001&00&02"
Remarks
The caller must free the returned string with LocalFree.

Definition at line 44 of file deskmon.c.

45{
46 CONFIGRET cr;
47 DEVINST diChild;
48 TCHAR szProperty[256];
50 LPTSTR lpDevInstId = NULL;
51
52 if (!bFoundAdapter)
53 return NULL;
54
55 /* Look for child monitor devices of selected video adapter */
56 cr = CM_Get_Child(&diChild, diAdapter, 0);
57 if (cr != CR_SUCCESS)
58 {
59 DPRINT1("CM_Get_Child failed: %d\n", cr);
60 return NULL;
61 }
62
63 do
64 {
65 /* Get Hardware ID for each of them */
66 dwSize = sizeof(szProperty) - sizeof(TCHAR);
67
70 NULL,
71 szProperty,
72 &dwSize,
73 0);
74 if (cr != CR_SUCCESS)
75 {
76 DPRINT1("CM_Get_DevNode_Registry_Property failed: %d\n", cr);
77 continue;
78 }
79
80 /* Concatenate with driver key */
81 _tcscat(szProperty, TEXT("\\"));
82 dwSize = sizeof(szProperty) - sizeof(TCHAR);
83 dwSize -= _tcslen(szProperty) * sizeof(TCHAR);
84
87 NULL,
88 szProperty + _tcslen(szProperty),
89 &dwSize,
90 0);
91 if (cr != CR_SUCCESS)
92 {
93 DPRINT1("CM_Get_DevNode_Registry_Property failed: %d\n", cr);
94 continue;
95 }
96
97 /* If the strings match, this is our monitor device node */
98 if (_tcscmp(szProperty, lpDeviceID) == 0)
99 {
101 diChild,
102 0);
103 if (cr != CR_SUCCESS)
104 {
105 DPRINT1("CM_Get_Device_ID_Size failed: %d\n", cr);
106 break;
107 }
108
109 lpDevInstId = LocalAlloc(LMEM_FIXED,
110 (dwSize + 1) * sizeof(TCHAR));
111 if (lpDevInstId == NULL)
112 {
113 DPRINT1("LocalAlloc failed\n");
114 break;
115 }
116
117 cr = CM_Get_Device_ID(diChild,
118 lpDevInstId,
119 dwSize + 1,
120 0);
121 if (cr != CR_SUCCESS)
122 {
123 DPRINT1("CM_Get_Device_ID failed: %d\n", cr);
124 LocalFree((HLOCAL)lpDevInstId);
125 lpDevInstId = NULL;
126 }
127
128 break;
129 }
130 } while (CM_Get_Sibling(&diChild, diChild, 0) == CR_SUCCESS);
131
132 return lpDevInstId;
133}
#define DPRINT1
Definition: precomp.h:8
#define CM_Get_Device_ID
Definition: cfgmgr32.h:1565
#define CM_DRP_DRIVER
Definition: cfgmgr32.h:685
DWORD DEVINST
Definition: cfgmgr32.h:76
#define CM_Get_DevNode_Registry_Property
Definition: cfgmgr32.h:1733
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define CM_DRP_HARDWAREID
Definition: cfgmgr32.h:677
CONFIGRET WINAPI CM_Get_Child(_Out_ PDEVINST pdnDevInst, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags)
Definition: cfgmgr.c:2530
CONFIGRET WINAPI CM_Get_Device_ID_Size(_Out_ PULONG pulLen, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags)
Definition: cfgmgr.c:4073
CONFIGRET WINAPI CM_Get_Sibling(_Out_ PDEVINST pdnDevInst, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags)
Definition: cfgmgr.c:5529
static DEVINST diAdapter
Definition: deskmon.c:14
static BOOL bFoundAdapter
Definition: deskmon.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define _tcscmp
Definition: tchar.h:1424
#define _tcscat
Definition: tchar.h:622
#define TEXT(s)
Definition: k32.h:26
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define LMEM_FIXED
Definition: winbase.h:368
char TCHAR
Definition: xmlstorage.h:189
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define _tcslen
Definition: xmlstorage.h:198

Referenced by ShowMonitorProperties(), and UpdateMonitorSelection().

◆ GetPruningSettings()

static VOID GetPruningSettings ( PDESKMONITOR  This)
static

Definition at line 218 of file deskmon.c.

219{
220 BOOL bModesPruned = FALSE, bKeyIsReadOnly = FALSE, bPruningOn = FALSE;
221
222 if (This->DeskExtInterface != NULL)
223 {
224 This->DeskExtInterface->GetPruningMode(This->DeskExtInterface->Context,
225 &bModesPruned,
226 &bKeyIsReadOnly,
227 &bPruningOn);
228 }
229
230 /* Check the boolean values against zero before assigning it to the bitfields! */
231 This->bModesPruned = (bModesPruned != FALSE);
232 This->bKeyIsReadOnly = (bKeyIsReadOnly != FALSE);
233 This->bPruningOn = (bPruningOn != FALSE);
234
236}
static VOID UpdatePruningControls(PDESKMONITOR This)
Definition: deskmon.c:207
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94

Referenced by UpdateRefreshFrequencyList().

◆ IDeskMonitor_AddPages()

HRESULT IDeskMonitor_AddPages ( PDESKMONITOR  This,
LPFNADDPROPSHEETPAGE  pfnAddPage,
LPARAM  lParam 
)

Definition at line 810 of file deskmon.c.

813{
814 HPROPSHEETPAGE hpsp;
815 PROPSHEETPAGE psp;
816
817 DPRINT1("IDeskMonitor::AddPages(%p,%p)\n", pfnAddPage, lParam);
818
819 psp.dwSize = sizeof(psp);
820 psp.dwFlags = PSP_DEFAULT;
821 psp.hInstance = hInstance;
822 psp.pszTemplate = MAKEINTRESOURCE(IDD_MONITOR);
823 psp.pfnDlgProc = MonitorDlgProc;
824 psp.lParam = (LPARAM)This;
825
826 hpsp = CreatePropertySheetPage(&psp);
827 if (hpsp != NULL && pfnAddPage(hpsp, lParam))
828 return S_OK;
829
830 return S_FALSE;
831}
LPARAM lParam
Definition: combotst.c:139
static INT_PTR CALLBACK MonitorDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: deskmon.c:610
#define IDD_MONITOR
Definition: resource.h:3
#define S_OK
Definition: intsafe.h:52
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
#define CreatePropertySheetPage
Definition: prsht.h:399
#define PSP_DEFAULT
Definition: prsht.h:22
#define PROPSHEETPAGE
Definition: prsht.h:389
LONG_PTR LPARAM
Definition: windef.h:208
#define S_FALSE
Definition: winerror.h:2357
#define MAKEINTRESOURCE
Definition: winuser.h:591

Referenced by IDeskMonitor_IShellPropSheetExt_AddPages().

◆ IDeskMonitor_AddRef()

ULONG IDeskMonitor_AddRef ( PDESKMONITOR  This)

Definition at line 723 of file deskmon.c.

724{
725 ULONG ret;
726
728 if (ret == 1)
730
731 return ret;
732}
#define InterlockedIncrement
Definition: armddk.h:53
DECLSPEC_HIDDEN LONG dll_refs
Definition: devenum_main.c:28
int32_t * PLONG
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
int ret

Referenced by IDeskMonitor_IClassFactory_AddRef(), IDeskMonitor_InitIface(), IDeskMonitor_IShellExtInit_AddRef(), IDeskMonitor_IShellPropSheetExt_AddRef(), and IDeskMonitor_QueryInterface().

◆ IDeskMonitor_Constructor()

HRESULT IDeskMonitor_Constructor ( REFIID  riid,
LPVOID ppv 
)

Definition at line 844 of file deskmon.c.

846{
848 HRESULT hRet = E_OUTOFMEMORY;
849
850 DPRINT1("IDeskMonitor::Constructor(%p,%p)\n", riid, ppv);
851
853 0,
854 sizeof(*This));
855 if (This != NULL)
856 {
858 sizeof(*This));
859
861
863 riid,
864 ppv);
865 if (!SUCCEEDED(hRet))
867 }
868
869 return hRet;
870}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
ULONG IDeskMonitor_Release(PDESKMONITOR This)
Definition: deskmon.c:735
HRESULT STDMETHODCALLTYPE IDeskMonitor_QueryInterface(PDESKMONITOR This, REFIID iid, PVOID *pvObject)
Definition: deskmon.c:754
VOID IDeskMonitor_InitIface(PDESKMONITOR This)
Definition: shxiface.c:176
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define ZeroMemory
Definition: winbase.h:1712

Referenced by DllGetClassObject(), and IDeskMonitor_IClassFactory_CreateInstance().

◆ IDeskMonitor_Destroy()

static VOID IDeskMonitor_Destroy ( PDESKMONITOR  This)
static

Definition at line 689 of file deskmon.c.

690{
691 PDESKMONINFO pmi, pminext;
692
693 if (This->pdtobj != NULL)
694 {
695 IDataObject_Release(This->pdtobj);
696 This->pdtobj = NULL;
697 }
698
699 if (This->DeskExtInterface != NULL)
700 {
701 LocalFree((HLOCAL)This->DeskExtInterface);
702 This->DeskExtInterface = NULL;
703 }
704
705 if (This->lpDisplayDevice != NULL)
706 {
707 LocalFree((HLOCAL)This->lpDisplayDevice);
708 This->lpDisplayDevice = NULL;
709 }
710
711 /* Free all monitors */
712 pmi = This->Monitors;
713 This->Monitors = NULL;
714 while (pmi != NULL)
715 {
716 pminext = pmi->Next;
717 LocalFree((HLOCAL)pmi);
718 pmi = pminext;
719 }
720}
struct _DESKMONINFO * Next
Definition: deskmon.h:6

Referenced by IDeskMonitor_Release().

◆ IDeskMonitor_Initialize()

HRESULT IDeskMonitor_Initialize ( PDESKMONITOR  This,
LPCITEMIDLIST  pidlFolder,
IDataObject pdtobj,
HKEY  hkeyProgID 
)

Definition at line 788 of file deskmon.c.

792{
793 DPRINT1("IDeskMonitor::Initialize(%p,%p,%p)\n", pidlFolder, pdtobj, hkeyProgID);
794
795 if (pdtobj != NULL)
796 {
797 IDataObject_AddRef(pdtobj);
798 This->pdtobj = pdtobj;
799
800 /* Get a copy of the desk.cpl extension interface */
801 This->DeskExtInterface = QueryDeskCplExtInterface(This->pdtobj);
802 if (This->DeskExtInterface != NULL)
803 return S_OK;
804 }
805
806 return S_FALSE;
807}
static __inline PDESK_EXT_INTERFACE QueryDeskCplExtInterface(IDataObject *pdo)
Definition: deskcplx.h:48

Referenced by IDeskMonitor_IShellExtInit_Initialize().

◆ IDeskMonitor_QueryInterface()

HRESULT STDMETHODCALLTYPE IDeskMonitor_QueryInterface ( PDESKMONITOR  This,
REFIID  iid,
PVOID pvObject 
)

Definition at line 754 of file deskmon.c.

757{
758 *pvObject = NULL;
759
760 if (IsEqualIID(iid,
761 &IID_IShellPropSheetExt) ||
762 IsEqualIID(iid,
763 &IID_IUnknown))
764 {
766 }
767 else if (IsEqualIID(iid,
768 &IID_IShellExtInit))
769 {
771 }
772 else if (IsEqualIID(iid,
774 {
776 }
777 else
778 {
779 DPRINT1("IDeskMonitor::QueryInterface(%p,%p): E_NOINTERFACE\n", iid, pvObject);
780 return E_NOINTERFACE;
781 }
782
784 return S_OK;
785}
const GUID IID_IUnknown
const GUID IID_IClassFactory
ULONG IDeskMonitor_AddRef(PDESKMONITOR This)
Definition: deskmon.c:723
#define impl_to_interface(impl, iface)
Definition: dwnl.c:35
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

Referenced by IDeskMonitor_Constructor(), IDeskMonitor_IClassFactory_QueryInterface(), IDeskMonitor_IShellExtInit_QueryInterface(), and IDeskMonitor_IShellPropSheetExt_QueryInterface().

◆ IDeskMonitor_Release()

ULONG IDeskMonitor_Release ( PDESKMONITOR  This)

Definition at line 735 of file deskmon.c.

736{
737 ULONG ret;
738
740 if (ret == 0)
741 {
744
746 0,
747 This);
748 }
749
750 return ret;
751}
#define InterlockedDecrement
Definition: armddk.h:52
static VOID IDeskMonitor_Destroy(PDESKMONITOR This)
Definition: deskmon.c:689
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by IDeskMonitor_Constructor(), IDeskMonitor_IClassFactory_Release(), IDeskMonitor_IShellExtInit_Release(), and IDeskMonitor_IShellPropSheetExt_Release().

◆ IDeskMonitor_ReplacePage()

HRESULT IDeskMonitor_ReplacePage ( PDESKMONITOR  This,
EXPPS  uPageID,
LPFNADDPROPSHEETPAGE  pfnReplacePage,
LPARAM  lParam 
)

Definition at line 834 of file deskmon.c.

838{
839 DPRINT1("IDeskMonitor::ReplacePage(%u,%p,%p)\n", uPageID, pfnReplacePage, lParam);
840 return E_NOTIMPL;
841}
#define E_NOTIMPL
Definition: ddrawi.h:99

Referenced by IDeskMonitor_IShellPropSheetExt_ReplacePage().

◆ InitMonitorDialog()

static VOID InitMonitorDialog ( PDESKMONITOR  This)
static

Definition at line 345 of file deskmon.c.

346{
347 PDESKMONINFO pmi, pminext, *pmilink;
348 LPTSTR lpDeviceId;
349 CONFIGRET cr;
351 BOOL bRet;
352 INT i;
353 DWORD dwIndex;
354
355 /* Free all allocated monitors */
356 pmi = This->Monitors;
357 This->Monitors = NULL;
358 while (pmi != NULL)
359 {
360 pminext = pmi->Next;
361 LocalFree((HLOCAL)pmi);
362 pmi = pminext;
363 }
364
365 This->SelMonitor = NULL;
366 This->dwMonitorCount = 0;
367
369 lpDeviceId = QueryDeskCplString(This->pdtobj,
371
372 if (lpDeviceId != NULL && lpDeviceId[0] != TEXT('\0'))
373 {
375 lpDeviceId,
377 bFoundAdapter = (cr == CR_SUCCESS);
378
379 if (!bFoundAdapter)
380 DPRINT1("CM_Locate_DevNode failed: %d\n", cr);
381 }
382
383 if (This->lpDisplayDevice != NULL)
384 LocalFree((HLOCAL)This->lpDisplayDevice);
385
386 This->lpDisplayDevice = QueryDeskCplString(This->pdtobj,
388
389 if (This->DeskExtInterface != NULL)
390 {
391 if (This->lpDisplayDevice != NULL)
392 {
393 /* Enumerate all monitors */
394 dwIndex = 0;
395 pmilink = &This->Monitors;
396
397 do
398 {
399 dd.cb = sizeof(dd);
400 bRet = EnumDisplayDevices(This->lpDisplayDevice,
401 dwIndex++,
402 &dd,
403 0);
404 if (bRet)
405 {
407 sizeof(*pmi));
408 if (pmi != NULL)
409 {
410 CopyMemory(&pmi->dd,
411 &dd,
412 sizeof(dd));
413 pmi->Next = NULL;
414 *pmilink = pmi;
415 pmilink = &pmi->Next;
416
417 This->dwMonitorCount++;
418 }
419 }
420 } while (bRet);
421 }
422
423 This->lpDevModeOnInit = This->DeskExtInterface->GetCurrentMode(This->DeskExtInterface->Context);
424 }
425 else
426 This->lpDevModeOnInit = NULL;
427
428 This->lpSelDevMode = This->lpDevModeOnInit;
429
430 /* Setup the UI depending on how many monitors are attached */
431 if (This->dwMonitorCount == 0)
432 {
433 LPTSTR lpMonitorName;
434
435 /* This is a fallback, let's hope that desk.cpl can provide us with a monitor name */
436 lpMonitorName = QueryDeskCplString(This->pdtobj,
438
439 SetDlgItemText(This->hwndDlg,
441 lpMonitorName);
442
443 if (lpMonitorName != NULL)
444 LocalFree((HLOCAL)lpMonitorName);
445 }
446 else if (This->dwMonitorCount == 1)
447 {
448 This->SelMonitor = This->Monitors;
449 SetDlgItemText(This->hwndDlg,
451 This->Monitors->dd.DeviceString);
452 }
453 else
454 {
455 SendDlgItemMessage(This->hwndDlg,
458 0,
459 0);
460
461 pmi = This->Monitors;
462 while (pmi != NULL)
463 {
464 i = (INT)SendDlgItemMessage(This->hwndDlg,
467 0,
468 (LPARAM)pmi->dd.DeviceString);
469 if (i >= 0)
470 {
471 SendDlgItemMessage(This->hwndDlg,
474 (WPARAM)i,
475 (LPARAM)pmi);
476
477 if (This->SelMonitor == NULL)
478 {
479 SendDlgItemMessage(This->hwndDlg,
482 (WPARAM)i,
483 0);
484
485 This->SelMonitor = pmi;
486 }
487 }
488
489 pmi = pmi->Next;
490 }
491 }
492
493 /* Show/Hide controls */
494 ShowWindow(GetDlgItem(This->hwndDlg,
496 (This->dwMonitorCount <= 1 ? SW_SHOW : SW_HIDE));
497 ShowWindow(GetDlgItem(This->hwndDlg,
499 (This->dwMonitorCount > 1 ? SW_SHOW : SW_HIDE));
500
503}
#define CM_Locate_DevNode
Definition: cfgmgr32.h:2403
#define CM_LOCATE_DEVNODE_NORMAL
Definition: cfgmgr32.h:760
#define DESK_EXT_MONITORNAME
Definition: deskcplx.h:13
static __inline LPTSTR QueryDeskCplString(IDataObject *pdo, UINT cfFormat)
Definition: deskcplx.h:84
#define DESK_EXT_DISPLAYDEVICE
Definition: deskcplx.h:8
#define DESK_EXT_DISPLAYID
Definition: deskcplx.h:10
static VOID UpdateRefreshFrequencyList(PDESKMONITOR This)
Definition: deskmon.c:239
static VOID UpdateMonitorSelection(PDESKMONITOR This)
Definition: deskmon.c:169
#define IDC_MONITORNAME
Definition: resource.h:5
#define IDC_MONITORLIST
Definition: resource.h:6
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define INT
Definition: polytest.cpp:20
DISPLAY_DEVICE dd
Definition: deskmon.h:5
CHAR DeviceString[128]
Definition: wingdi.h:2811
int32_t INT
Definition: typedefs.h:58
#define CopyMemory
Definition: winbase.h:1710
UINT_PTR WPARAM
Definition: windef.h:207
#define SW_HIDE
Definition: winuser.h:768
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define RegisterClipboardFormat
Definition: winuser.h:5838
#define LB_ADDSTRING
Definition: winuser.h:2031
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define LB_RESETCONTENT
Definition: winuser.h:2055
#define LB_SETITEMDATA
Definition: winuser.h:2065
#define SW_SHOW
Definition: winuser.h:775
#define LB_SETCURSEL
Definition: winuser.h:2063
#define SendDlgItemMessage
Definition: winuser.h:5842
#define SetDlgItemText
Definition: winuser.h:5849

Referenced by ApplyMonitorChanges(), and MonitorDlgProc().

◆ MonitorDlgProc()

static INT_PTR CALLBACK MonitorDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 610 of file deskmon.c.

614{
616 INT_PTR Ret = 0;
617
618 if (uMsg != WM_INITDIALOG)
619 {
621 }
622
623 switch (uMsg)
624 {
625 case WM_INITDIALOG:
627 This->hwndDlg = hwndDlg;
629
631 Ret = TRUE;
632 break;
633
634 case WM_COMMAND:
635 switch (LOWORD(wParam))
636 {
639 break;
640
641 case IDC_MONITORLIST:
644 break;
645
646 case IDC_PRUNINGCHECK:
647 if (HIWORD(wParam) == BN_CLICKED)
649 break;
650
651 case IDC_REFRESHRATE:
654 break;
655 }
656 break;
657
658 case WM_NOTIFY:
659 {
660 NMHDR *nmh = (NMHDR *)lParam;
661
662 switch (nmh->code)
663 {
664 case PSN_APPLY:
665 {
666 SetWindowLongPtr(hwndDlg,
669 Ret = TRUE;
670 break;
671 }
672
673 case PSN_RESET:
675 break;
676
677 case PSN_SETACTIVE:
679 break;
680 }
681 break;
682 }
683 }
684
685 return Ret;
686}
WPARAM wParam
Definition: combotst.c:138
static LONG ApplyMonitorChanges(PDESKMONITOR This)
Definition: deskmon.c:570
static VOID ShowMonitorProperties(PDESKMONITOR This)
Definition: deskmon.c:136
static VOID UpdateRefreshRateSelection(PDESKMONITOR This)
Definition: deskmon.c:534
static VOID UpdatePruningSelection(PDESKMONITOR This)
Definition: deskmon.c:506
static VOID ResetMonitorChanges(PDESKMONITOR This)
Definition: deskmon.c:600
struct _DESKMONITOR * PDESKMONITOR
#define IDC_PRUNINGCHECK
Definition: resource.h:11
#define IDC_MONITORPROPERTIES
Definition: resource.h:7
#define IDC_REFRESHRATE
Definition: resource.h:10
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
#define PSN_APPLY
Definition: prsht.h:117
#define LPCPROPSHEETPAGE
Definition: prsht.h:391
#define PSN_RESET
Definition: prsht.h:118
#define PSN_SETACTIVE
Definition: prsht.h:115
#define WM_NOTIFY
Definition: richedit.h:61
UINT code
Definition: winuser.h:3159
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
int32_t INT_PTR
Definition: typedefs.h:64
#define HIWORD(l)
Definition: typedefs.h:247
#define DWLP_USER
Definition: winuser.h:872
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define CBN_SELCHANGE
Definition: winuser.h:1979
#define LBN_SELCHANGE
Definition: winuser.h:2075
#define DWLP_MSGRESULT
Definition: winuser.h:870
#define BN_CLICKED
Definition: winuser.h:1925

Referenced by IDeskMonitor_AddPages().

◆ ResetMonitorChanges()

static VOID ResetMonitorChanges ( PDESKMONITOR  This)
static

Definition at line 600 of file deskmon.c.

601{
602 if (This->DeskExtInterface != NULL && This->lpDevModeOnInit != NULL)
603 {
604 This->DeskExtInterface->SetCurrentMode(This->DeskExtInterface->Context,
605 This->lpDevModeOnInit);
606 }
607}

Referenced by MonitorDlgProc().

◆ ShowMonitorProperties()

static VOID ShowMonitorProperties ( PDESKMONITOR  This)
static

Definition at line 136 of file deskmon.c.

137{
138 HMODULE hDevMgr;
139 PDEVICEPROPERTIES pDeviceProperties;
140 LPTSTR lpDevInstID;
141
142 if (This->SelMonitor != NULL)
143 {
144 lpDevInstID = GetMonitorDevInstID(This->SelMonitor->dd.DeviceID);
145 if (lpDevInstID != NULL)
146 {
147 hDevMgr = LoadLibrary(TEXT("devmgr.dll"));
148 if (hDevMgr != NULL)
149 {
150 pDeviceProperties = (PDEVICEPROPERTIES)GetProcAddress(hDevMgr,
152 if (pDeviceProperties != NULL)
153 {
154 pDeviceProperties(This->hwndDlg,
155 NULL,
156 lpDevInstID,
157 FALSE);
158 }
159
160 FreeLibrary(hDevMgr);
161 }
162
163 LocalFree((HLOCAL)lpDevInstID);
164 }
165 }
166}
static LPTSTR GetMonitorDevInstID(LPCTSTR lpDeviceID)
Converts a Hardware ID (DeviceID from EnumDisplayDevices) to an unique Device Instance ID.
Definition: deskmon.c:44
INT_PTR(WINAPI * PDEVICEPROPERTIES)(HWND, LPCSTR, LPCSTR, BOOL)
Definition: deskmon.c:20
#define FUNC_DEVICEPROPERTIES
Definition: deskmon.c:21
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibrary
Definition: winbase.h:3862

Referenced by MonitorDlgProc().

◆ UpdateMonitorSelection()

static VOID UpdateMonitorSelection ( PDESKMONITOR  This)
static

Definition at line 169 of file deskmon.c.

170{
171 INT i;
172 LPTSTR lpDevInstID = NULL;
173
174 if (This->dwMonitorCount > 1)
175 {
176 This->SelMonitor = NULL;
177
178 i = (INT)SendDlgItemMessage(This->hwndDlg,
181 0,
182 0);
183 if (i >= 0)
184 {
185 This->SelMonitor = (PDESKMONINFO)SendDlgItemMessage(This->hwndDlg,
188 (WPARAM)i,
189 0);
190 }
191 }
192 else
193 This->SelMonitor = This->Monitors;
194
195 if (This->SelMonitor != NULL)
196 lpDevInstID = GetMonitorDevInstID(This->SelMonitor->dd.DeviceID);
197
200 lpDevInstID != NULL && lpDevInstID[0] != TEXT('\0'));
201
202 if (lpDevInstID != NULL)
203 LocalFree((HLOCAL)lpDevInstID);
204}
struct _DESKMONINFO * PDESKMONINFO
#define LB_GETITEMDATA
Definition: winuser.h:2041
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define LB_GETCURSEL
Definition: winuser.h:2039

Referenced by InitMonitorDialog(), and MonitorDlgProc().

◆ UpdatePruningControls()

static VOID UpdatePruningControls ( PDESKMONITOR  This)
static

Definition at line 207 of file deskmon.c.

208{
211 This->bModesPruned && !This->bKeyIsReadOnly);
212 CheckDlgButton(This->hwndDlg,
214 (This->bModesPruned && This->bPruningOn) ? BST_CHECKED : BST_UNCHECKED);
215}
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define BST_UNCHECKED
Definition: winuser.h:199
#define BST_CHECKED
Definition: winuser.h:197

Referenced by GetPruningSettings().

◆ UpdatePruningSelection()

static VOID UpdatePruningSelection ( PDESKMONITOR  This)
static

Definition at line 506 of file deskmon.c.

507{
508 BOOL bPruningOn;
509
510 if (This->DeskExtInterface != NULL && This->bModesPruned && !This->bKeyIsReadOnly)
511 {
512 bPruningOn = IsDlgButtonChecked(This->hwndDlg,
514
515 if (bPruningOn != This->bPruningOn)
516 {
517 /* Tell desk.cpl to turn on/off pruning mode */
518 This->bPruningOn = bPruningOn;
519 This->DeskExtInterface->SetPruningMode(This->DeskExtInterface->Context,
520 bPruningOn);
521
522 /* Fill the refresh rate combobox again, we now receive a filtered
523 or unfiltered device mode list from desk.cpl (depending on whether
524 pruning is active or not) */
526
528 This->hwndDlg);
529 }
530 }
531}
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)

Referenced by MonitorDlgProc().

◆ UpdateRefreshFrequencyList()

static VOID UpdateRefreshFrequencyList ( PDESKMONITOR  This)
static

Definition at line 239 of file deskmon.c.

240{
241 PDEVMODEW lpCurrentMode, lpMode;
242 TCHAR szBuffer[64];
243 DWORD dwIndex;
244 INT i;
245 BOOL bHasDef = FALSE;
246 BOOL bAdded = FALSE;
247
248 /* Fill the refresh rate combo box */
249 SendDlgItemMessage(This->hwndDlg,
252 0,
253 0);
254
255 lpCurrentMode = This->DeskExtInterface->GetCurrentMode(This->DeskExtInterface->Context);
256 dwIndex = 0;
257
258 do
259 {
260 lpMode = This->DeskExtInterface->EnumAllModes(This->DeskExtInterface->Context,
261 dwIndex++);
262 if (lpMode != NULL &&
263 lpMode->dmBitsPerPel == lpCurrentMode->dmBitsPerPel &&
264 lpMode->dmPelsWidth == lpCurrentMode->dmPelsWidth &&
265 lpMode->dmPelsHeight == lpCurrentMode->dmPelsHeight)
266 {
267 /* We're only interested in refresh rates for the current resolution and color depth */
268
269 if (lpMode->dmDisplayFrequency <= 1)
270 {
271 /* Default hardware frequency */
272 if (bHasDef)
273 continue;
274
275 bHasDef = TRUE;
276
279 szBuffer,
280 sizeof(szBuffer) / sizeof(szBuffer[0])))
281 {
282 szBuffer[0] = TEXT('\0');
283 }
284 }
285 else
286 {
287 TCHAR szFmt[64];
288
291 szFmt,
292 sizeof(szFmt) / sizeof(szFmt[0])))
293 {
294 szFmt[0] = TEXT('\0');
295 }
296
297 _sntprintf(szBuffer,
298 sizeof(szBuffer) / sizeof(szBuffer[0]),
299 szFmt,
300 lpMode->dmDisplayFrequency);
301 }
302
303 i = (INT)SendDlgItemMessage(This->hwndDlg,
306 0,
307 (LPARAM)szBuffer);
308 if (i >= 0)
309 {
310 bAdded = TRUE;
311
312 SendDlgItemMessage(This->hwndDlg,
315 (WPARAM)i,
316 (LPARAM)lpMode);
317
318 if (lpMode->dmDisplayFrequency == lpCurrentMode->dmDisplayFrequency)
319 {
320 SendDlgItemMessage(This->hwndDlg,
323 (WPARAM)i,
324 0);
325 }
326 }
327 }
328
329 } while (lpMode != NULL);
330
333 bAdded);
336 bAdded);
339 bAdded);
340
342}
static VOID GetPruningSettings(PDESKMONITOR This)
Definition: deskmon.c:218
#define IDS_MONITORSETTINGSGROUP
Definition: resource.h:8
#define IDS_REFRESHRATELABEL
Definition: resource.h:9
#define IDS_USEDEFFRQUENCY
Definition: resource.h:14
#define IDS_FREQFMT
Definition: resource.h:15
DWORD dmBitsPerPel
Definition: wingdi.h:1647
DWORD dmPelsWidth
Definition: wingdi.h:1648
DWORD dmPelsHeight
Definition: wingdi.h:1649
DWORD dmDisplayFrequency
Definition: wingdi.h:1654
#define CB_SETITEMDATA
Definition: winuser.h:1966
#define CB_SETCURSEL
Definition: winuser.h:1961
#define CB_RESETCONTENT
Definition: winuser.h:1959
#define CB_ADDSTRING
Definition: winuser.h:1936
#define LoadString
Definition: winuser.h:5819
#define _sntprintf
Definition: xmlstorage.h:201

Referenced by InitMonitorDialog(), MonitorDlgProc(), UpdatePruningSelection(), and UpdateRefreshRateSelection().

◆ UpdateRefreshRateSelection()

static VOID UpdateRefreshRateSelection ( PDESKMONITOR  This)
static

Definition at line 534 of file deskmon.c.

535{
536 PDEVMODEW lpCurrentDevMode;
537 INT i;
538
539 if (This->DeskExtInterface != NULL)
540 {
541 i = (INT)SendDlgItemMessage(This->hwndDlg,
544 0,
545 0);
546 if (i >= 0)
547 {
548 lpCurrentDevMode = This->lpSelDevMode;
549 This->lpSelDevMode = (PDEVMODEW)SendDlgItemMessage(This->hwndDlg,
552 (WPARAM)i,
553 0);
554
555 if (This->lpSelDevMode != NULL && This->lpSelDevMode != lpCurrentDevMode)
556 {
557 This->DeskExtInterface->SetCurrentMode(This->DeskExtInterface->Context,
558 This->lpSelDevMode);
559
561
563 This->hwndDlg);
564 }
565 }
566 }
567}
struct _devicemodeW * PDEVMODEW
#define CB_GETITEMDATA
Definition: winuser.h:1950
#define CB_GETCURSEL
Definition: winuser.h:1943

Referenced by MonitorDlgProc().

Variable Documentation

◆ bFoundAdapter

BOOL bFoundAdapter
static

Definition at line 13 of file deskmon.c.

Referenced by GetMonitorDevInstID(), InitMonitorDialog(), Release(), and Renew().

◆ diAdapter

DEVINST diAdapter
static

Definition at line 14 of file deskmon.c.

Referenced by GetMonitorDevInstID(), and InitMonitorDialog().

◆ hInstance

HINSTANCE hInstance
static

Definition at line 12 of file deskmon.c.

Referenced by DllMain(), IDeskMonitor_AddPages(), and UpdateRefreshFrequencyList().