Author: weiden
Date: Fri Sep 28 08:07:26 2007
New Revision: 29266
URL:
http://svn.reactos.org/svn/reactos?rev=29266&view=rev
Log:
Allow changing the display refresh frequency
Modified:
trunk/reactos/dll/win32/shellext/deskmon/deskmon.c
trunk/reactos/dll/win32/shellext/deskmon/deskmon.h
trunk/reactos/dll/win32/shellext/deskmon/lang/en-US.rc
trunk/reactos/dll/win32/shellext/deskmon/resource.h
Modified: trunk/reactos/dll/win32/shellext/deskmon/deskmon.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shellext/deskmon…
==============================================================================
--- trunk/reactos/dll/win32/shellext/deskmon/deskmon.c (original)
+++ trunk/reactos/dll/win32/shellext/deskmon/deskmon.c Fri Sep 28 08:07:26 2007
@@ -85,6 +85,144 @@
}
static VOID
+UpdatePruningControls(PDESKMONITOR This)
+{
+ EnableWindow(GetDlgItem(This->hwndDlg,
+ IDC_PRUNINGCHECK),
+ This->bModesPruned && !This->bKeyIsReadOnly);
+ CheckDlgButton(This->hwndDlg,
+ IDC_PRUNINGCHECK,
+ (This->bModesPruned && This->bPruningOn) ? BST_CHECKED :
BST_UNCHECKED);
+}
+
+static VOID
+GetPruningSettings(PDESKMONITOR This)
+{
+ BOOL bModesPruned = FALSE, bKeyIsReadOnly = FALSE, bPruningOn = FALSE;
+
+ if (This->DeskExtInterface != NULL)
+ {
+
This->DeskExtInterface->GetPruningMode(This->DeskExtInterface->Context,
+ &bModesPruned,
+ &bKeyIsReadOnly,
+ &bPruningOn);
+ }
+
+ /* Check the boolean values against zero before assigning it to the bitfields! */
+ This->bModesPruned = (bModesPruned != FALSE);
+ This->bKeyIsReadOnly = (bKeyIsReadOnly != FALSE);
+ This->bPruningOn = (bPruningOn != FALSE);
+
+ UpdatePruningControls(This);
+}
+
+static VOID
+UpdateRefreshFrequencyList(PDESKMONITOR This)
+{
+ PDEVMODEW lpCurrentMode, lpMode;
+ TCHAR szBuffer[64];
+ DWORD dwIndex;
+ INT i;
+ BOOL bHasDef = FALSE;
+ BOOL bAdded = FALSE;
+
+ /* Fill the refresh rate combo box */
+ SendDlgItemMessage(This->hwndDlg,
+ IDC_REFRESHRATE,
+ CB_RESETCONTENT,
+ 0,
+ 0);
+
+ lpCurrentMode =
This->DeskExtInterface->GetCurrentMode(This->DeskExtInterface->Context);
+ dwIndex = 0;
+
+ do
+ {
+ lpMode =
This->DeskExtInterface->EnumAllModes(This->DeskExtInterface->Context,
+ dwIndex++);
+ if (lpMode != NULL &&
+ lpMode->dmBitsPerPel == lpCurrentMode->dmBitsPerPel &&
+ lpMode->dmPelsWidth == lpCurrentMode->dmPelsWidth &&
+ lpMode->dmPelsHeight == lpCurrentMode->dmPelsHeight)
+ {
+ /* We're only interested in refresh rates for the current resolution and
color depth */
+
+ if (lpMode->dmDisplayFrequency <= 1)
+ {
+ /* Default hardware frequency */
+ if (bHasDef)
+ continue;
+
+ bHasDef = TRUE;
+
+ if (!LoadString(hInstance,
+ IDS_USEDEFFRQUENCY,
+ szBuffer,
+ sizeof(szBuffer) / sizeof(szBuffer[0])))
+ {
+ szBuffer[0] = TEXT('\0');
+ }
+ }
+ else
+ {
+ TCHAR szFmt[64];
+
+ if (!LoadString(hInstance,
+ IDS_FREQFMT,
+ szFmt,
+ sizeof(szFmt) / sizeof(szFmt[0])))
+ {
+ szFmt[0] = TEXT('\0');
+ }
+
+ _sntprintf(szBuffer,
+ sizeof(szBuffer) / sizeof(szBuffer[0]),
+ szFmt,
+ lpMode->dmDisplayFrequency);
+ }
+
+ i = (INT)SendDlgItemMessage(This->hwndDlg,
+ IDC_REFRESHRATE,
+ CB_ADDSTRING,
+ 0,
+ (LPARAM)szBuffer);
+ if (i >= 0)
+ {
+ bAdded = TRUE;
+
+ SendDlgItemMessage(This->hwndDlg,
+ IDC_REFRESHRATE,
+ CB_SETITEMDATA,
+ (WPARAM)i,
+ (LPARAM)lpMode);
+
+ if (lpMode->dmDisplayFrequency ==
lpCurrentMode->dmDisplayFrequency)
+ {
+ SendDlgItemMessage(This->hwndDlg,
+ IDC_REFRESHRATE,
+ CB_SETCURSEL,
+ (WPARAM)i,
+ 0);
+ }
+ }
+ }
+
+ } while (lpMode != NULL);
+
+ EnableWindow(GetDlgItem(This->hwndDlg,
+ IDS_MONITORSETTINGSGROUP),
+ bAdded);
+ EnableWindow(GetDlgItem(This->hwndDlg,
+ IDS_REFRESHRATELABEL),
+ bAdded);
+ EnableWindow(GetDlgItem(This->hwndDlg,
+ IDC_REFRESHRATE),
+ bAdded);
+
+ GetPruningSettings(This);
+}
+
+static VOID
InitMonitorDialog(PDESKMONITOR This)
{
PDESKMONINFO pmi, pminext, *pmilink;
@@ -92,10 +230,6 @@
BOOL bRet;
INT i;
DWORD dwIndex;
- PDEVMODEW lpCurrentMode, lpMode;
- TCHAR szBuffer[64];
- BOOL bHasDef = FALSE;
- BOOL bAdded = FALSE;
/* Free all allocated monitors */
pmi = This->Monitors;
@@ -155,6 +289,8 @@
else
This->lpDevModeOnInit = NULL;
+ This->lpSelDevMode = This->lpDevModeOnInit;
+
/* Setup the UI depending on how many monitors are attached */
if (This->dwMonitorCount == 0)
{
@@ -226,102 +362,72 @@
IDC_MONITORLIST),
(This->dwMonitorCount > 1 ? SW_SHOW : SW_HIDE));
- /* Fill the refresh rate combo box */
- SendDlgItemMessage(This->hwndDlg,
- IDC_REFRESHRATE,
- CB_RESETCONTENT,
- 0,
- 0);
-
- lpCurrentMode =
This->DeskExtInterface->GetCurrentMode(This->DeskExtInterface->Context);
- dwIndex = 0;
-
- do
- {
- lpMode =
This->DeskExtInterface->EnumAllModes(This->DeskExtInterface->Context,
- dwIndex++);
- if (lpMode != NULL &&
- lpMode->dmBitsPerPel == lpCurrentMode->dmBitsPerPel &&
- lpMode->dmPelsWidth == lpCurrentMode->dmPelsWidth &&
- lpMode->dmPelsHeight == lpCurrentMode->dmPelsHeight)
- {
- /* We're only interested in refresh rates for the current resolution and
color depth */
-
- if (lpMode->dmDisplayFrequency <= 1)
- {
- /* Default hardware frequency */
- if (bHasDef)
- continue;
-
- bHasDef = TRUE;
-
- if (!LoadString(hInstance,
- IDS_USEDEFFRQUENCY,
- szBuffer,
- sizeof(szBuffer) / sizeof(szBuffer[0])))
- {
- szBuffer[0] = TEXT('\0');
- }
+ UpdateRefreshFrequencyList(This);
+ UpdateMonitorSelection(This);
+}
+
+static VOID
+UpdatePruningSelection(PDESKMONITOR This)
+{
+ BOOL bPruningOn;
+
+ if (This->DeskExtInterface != NULL && This->bModesPruned &&
!This->bKeyIsReadOnly)
+ {
+ bPruningOn = IsDlgButtonChecked(This->hwndDlg,
+ IDC_PRUNINGCHECK) != BST_UNCHECKED;
+
+ if (bPruningOn != This->bPruningOn)
+ {
+ /* Tell desk.cpl to turn on/off pruning mode */
+ This->bPruningOn = bPruningOn;
+
This->DeskExtInterface->SetPruningMode(This->DeskExtInterface->Context,
+ bPruningOn);
+
+ /* Fill the refresh rate combobox again, we now receive a filtered
+ or unfiltered device mode list from desk.cpl (depending on whether
+ pruning is active or not) */
+ UpdateRefreshFrequencyList(This);
+
+ (void)PropSheet_Changed(GetParent(This->hwndDlg),
+ This->hwndDlg);
+ }
+ }
+}
+
+static VOID
+UpdateRefreshRateSelection(PDESKMONITOR This)
+{
+ PDEVMODEW lpCurrentDevMode;
+ INT i;
+
+ if (This->DeskExtInterface != NULL)
+ {
+ i = (INT)SendDlgItemMessage(This->hwndDlg,
+ IDC_REFRESHRATE,
+ CB_GETCURSEL,
+ 0,
+ 0);
+ if (i >= 0)
+ {
+ lpCurrentDevMode = This->lpSelDevMode;
+ This->lpSelDevMode = (PDEVMODEW)SendDlgItemMessage(This->hwndDlg,
+ IDC_REFRESHRATE,
+ CB_GETITEMDATA,
+ (WPARAM)i,
+ 0);
+
+ if (This->lpSelDevMode != NULL && This->lpSelDevMode !=
lpCurrentDevMode)
+ {
+
This->DeskExtInterface->SetCurrentMode(This->DeskExtInterface->Context,
+ This->lpSelDevMode);
+
+ UpdateRefreshFrequencyList(This);
+
+ (void)PropSheet_Changed(GetParent(This->hwndDlg),
+ This->hwndDlg);
}
- else
- {
- TCHAR szFmt[64];
-
- if (!LoadString(hInstance,
- IDS_FREQFMT,
- szFmt,
- sizeof(szFmt) / sizeof(szFmt[0])))
- {
- szFmt[0] = TEXT('\0');
- }
-
- _sntprintf(szBuffer,
- sizeof(szBuffer) / sizeof(szBuffer[0]),
- szFmt,
- lpMode->dmDisplayFrequency);
- }
-
- i = (INT)SendDlgItemMessage(This->hwndDlg,
- IDC_REFRESHRATE,
- CB_ADDSTRING,
- 0,
- (LPARAM)szBuffer);
- if (i >= 0)
- {
- bAdded = TRUE;
-
- SendDlgItemMessage(This->hwndDlg,
- IDC_REFRESHRATE,
- CB_SETITEMDATA,
- (WPARAM)lpMode,
- 0);
-
- if (lpMode->dmDisplayFrequency ==
lpCurrentMode->dmDisplayFrequency)
- {
- SendDlgItemMessage(This->hwndDlg,
- IDC_REFRESHRATE,
- CB_SETCURSEL,
- (WPARAM)i,
- 0);
- }
- }
- }
-
- } while (lpMode != NULL);
-
- EnableWindow(GetDlgItem(This->hwndDlg,
- IDS_MONITORSETTINGSGROUP),
- bAdded);
- EnableWindow(GetDlgItem(This->hwndDlg,
- IDS_REFRESHRATELABEL),
- bAdded);
- EnableWindow(GetDlgItem(This->hwndDlg,
- IDC_REFRESHRATE),
- bAdded);
-
- /* FIXME: Update pruning mode controls */
-
- UpdateMonitorSelection(This);
+ }
+ }
}
static LONG
@@ -338,6 +444,7 @@
{
/* Save the new mode */
This->lpDevModeOnInit =
This->DeskExtInterface->GetCurrentMode(This->DeskExtInterface->Context);
+ This->lpSelDevMode = This->lpDevModeOnInit;
return PSNRET_NOERROR;
}
else if (lChangeRet == DISP_CHANGE_RESTART)
@@ -401,6 +508,16 @@
case IDC_MONITORLIST:
if (HIWORD(wParam) == LBN_SELCHANGE)
UpdateMonitorSelection(This);
+ break;
+
+ case IDC_PRUNINGCHECK:
+ if (HIWORD(wParam) == BN_CLICKED)
+ UpdatePruningSelection(This);
+ break;
+
+ case IDC_REFRESHRATE:
+ if (HIWORD(wParam) == CBN_SELCHANGE)
+ UpdateRefreshRateSelection(This);
break;
}
break;
@@ -422,6 +539,10 @@
case PSN_RESET:
ResetMonitorChanges(This);
break;
+
+ case PSN_SETACTIVE:
+ UpdateRefreshFrequencyList(This);
+ break;
}
break;
}
Modified: trunk/reactos/dll/win32/shellext/deskmon/deskmon.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shellext/deskmon…
==============================================================================
--- trunk/reactos/dll/win32/shellext/deskmon/deskmon.h (original)
+++ trunk/reactos/dll/win32/shellext/deskmon/deskmon.h Fri Sep 28 08:07:26 2007
@@ -21,7 +21,19 @@
DWORD dwMonitorCount;
PDESKMONINFO Monitors;
PDESKMONINFO SelMonitor;
+ PDEVMODEW lpSelDevMode;
PDEVMODEW lpDevModeOnInit;
+ union
+ {
+ DWORD dwFlags;
+ struct
+ {
+ DWORD bModesPruned : 1;
+ DWORD bKeyIsReadOnly : 1;
+ DWORD bPruningOn : 1;
+ };
+ };
+
} DESKMONITOR, *PDESKMONITOR;
extern LONG dll_refs;
Modified: trunk/reactos/dll/win32/shellext/deskmon/lang/en-US.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shellext/deskmon…
==============================================================================
--- trunk/reactos/dll/win32/shellext/deskmon/lang/en-US.rc (original)
+++ trunk/reactos/dll/win32/shellext/deskmon/lang/en-US.rc Fri Sep 28 08:07:26 2007
@@ -9,9 +9,10 @@
LTEXT "", IDC_MONITORNAME, 40, 17, 190, 20, SS_NOPREFIX
LISTBOX IDC_MONITORLIST, 40, 13, 196, 30, WS_VSCROLL
PUSHBUTTON "&Properties", IDC_MONITORPROPERTIES, 177, 35, 59, 14,
WS_DISABLED
- GROUPBOX "Monitor settings", IDS_MONITORSETTINGSGROUP, 7, 58, 237, 47
+ GROUPBOX "Monitor settings", IDS_MONITORSETTINGSGROUP, 7, 58, 237, 63
LTEXT "&Screen refresh rate:", IDS_REFRESHRATELABEL, 13, 73, 225, 8
COMBOBOX IDC_REFRESHRATE, 13, 85, 225, 200, WS_VSCROLL | CBS_DROPDOWNLIST | CBS_SORT
+ AUTOCHECKBOX "&Hide modes that this monitor can\'t display",
IDC_PRUNINGCHECK, 13, 106, 225, 10
END
STRINGTABLE
Modified: trunk/reactos/dll/win32/shellext/deskmon/resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shellext/deskmon…
==============================================================================
--- trunk/reactos/dll/win32/shellext/deskmon/resource.h (original)
+++ trunk/reactos/dll/win32/shellext/deskmon/resource.h Fri Sep 28 08:07:26 2007
@@ -9,6 +9,7 @@
#define IDS_MONITORSETTINGSGROUP 204
#define IDS_REFRESHRATELABEL 205
#define IDC_REFRESHRATE 206
+#define IDC_PRUNINGCHECK 207
#define IDS_USEDEFFRQUENCY 101
#define IDS_FREQFMT 102