ReactOS 0.4.15-dev-7113-g9ea2222
settings.c File Reference
#include "desk.h"
Include dependency graph for settings.c:

Go to the source code of this file.

Classes

struct  _SETTINGS_DATA
 
struct  _TIMEOUTDATA
 

Typedefs

typedef struct _SETTINGS_DATA SETTINGS_DATA
 
typedef struct _SETTINGS_DATAPSETTINGS_DATA
 
typedef struct _TIMEOUTDATA TIMEOUTDATA
 
typedef struct _TIMEOUTDATAPTIMEOUTDATA
 

Functions

static VOID UpdateDisplay (IN HWND hwndDlg, PSETTINGS_DATA pData, IN BOOL bUpdateThumb)
 
static int CompareSettings (PSETTINGS_ENTRY Entry, DWORD dmPelsWidth, DWORD dmPelsHeight, DWORD dmBitsPerPel, DWORD dmDisplayFrequency)
 
static PSETTINGS_ENTRY GetPossibleSettings (IN LPCTSTR DeviceName, OUT DWORD *pSettingsCount, OUT PSETTINGS_ENTRY *CurrentSettings)
 
static BOOL AddDisplayDevice (IN PSETTINGS_DATA pData, IN const DISPLAY_DEVICE *DisplayDevice)
 
static VOID OnDisplayDeviceChanged (IN HWND hwndDlg, IN PSETTINGS_DATA pData, IN PDISPLAY_DEVICE_ENTRY pDeviceEntry)
 
static VOID SettingsOnInitDialog (IN HWND hwndDlg)
 
static VOID ShowResolutionPreview (IN LPDRAWITEMSTRUCT draw, IN PSETTINGS_DATA pData)
 
static VOID ShowColorSpectrum (IN HDC hDC, IN LPRECT client, IN DWORD BitsPerPel, IN PSETTINGS_DATA pData)
 
static VOID OnBPPChanged (IN HWND hwndDlg, IN PSETTINGS_DATA pData)
 
static VOID OnResolutionChanged (IN HWND hwndDlg, IN PSETTINGS_DATA pData, IN DWORD NewPosition, IN BOOL bUpdateThumb)
 
UINT CALLBACK SettingsPageCallbackProc (HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp)
 
static INT_PTR CALLBACK ConfirmDlgProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
BOOL SwitchDisplayMode (HWND hwndDlg, PWSTR DeviceName, PSETTINGS_ENTRY seInit, PSETTINGS_ENTRY seNew, OUT PLONG rc)
 
static VOID ApplyDisplaySettings (HWND hwndDlg, PSETTINGS_DATA pData)
 
INT_PTR CALLBACK SettingsPageProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 

Typedef Documentation

◆ PSETTINGS_DATA

◆ PTIMEOUTDATA

◆ SETTINGS_DATA

◆ TIMEOUTDATA

Function Documentation

◆ AddDisplayDevice()

static BOOL AddDisplayDevice ( IN PSETTINGS_DATA  pData,
IN const DISPLAY_DEVICE DisplayDevice 
)
static

Definition at line 173 of file settings.c.

174{
175 PDISPLAY_DEVICE_ENTRY newEntry = NULL;
177 LPTSTR name = NULL;
178 LPTSTR key = NULL;
179 LPTSTR devid = NULL;
180 SIZE_T descriptionSize, nameSize, keySize, devidSize;
181 PSETTINGS_ENTRY Current;
182 DWORD ResolutionsCount = 1;
183 DWORD i;
184
186 if (!newEntry) goto ByeBye;
187
188 newEntry->Settings = GetPossibleSettings(DisplayDevice->DeviceName, &newEntry->SettingsCount, &newEntry->CurrentSettings);
189 if (!newEntry->Settings) goto ByeBye;
190
195
196 /* Count different resolutions */
197 for (Current = newEntry->Settings; Current != NULL; Current = Current->Flink)
198 {
199 if (Current->Flink != NULL &&
200 ((Current->dmPelsWidth != Current->Flink->dmPelsWidth) ||
201 (Current->dmPelsHeight != Current->Flink->dmPelsHeight)))
202 {
203 ResolutionsCount++;
204 }
205 }
206
207 newEntry->Resolutions = HeapAlloc(GetProcessHeap(), 0, ResolutionsCount * sizeof(RESOLUTION_INFO));
208 if (!newEntry->Resolutions) goto ByeBye;
209
210 newEntry->ResolutionsCount = ResolutionsCount;
211
212 /* Fill resolutions infos */
213 for (Current = newEntry->Settings, i = 0; Current != NULL; Current = Current->Flink)
214 {
215 if (Current->Flink == NULL ||
216 (Current->Flink != NULL &&
217 ((Current->dmPelsWidth != Current->Flink->dmPelsWidth) ||
218 (Current->dmPelsHeight != Current->Flink->dmPelsHeight))))
219 {
220 newEntry->Resolutions[i].dmPelsWidth = Current->dmPelsWidth;
221 newEntry->Resolutions[i].dmPelsHeight = Current->dmPelsHeight;
222 i++;
223 }
224 }
225 descriptionSize = (_tcslen(DisplayDevice->DeviceString) + 1) * sizeof(TCHAR);
226 description = HeapAlloc(GetProcessHeap(), 0, descriptionSize);
227 if (!description) goto ByeBye;
228
229 nameSize = (_tcslen(DisplayDevice->DeviceName) + 1) * sizeof(TCHAR);
230 name = HeapAlloc(GetProcessHeap(), 0, nameSize);
231 if (!name) goto ByeBye;
232
233 keySize = (_tcslen(DisplayDevice->DeviceKey) + 1) * sizeof(TCHAR);
234 key = HeapAlloc(GetProcessHeap(), 0, keySize);
235 if (!key) goto ByeBye;
236
237 devidSize = (_tcslen(DisplayDevice->DeviceID) + 1) * sizeof(TCHAR);
238 devid = HeapAlloc(GetProcessHeap(), 0, devidSize);
239 if (!devid) goto ByeBye;
240
241 memcpy(description, DisplayDevice->DeviceString, descriptionSize);
242 memcpy(name, DisplayDevice->DeviceName, nameSize);
243 memcpy(key, DisplayDevice->DeviceKey, keySize);
244 memcpy(devid, DisplayDevice->DeviceID, devidSize);
245 newEntry->DeviceDescription = description;
246 newEntry->DeviceName = name;
247 newEntry->DeviceKey = key;
248 newEntry->DeviceID = devid;
249 newEntry->DeviceStateFlags = DisplayDevice->StateFlags;
250 newEntry->Flink = pData->DisplayDeviceList;
251 pData->DisplayDeviceList = newEntry;
252 return TRUE;
253
254ByeBye:
255 if (newEntry != NULL)
256 {
257 if (newEntry->Settings != NULL)
258 {
259 Current = newEntry->Settings;
260 while (Current != NULL)
261 {
262 PSETTINGS_ENTRY Next = Current->Flink;
263 HeapFree(GetProcessHeap(), 0, Current);
264 Current = Next;
265 }
266 }
267 if (newEntry->Resolutions != NULL)
268 HeapFree(GetProcessHeap(), 0, newEntry->Resolutions);
269 HeapFree(GetProcessHeap(), 0, newEntry);
270 }
271 if (description != NULL)
273 if (name != NULL)
275 if (key != NULL)
277 return FALSE;
278}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static PSETTINGS_ENTRY GetPossibleSettings(IN LPCTSTR DeviceName, OUT DWORD *pSettingsCount, OUT PSETTINGS_ENTRY *CurrentSettings)
Definition: settings.c:88
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned long DWORD
Definition: ntddk_ex.h:95
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 memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: precomp.h:68
PRESOLUTION_INFO Resolutions
Definition: precomp.h:77
struct _DISPLAY_DEVICE_ENTRY * Flink
Definition: precomp.h:69
DWORD SettingsCount
Definition: precomp.h:76
SETTINGS_ENTRY InitialSettings
Definition: precomp.h:80
PSETTINGS_ENTRY CurrentSettings
Definition: precomp.h:79
DWORD ResolutionsCount
Definition: precomp.h:78
DWORD DeviceStateFlags
Definition: precomp.h:74
LPWSTR DeviceID
Definition: precomp.h:73
LPWSTR DeviceDescription
Definition: precomp.h:70
PSETTINGS_ENTRY Settings
Definition: precomp.h:75
LPWSTR DeviceKey
Definition: precomp.h:72
LPWSTR DeviceName
Definition: precomp.h:71
DWORD dmPelsWidth
Definition: precomp.h:54
DWORD dmPelsHeight
Definition: precomp.h:55
Definition: precomp.h:59
DWORD dmPelsHeight
Definition: precomp.h:64
DWORD dmDisplayFrequency
Definition: desk.h:138
struct _SETTINGS_ENTRY * Flink
Definition: precomp.h:61
DWORD dmBitsPerPel
Definition: precomp.h:62
DWORD dmPelsWidth
Definition: precomp.h:63
Definition: copy.c:22
Definition: name.c:39
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
ULONG_PTR SIZE_T
Definition: typedefs.h:80
const char * description
Definition: directx.c:2497
char TCHAR
Definition: xmlstorage.h:189
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define _tcslen
Definition: xmlstorage.h:198

Referenced by SettingsOnInitDialog().

◆ ApplyDisplaySettings()

static VOID ApplyDisplaySettings ( HWND  hwndDlg,
PSETTINGS_DATA  pData 
)
static

Definition at line 846 of file settings.c.

847{
848 BOOL Ret;
849 LONG rc;
850
851 Ret = SwitchDisplayMode(hwndDlg,
852 pData->CurrentDisplayDevice->DeviceName,
853 &pData->CurrentDisplayDevice->InitialSettings,
854 pData->CurrentDisplayDevice->CurrentSettings,
855 &rc);
856
857 if (rc != DISP_CHANGE_SUCCESSFUL)
858 return;
859
860 if (Ret)
861 {
862 pData->CurrentDisplayDevice->InitialSettings.dmPelsWidth = pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth;
863 pData->CurrentDisplayDevice->InitialSettings.dmPelsHeight = pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight;
864 pData->CurrentDisplayDevice->InitialSettings.dmBitsPerPel = pData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel;
865 pData->CurrentDisplayDevice->InitialSettings.dmDisplayFrequency = pData->CurrentDisplayDevice->CurrentSettings->dmDisplayFrequency;
866 }
867 else
868 {
869 pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth = pData->CurrentDisplayDevice->InitialSettings.dmPelsWidth;
870 pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight = pData->CurrentDisplayDevice->InitialSettings.dmPelsHeight;
871 pData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel = pData->CurrentDisplayDevice->InitialSettings.dmBitsPerPel;
872 pData->CurrentDisplayDevice->CurrentSettings->dmDisplayFrequency = pData->CurrentDisplayDevice->InitialSettings.dmDisplayFrequency;
873 UpdateDisplay(hwndDlg, pData, TRUE);
874 }
875}
static VOID UpdateDisplay(IN HWND hwndDlg, PSETTINGS_DATA pData, IN BOOL bUpdateThumb)
Definition: settings.c:30
BOOL SwitchDisplayMode(HWND hwndDlg, PWSTR DeviceName, PSETTINGS_ENTRY seInit, PSETTINGS_ENTRY seNew, OUT PLONG rc)
Definition: settings.c:771
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190

Referenced by SettingsPageProc().

◆ CompareSettings()

static int CompareSettings ( PSETTINGS_ENTRY  Entry,
DWORD  dmPelsWidth,
DWORD  dmPelsHeight,
DWORD  dmBitsPerPel,
DWORD  dmDisplayFrequency 
)
static

Definition at line 66 of file settings.c.

68{
69 if (Entry->dmPelsWidth == dmPelsWidth &&
70 Entry->dmPelsHeight == dmPelsHeight &&
71 Entry->dmBitsPerPel == dmBitsPerPel &&
72 Entry->dmDisplayFrequency == dmDisplayFrequency)
73 {
74 return 0;
75 }
76 else
77 if ((Entry->dmPelsWidth < dmPelsWidth) ||
78 (Entry->dmPelsWidth == dmPelsWidth && Entry->dmPelsHeight < dmPelsHeight) ||
79 (Entry->dmPelsWidth == dmPelsWidth && Entry->dmPelsHeight == dmPelsHeight &&
80 Entry->dmBitsPerPel < dmBitsPerPel))
81 {
82 return 1;
83 }
84 return -1;
85}
base of all file and directory entries
Definition: entries.h:83

Referenced by GetPossibleSettings(), and OnResolutionChanged().

◆ ConfirmDlgProc()

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

Definition at line 708 of file settings.c.

709{
711
713
714 switch(uMsg)
715 {
716 case WM_INITDIALOG:
717 /* Allocate the local dialog data */
719 if (pData == NULL)
720 return FALSE;
721
722 /* Link the dialog data to the dialog */
724
725 /* Timeout in seconds */
726 pData->nTimeout = 15;
727
728 /* Load the raw timeout string */
729 LoadString(hApplet, IDS_TIMEOUTTEXT, pData->szRawBuffer, ARRAYSIZE(pData->szRawBuffer));
730
731 /* Cook the timeout string and show it */
732 _stprintf(pData->szCookedBuffer, pData->szRawBuffer, pData->nTimeout);
733 SetDlgItemText(hwndDlg, IDC_TIMEOUTTEXT, pData->szCookedBuffer);
734
735 /* Start the timer (ticks every second)*/
736 SetTimer(hwndDlg, 1, 1000, NULL);
737 break;
738
739 case WM_TIMER:
740 /* Update the timepout value */
741 pData->nTimeout--;
742
743 /* Update the timeout text */
744 _stprintf(pData->szCookedBuffer, pData->szRawBuffer, pData->nTimeout);
745 SetDlgItemText(hwndDlg, IDC_TIMEOUTTEXT, pData->szCookedBuffer);
746
747 /* Kill the timer and return a 'No', if we ran out of time */
748 if (pData->nTimeout == 0)
749 {
750 KillTimer(hwndDlg, 1);
751 EndDialog(hwndDlg, IDNO);
752 }
753 break;
754
755 case WM_COMMAND:
756 /* Kill the timer and return the clicked button id */
757 KillTimer(hwndDlg, 1);
758 EndDialog(hwndDlg, LOWORD(wParam));
759 break;
760
761 case WM_DESTROY:
762 /* Free the local dialog data */
764 break;
765 }
766
767 return FALSE;
768}
WPARAM wParam
Definition: combotst.c:138
HINSTANCE hApplet
Definition: access.c:17
#define IDC_TIMEOUTTEXT
Definition: resource.h:201
#define IDS_TIMEOUTTEXT
Definition: resource.h:202
struct _TIMEOUTDATA * PTIMEOUTDATA
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define _stprintf
Definition: utility.h:124
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define DWLP_USER
Definition: winuser.h:871
#define WM_COMMAND
Definition: winuser.h:1739
#define WM_INITDIALOG
Definition: winuser.h:1738
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_TIMER
Definition: winuser.h:1741
#define IDNO
Definition: winuser.h:835
#define LoadString
Definition: winuser.h:5818
#define WM_DESTROY
Definition: winuser.h:1608
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define SetDlgItemText
Definition: winuser.h:5848
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by SwitchDisplayMode().

◆ GetPossibleSettings()

static PSETTINGS_ENTRY GetPossibleSettings ( IN LPCTSTR  DeviceName,
OUT DWORD pSettingsCount,
OUT PSETTINGS_ENTRY CurrentSettings 
)
static

Definition at line 88 of file settings.c.

89{
91 DWORD NbSettings = 0;
92 DWORD iMode = 0;
93 DWORD dwFlags = 0;
95 HDC hDC;
96 PSETTINGS_ENTRY Current;
97 DWORD bpp, xres, yres;
98 DWORD curDispFreq;
99
100 /* Get current settings */
101 *CurrentSettings = NULL;
105 xres = GetDeviceCaps(hDC, HORZRES);
106 yres = GetDeviceCaps(hDC, VERTRES);
107 DeleteDC(hDC);
108
109 /* List all settings */
110 devmode.dmSize = (WORD)sizeof(devmode);
112
113 if (!EnumDisplaySettingsEx(DeviceName, ENUM_CURRENT_SETTINGS, &devmode, dwFlags))
114 return NULL;
115
116 curDispFreq = devmode.dmDisplayFrequency;
117
118 while (EnumDisplaySettingsEx(DeviceName, iMode, &devmode, dwFlags))
119 {
120 iMode++;
121
122 if (devmode.dmPelsWidth < 640 ||
123 devmode.dmPelsHeight < 480 ||
124 devmode.dmDisplayFrequency != curDispFreq ||
125 (devmode.dmBitsPerPel != 4 &&
126 devmode.dmBitsPerPel != 8 &&
127 devmode.dmBitsPerPel != 16 &&
128 devmode.dmBitsPerPel != 24 &&
129 devmode.dmBitsPerPel != 32))
130 {
131 continue;
132 }
133
134 Current = HeapAlloc(GetProcessHeap(), 0, sizeof(SETTINGS_ENTRY));
135 if (Current != NULL)
136 {
137 /* Sort resolutions by increasing height, and BPP */
138 PSETTINGS_ENTRY Previous = NULL;
144 while (Next != NULL &&
148 {
149 Previous = Next;
150 Next = Next->Flink;
151 }
152 Current->Blink = Previous;
153 Current->Flink = Next;
154 if (Previous == NULL)
155 Settings = Current;
156 else
157 Previous->Flink = Current;
158 if (Next != NULL)
159 Next->Blink = Current;
160 if (devmode.dmPelsWidth == xres && devmode.dmPelsHeight == yres && devmode.dmBitsPerPel == bpp)
161 {
162 *CurrentSettings = Current;
163 }
164 NbSettings++;
165 }
166 }
167
168 *pSettingsCount = NbSettings;
169 return Settings;
170}
static HDC hDC
Definition: 3dtext.c:33
DEVMODEW devmode
static int CompareSettings(PSETTINGS_ENTRY Entry, DWORD dmPelsWidth, DWORD dmPelsHeight, DWORD dmBitsPerPel, DWORD dmDisplayFrequency)
Definition: settings.c:66
DWORD bpp
Definition: surface.c:185
unsigned short WORD
Definition: ntddk_ex.h:93
static HDC
Definition: imagelist.c:92
struct _SETTINGS_ENTRY * Blink
Definition: precomp.h:60
DWORD dmBitsPerPel
Definition: wingdi.h:1647
DWORD dmPelsWidth
Definition: wingdi.h:1648
WORD dmDriverExtra
Definition: wingdi.h:1621
DWORD dmPelsHeight
Definition: wingdi.h:1649
DWORD dmDisplayFrequency
Definition: wingdi.h:1654
WORD dmSize
Definition: wingdi.h:1620
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings
Definition: wdfdevice.h:2595
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ ULONG iMode
Definition: winddi.h:3520
#define HORZRES
Definition: wingdi.h:716
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define VERTRES
Definition: wingdi.h:717
#define PLANES
Definition: wingdi.h:721
#define CreateIC
Definition: wingdi.h:4446
#define BITSPIXEL
Definition: wingdi.h:720
BOOL WINAPI DeleteDC(_In_ HDC)
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179

Referenced by AddDisplayDevice().

◆ OnBPPChanged()

static VOID OnBPPChanged ( IN HWND  hwndDlg,
IN PSETTINGS_DATA  pData 
)
static

Definition at line 497 of file settings.c.

498{
499 /* If new BPP is not compatible with resolution:
500 * 1) try to find the nearest smaller matching resolution
501 * 2) otherwise, get the nearest bigger resolution
502 */
503 PSETTINGS_ENTRY Current;
504 DWORD dmNewBitsPerPel;
505 DWORD index;
506 HDC hSpectrumDC;
507 HWND hSpectrumControl;
508 RECT client;
509
511 dmNewBitsPerPel = (DWORD) SendDlgItemMessage(hwndDlg, IDC_SETTINGS_BPP, CB_GETITEMDATA, index, 0);
512
513 /* Show a new spectrum bitmap */
514 hSpectrumControl = GetDlgItem(hwndDlg, IDC_SETTINGS_SPECTRUM);
515 hSpectrumDC = GetDC(hSpectrumControl);
516 if (hSpectrumDC == NULL)
517 return;
518
519 GetClientRect(hSpectrumControl, &client);
520 ShowColorSpectrum(hSpectrumDC, &client, dmNewBitsPerPel, pData);
521 ReleaseDC(hSpectrumControl, hSpectrumDC);
522
523 /* Find if new parameters are valid */
524 Current = pData->CurrentDisplayDevice->CurrentSettings;
525 if (dmNewBitsPerPel == Current->dmBitsPerPel)
526 {
527 /* No change */
528 return;
529 }
530
531 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
532
533 if (dmNewBitsPerPel < Current->dmBitsPerPel)
534 {
535 Current = Current->Blink;
536 while (Current != NULL)
537 {
538 if (Current->dmBitsPerPel == dmNewBitsPerPel
539 && Current->dmPelsHeight == pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight
540 && Current->dmPelsWidth == pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth)
541 {
542 pData->CurrentDisplayDevice->CurrentSettings = Current;
543 UpdateDisplay(hwndDlg, pData, TRUE);
544 return;
545 }
546 Current = Current->Blink;
547 }
548 }
549 else
550 {
551 Current = Current->Flink;
552 while (Current != NULL)
553 {
554 if (Current->dmBitsPerPel == dmNewBitsPerPel
555 && Current->dmPelsHeight == pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight
556 && Current->dmPelsWidth == pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth)
557 {
558 pData->CurrentDisplayDevice->CurrentSettings = Current;
559 UpdateDisplay(hwndDlg, pData, TRUE);
560 return;
561 }
562 Current = Current->Flink;
563 }
564 }
565
566 /* Search smaller resolution compatible with current color depth */
567 Current = pData->CurrentDisplayDevice->CurrentSettings->Blink;
568 while (Current != NULL)
569 {
570 if (Current->dmBitsPerPel == dmNewBitsPerPel)
571 {
572 pData->CurrentDisplayDevice->CurrentSettings = Current;
573 UpdateDisplay(hwndDlg, pData, TRUE);
574 return;
575 }
576 Current = Current->Blink;
577 }
578
579 /* Search bigger resolution compatible with current color depth */
580 Current = pData->CurrentDisplayDevice->CurrentSettings->Flink;
581 while (Current != NULL)
582 {
583 if (Current->dmBitsPerPel == dmNewBitsPerPel)
584 {
585 pData->CurrentDisplayDevice->CurrentSettings = Current;
586 UpdateDisplay(hwndDlg, pData, TRUE);
587 return;
588 }
589 Current = Current->Flink;
590 }
591
592 /* We shouldn't go there */
593}
#define index(s, c)
Definition: various.h:29
#define IDC_SETTINGS_BPP
Definition: resource.h:65
#define IDC_SETTINGS_SPECTRUM
Definition: resource.h:70
static VOID ShowColorSpectrum(IN HDC hDC, IN LPRECT client, IN DWORD BitsPerPel, IN PSETTINGS_DATA pData)
Definition: settings.c:465
GLuint index
Definition: glext.h:6031
#define DWORD
Definition: nt_native.h:44
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
static FILE * client
Definition: client.c:41
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define CB_GETITEMDATA
Definition: winuser.h:1949
HDC WINAPI GetDC(_In_opt_ HWND)
HWND WINAPI GetParent(_In_ HWND)
#define CB_GETCURSEL
Definition: winuser.h:1942
#define SendDlgItemMessage
Definition: winuser.h:5841

Referenced by SettingsPageProc().

◆ OnDisplayDeviceChanged()

static VOID OnDisplayDeviceChanged ( IN HWND  hwndDlg,
IN PSETTINGS_DATA  pData,
IN PDISPLAY_DEVICE_ENTRY  pDeviceEntry 
)
static

Definition at line 281 of file settings.c.

282{
283 PSETTINGS_ENTRY Current;
284 DWORD index;
285
286 pData->CurrentDisplayDevice = pDeviceEntry; /* Update variable */
287
288 /* Fill color depths combo box */
290 for (Current = pDeviceEntry->Settings; Current != NULL; Current = Current->Flink)
291 {
292 TCHAR Buffer[64];
293 if (LoadString(hApplet, (2900 + Current->dmBitsPerPel), Buffer, sizeof(Buffer) / sizeof(TCHAR)))
294 {
296 if (index == (DWORD)CB_ERR)
297 {
300 }
301 }
302 }
303
304 /* Fill device description */
305 SendDlgItemMessage(hwndDlg, IDC_SETTINGS_DEVICE, WM_SETTEXT, 0, (LPARAM)pDeviceEntry->DeviceDescription);
306
307 /* Fill resolutions slider */
309 SendDlgItemMessage(hwndDlg, IDC_SETTINGS_RESOLUTION, TBM_SETRANGE, TRUE, MAKELONG(0, pDeviceEntry->ResolutionsCount - 1));
310
311 UpdateDisplay(hwndDlg, pData, TRUE);
312}
Definition: bufpool.h:45
#define IDC_SETTINGS_RESOLUTION
Definition: resource.h:66
#define IDC_SETTINGS_DEVICE
Definition: resource.h:64
#define TBM_CLEARTICS
Definition: commctrl.h:2040
#define TBM_SETRANGE
Definition: commctrl.h:2037
#define MAKELONG(a, b)
Definition: typedefs.h:249
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define CB_SETITEMDATA
Definition: winuser.h:1965
#define CB_ERR
Definition: winuser.h:2434
#define CB_RESETCONTENT
Definition: winuser.h:1958
#define CB_FINDSTRINGEXACT
Definition: winuser.h:1939
#define WM_SETTEXT
Definition: winuser.h:1616
#define CB_ADDSTRING
Definition: winuser.h:1935

Referenced by SettingsOnInitDialog(), and SettingsPageProc().

◆ OnResolutionChanged()

static VOID OnResolutionChanged ( IN HWND  hwndDlg,
IN PSETTINGS_DATA  pData,
IN DWORD  NewPosition,
IN BOOL  bUpdateThumb 
)
static

Definition at line 596 of file settings.c.

598{
599 /* If new resolution is not compatible with color depth:
600 * 1) try to find the nearest bigger matching color depth
601 * 2) otherwise, get the nearest smaller color depth
602 */
603 PSETTINGS_ENTRY Current;
604 DWORD dmNewPelsHeight = pData->CurrentDisplayDevice->Resolutions[NewPosition].dmPelsHeight;
605 DWORD dmNewPelsWidth = pData->CurrentDisplayDevice->Resolutions[NewPosition].dmPelsWidth;
606 DWORD dmBitsPerPel;
607 DWORD dmDisplayFrequency;
608
609 /* Find if new parameters are valid */
610 Current = pData->CurrentDisplayDevice->CurrentSettings;
611 if (dmNewPelsHeight == Current->dmPelsHeight && dmNewPelsWidth == Current->dmPelsWidth)
612 {
613 /* No change */
614 return;
615 }
616
617 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
619
620 dmBitsPerPel = Current->dmBitsPerPel;
621 dmDisplayFrequency = Current->dmDisplayFrequency;
622
623 if (CompareSettings(Current, dmNewPelsWidth,
624 dmNewPelsHeight, dmBitsPerPel,
625 dmDisplayFrequency) < 0)
626 {
627 Current = Current->Blink;
628 while (Current != NULL)
629 {
630 if (Current->dmPelsHeight == dmNewPelsHeight
631 && Current->dmPelsWidth == dmNewPelsWidth
632 && Current->dmBitsPerPel == dmBitsPerPel)
633 {
634 pData->CurrentDisplayDevice->CurrentSettings = Current;
635 UpdateDisplay(hwndDlg, pData, bUpdateThumb);
636 return;
637 }
638 Current = Current->Blink;
639 }
640 }
641 else
642 {
643 Current = Current->Flink;
644 while (Current != NULL)
645 {
646 if (Current->dmPelsHeight == dmNewPelsHeight
647 && Current->dmPelsWidth == dmNewPelsWidth
648 && Current->dmBitsPerPel == dmBitsPerPel)
649 {
650 pData->CurrentDisplayDevice->CurrentSettings = Current;
651 UpdateDisplay(hwndDlg, pData, bUpdateThumb);
652 return;
653 }
654 Current = Current->Flink;
655 }
656 }
657
658 /* Search bigger color depth compatible with current resolution */
659 Current = pData->CurrentDisplayDevice->CurrentSettings->Flink;
660 while (Current != NULL)
661 {
662 if (dmNewPelsHeight == Current->dmPelsHeight && dmNewPelsWidth == Current->dmPelsWidth)
663 {
664 pData->CurrentDisplayDevice->CurrentSettings = Current;
665 UpdateDisplay(hwndDlg, pData, bUpdateThumb);
666 return;
667 }
668 Current = Current->Flink;
669 }
670
671 /* Search smaller color depth compatible with current resolution */
672 Current = pData->CurrentDisplayDevice->CurrentSettings->Blink;
673 while (Current != NULL)
674 {
675 if (dmNewPelsHeight == Current->dmPelsHeight && dmNewPelsWidth == Current->dmPelsWidth)
676 {
677 pData->CurrentDisplayDevice->CurrentSettings = Current;
678 UpdateDisplay(hwndDlg, pData, bUpdateThumb);
679 return;
680 }
681 Current = Current->Blink;
682 }
683
684 /* We shouldn't go there */
685}
#define IDC_RESOLUTION_PREVIEW
Definition: resource.h:35
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by SettingsPageProc().

◆ SettingsOnInitDialog()

static VOID SettingsOnInitDialog ( IN HWND  hwndDlg)
static

Definition at line 315 of file settings.c.

316{
318 DWORD Result = 0;
319 DWORD iDevNum = 0;
320 DWORD i;
321 DISPLAY_DEVICE displayDevice;
323
325 if (pData == NULL)
326 return;
327
329
330 /* Get video cards list */
331 pData->DisplayDeviceList = NULL;
332 displayDevice.cb = sizeof(displayDevice);
333 while (EnumDisplayDevices(NULL, iDevNum, &displayDevice, EDD_GET_DEVICE_INTERFACE_NAME))
334 {
335 if ((displayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) != 0)
336 {
337 if (AddDisplayDevice(pData, &displayDevice))
338 Result++;
339 }
340 iDevNum++;
341 }
342
343 if (Result == 0)
344 {
345 /* No adapter found */
351
352 /* Do not initialize the color spectrum bitmaps */
353 memset(pData->hSpectrumBitmaps, 0, sizeof(pData->hSpectrumBitmaps));
354 return;
355 }
356 else if (Result == 1)
357 {
359
360 /* Single video adapter */
361 OnDisplayDeviceChanged(hwndDlg, pData, pData->DisplayDeviceList);
362
365
366 monitors.Position.x = monitors.Position.y = 0;
367 monitors.Size.cx = pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth;
368 monitors.Size.cy = pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight;
369 monitors.Flags = 0;
370 SendDlgItemMessage(hwndDlg,
373 1,
374 (LPARAM)&monitors);
375 }
376 else /* FIXME: Incomplete! */
377 {
378 PMONSL_MONINFO pMonitors;
379 DWORD i;
380
381 OnDisplayDeviceChanged(hwndDlg, pData, pData->DisplayDeviceList);
382
384
385 pMonitors = (PMONSL_MONINFO)HeapAlloc(GetProcessHeap(), 0, sizeof(MONSL_MONINFO) * Result);
386 if (pMonitors)
387 {
388 DWORD hack = 1280;
389 for (i = 0; i < Result; i++)
390 {
391 pMonitors[i].Position.x = hack * i;
392 pMonitors[i].Position.y = 0;
393 pMonitors[i].Size.cx = pData->DisplayDeviceList->CurrentSettings->dmPelsWidth;
394 pMonitors[i].Size.cy = pData->DisplayDeviceList->CurrentSettings->dmPelsHeight;
395 pMonitors[i].Flags = 0;
396 }
397
398 SendDlgItemMessage(hwndDlg,
401 Result,
402 (LPARAM)pMonitors);
403
404 HeapFree(GetProcessHeap(), 0, pMonitors);
405 }
406 }
407
408 /* Initialize the color spectrum bitmaps */
409 for (i = 0; i < NUM_SPECTRUM_BITMAPS; i++)
410 {
412
413 if (pData->hSpectrumBitmaps[i] != NULL)
414 {
415 if (GetObjectW(pData->hSpectrumBitmaps[i], sizeof(BITMAP), &bitmap) != 0)
416 {
417 pData->cxSource[i] = bitmap.bmWidth;
418 pData->cySource[i] = bitmap.bmHeight;
419 }
420 else
421 {
422 pData->cxSource[i] = 0;
423 pData->cySource[i] = 0;
424 }
425 }
426 }
427}
#define IDC_SETTINGS_RESOLUTION_TEXT
Definition: resource.h:21
#define NUM_SPECTRUM_BITMAPS
Definition: desk.h:82
#define IDB_SPECTRUM_4
Definition: resource.h:73
#define IDC_SETTINGS_MONSEL
Definition: resource.h:69
#define IDC_SETTINGS_MONTEXT
Definition: resource.h:71
#define IDC_SETTINGS_ADVANCED
Definition: resource.h:68
static BOOL AddDisplayDevice(IN PSETTINGS_DATA pData, IN const DISPLAY_DEVICE *DisplayDevice)
Definition: settings.c:173
static VOID OnDisplayDeviceChanged(IN HWND hwndDlg, IN PSETTINGS_DATA pData, IN PDISPLAY_DEVICE_ENTRY pDeviceEntry)
Definition: settings.c:281
GLuint * monitors
Definition: glext.h:11118
struct _MONSL_MONINFO MONSL_MONINFO
struct _MONSL_MONINFO * PMONSL_MONINFO
#define MSLM_SETMONITORSINFO
Definition: monslctl.h:89
#define memset(x, y, z)
Definition: compat.h:39
Definition: bl.h:1331
DWORD StateFlags
Definition: wingdi.h:2812
DWORD Flags
Definition: monslctl.h:19
POINT Position
Definition: monslctl.h:17
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
Definition: uimain.c:89
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
Definition: wingdi.h:1396
#define SW_HIDE
Definition: winuser.h:767
#define IMAGE_BITMAP
Definition: winuser.h:211
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2172
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define LR_DEFAULTCOLOR
Definition: winuser.h:1086
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by SettingsPageProc().

◆ SettingsPageCallbackProc()

UINT CALLBACK SettingsPageCallbackProc ( HWND  hwnd,
UINT  uMsg,
LPPROPSHEETPAGE  ppsp 
)

Definition at line 689 of file settings.c.

690{
691 UINT Ret = 0;
692
693 switch (uMsg)
694 {
695 case PSPCB_CREATE:
697 break;
698
699 case PSPCB_RELEASE:
701 break;
702 }
703
704 return Ret;
705}
VOID UnregisterMonitorSelectionControl(IN HINSTANCE hInstance)
Definition: monslctl.c:1655
BOOL RegisterMonitorSelectionControl(IN HINSTANCE hInstance)
Definition: monslctl.c:1638
unsigned int UINT
Definition: ndis.h:50
#define PSPCB_CREATE
Definition: prsht.h:38
#define PSPCB_RELEASE
Definition: prsht.h:37

◆ SettingsPageProc()

INT_PTR CALLBACK SettingsPageProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)

Definition at line 879 of file settings.c.

880{
882
884
885 switch(uMsg)
886 {
887 case WM_INITDIALOG:
888 {
889 SettingsOnInitDialog(hwndDlg);
890 break;
891 }
892 case WM_DRAWITEM:
893 {
894 LPDRAWITEMSTRUCT lpDrawItem;
895 lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
896
897 switch (lpDrawItem->CtlID)
898 {
900 {
901 ShowResolutionPreview(lpDrawItem, pData);
902 break;
903 }
905 {
906 ShowColorSpectrum(lpDrawItem->hDC, &lpDrawItem->rcItem, pData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel, pData);
907 break;
908 }
909 }
910 break;
911 }
912 case WM_COMMAND:
913 {
914 DWORD controlId = LOWORD(wParam);
916
917 if (controlId == IDC_SETTINGS_ADVANCED && command == BN_CLICKED)
918 {
919 if (DisplayAdvancedSettings(hwndDlg, pData->CurrentDisplayDevice))
920 {
922 ZeroMemory(&devmode, sizeof(devmode));
923 devmode.dmSize = (WORD)sizeof(devmode);
924 if (EnumDisplaySettingsExW(pData->CurrentDisplayDevice->DeviceName, ENUM_CURRENT_SETTINGS, &devmode, 0))
925 {
926 pData->CurrentDisplayDevice->InitialSettings.dmPelsWidth = devmode.dmPelsWidth;
927 pData->CurrentDisplayDevice->InitialSettings.dmPelsHeight = devmode.dmPelsHeight;
928 pData->CurrentDisplayDevice->InitialSettings.dmBitsPerPel = devmode.dmBitsPerPel;
929 pData->CurrentDisplayDevice->InitialSettings.dmDisplayFrequency = devmode.dmDisplayFrequency;
930 pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth = pData->CurrentDisplayDevice->InitialSettings.dmPelsWidth;
931 pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight = pData->CurrentDisplayDevice->InitialSettings.dmPelsHeight;
932 pData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel = pData->CurrentDisplayDevice->InitialSettings.dmBitsPerPel;
933 pData->CurrentDisplayDevice->CurrentSettings->dmDisplayFrequency = pData->CurrentDisplayDevice->InitialSettings.dmDisplayFrequency;
934 UpdateDisplay(hwndDlg, pData, TRUE);
935 }
936 }
937 }
938 else if (controlId == IDC_SETTINGS_BPP && command == CBN_SELCHANGE)
939 OnBPPChanged(hwndDlg, pData);
940 break;
941 }
942 case WM_HSCROLL:
943 {
944 switch (LOWORD(wParam))
945 {
946 case TB_LINEUP:
947 case TB_LINEDOWN:
948 case TB_PAGEUP:
949 case TB_PAGEDOWN:
950 case TB_TOP:
951 case TB_BOTTOM:
952 case TB_ENDTRACK:
953 {
954 DWORD newPosition = (DWORD) SendDlgItemMessage(hwndDlg, IDC_SETTINGS_RESOLUTION, TBM_GETPOS, 0, 0);
955 OnResolutionChanged(hwndDlg, pData, newPosition, TRUE);
956 break;
957 }
958
959 case TB_THUMBTRACK:
961 break;
962 }
963 break;
964 }
965 case WM_NOTIFY:
966 {
967 LPNMHDR lpnm = (LPNMHDR)lParam;
968 if (lpnm->code == (UINT)PSN_APPLY)
969 {
970 if (pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth != pData->CurrentDisplayDevice->InitialSettings.dmPelsWidth
971 || pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight != pData->CurrentDisplayDevice->InitialSettings.dmPelsHeight
972 || pData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel != pData->CurrentDisplayDevice->InitialSettings.dmBitsPerPel)
973 {
974 /* Apply new settings */
975 ApplyDisplaySettings(hwndDlg, pData);
976 }
977 }
978 else if (lpnm->code == MSLN_MONITORCHANGED)
979 {
981 PDISPLAY_DEVICE_ENTRY Current = pData->DisplayDeviceList;
982 ULONG i;
983 for (i = 0; i < lpnmi->hdr.Index; i++)
984 Current = Current->Flink;
985 OnDisplayDeviceChanged(hwndDlg, pData, Current);
986 }
987 break;
988 }
989
990 case WM_CONTEXTMENU:
991 {
992 HWND hwndMonSel;
993 HMENU hPopup;
994 UINT uiCmd;
995 POINT pt, ptClient;
996 INT Index;
997
998 pt.x = (SHORT)LOWORD(lParam);
999 pt.y = (SHORT)HIWORD(lParam);
1000
1001 hwndMonSel = GetDlgItem(hwndDlg,
1003 if ((HWND)wParam == hwndMonSel)
1004 {
1005 if (pt.x == -1 && pt.y == -1)
1006 {
1007 RECT rcMon;
1008
1009 Index = (INT)SendMessage(hwndMonSel,
1011 0,
1012 0);
1013
1014 if (Index >= 0 &&
1015 (INT)SendMessage(hwndMonSel,
1017 Index,
1018 (LPARAM)&rcMon) > 0)
1019 {
1020 pt.x = rcMon.left + ((rcMon.right - rcMon.left) / 2);
1021 pt.y = rcMon.top + ((rcMon.bottom - rcMon.top) / 2);
1022 }
1023 else
1024 pt.x = pt.y = 0;
1025
1026 MapWindowPoints(hwndMonSel,
1027 NULL,
1028 &pt,
1029 1);
1030 }
1031 else
1032 {
1033 ptClient = pt;
1035 hwndMonSel,
1036 &ptClient,
1037 1);
1038
1039 Index = (INT)SendMessage(hwndMonSel,
1041 (WPARAM)&ptClient,
1042 0);
1043 }
1044
1045 if (Index >= 0)
1046 {
1047 hPopup = LoadPopupMenu(hApplet,
1049 if (hPopup != NULL)
1050 {
1051 /* FIXME: Enable/Disable menu items */
1052 EnableMenuItem(hPopup,
1055 EnableMenuItem(hPopup,
1058 EnableMenuItem(hPopup,
1061 EnableMenuItem(hPopup,
1064
1065 uiCmd = (UINT)TrackPopupMenu(hPopup,
1067 pt.x,
1068 pt.y,
1069 0,
1070 hwndDlg,
1071 NULL);
1072
1073 switch (uiCmd)
1074 {
1075 case ID_MENU_ATTACHED:
1076 case ID_MENU_PRIMARY:
1077 case ID_MENU_IDENTIFY:
1078 case ID_MENU_PROPERTIES:
1079 /* FIXME: Implement */
1080 break;
1081 }
1082
1083 DestroyMenu(hPopup);
1084 }
1085 }
1086 }
1087 break;
1088 }
1089
1090 case WM_DESTROY:
1091 {
1092 DWORD i;
1093 PDISPLAY_DEVICE_ENTRY Current = pData->DisplayDeviceList;
1094
1095 while (Current != NULL)
1096 {
1097 PDISPLAY_DEVICE_ENTRY Next = Current->Flink;
1098 PSETTINGS_ENTRY CurrentSettings = Current->Settings;
1099 while (CurrentSettings != NULL)
1100 {
1101 PSETTINGS_ENTRY NextSettings = CurrentSettings->Flink;
1102 HeapFree(GetProcessHeap(), 0, CurrentSettings);
1103 CurrentSettings = NextSettings;
1104 }
1105 HeapFree(GetProcessHeap(), 0, Current);
1106 Current = Next;
1107 }
1108
1109 for (i = 0; i < NUM_SPECTRUM_BITMAPS; i++)
1110 {
1111 if (pData->hSpectrumBitmaps[i])
1112 DeleteObject(pData->hSpectrumBitmaps[i]);
1113 }
1114
1116 }
1117 }
1118 return FALSE;
1119}
BOOL DisplayAdvancedSettings(HWND hWndParent, PDISPLAY_DEVICE_ENTRY DisplayDevice)
Definition: advmon.c:78
HMENU LoadPopupMenu(IN HINSTANCE hInstance, IN LPCWSTR lpMenuName)
Definition: util.cpp:33
LPARAM lParam
Definition: combotst.c:139
#define ID_MENU_PROPERTIES
Definition: resource.h:86
#define ID_MENU_IDENTIFY
Definition: resource.h:85
#define IDM_MONITOR_MENU
Definition: resource.h:82
#define ID_MENU_PRIMARY
Definition: resource.h:84
#define ID_MENU_ATTACHED
Definition: resource.h:83
static VOID OnResolutionChanged(IN HWND hwndDlg, IN PSETTINGS_DATA pData, IN DWORD NewPosition, IN BOOL bUpdateThumb)
Definition: settings.c:596
static VOID SettingsOnInitDialog(IN HWND hwndDlg)
Definition: settings.c:315
struct _SETTINGS_DATA * PSETTINGS_DATA
static VOID ApplyDisplaySettings(HWND hwndDlg, PSETTINGS_DATA pData)
Definition: settings.c:846
static VOID OnBPPChanged(IN HWND hwndDlg, IN PSETTINGS_DATA pData)
Definition: settings.c:497
static VOID ShowResolutionPreview(IN LPDRAWITEMSTRUCT draw, IN PSETTINGS_DATA pData)
Definition: settings.c:430
#define pt(x, y)
Definition: drawing.c:79
pKey DeleteObject()
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define MSLM_GETCURSEL
Definition: monslctl.h:139
struct _MONSL_MONNMMONITORCHANGING * PMONSL_MONNMMONITORCHANGING
#define MSLN_MONITORCHANGED
Definition: monslctl.h:66
#define MSLM_GETMONITORRECT
Definition: monslctl.h:212
#define MSLM_HITTEST
Definition: monslctl.h:120
short SHORT
Definition: pedump.c:59
#define INT
Definition: polytest.cpp:20
#define PSN_APPLY
Definition: prsht.h:117
#define TB_TOP
Definition: commctrl.h:2079
#define TB_ENDTRACK
Definition: commctrl.h:2081
#define TB_PAGEUP
Definition: commctrl.h:2075
#define TB_BOTTOM
Definition: commctrl.h:2080
#define TBM_GETPOS
Definition: commctrl.h:2031
#define TB_PAGEDOWN
Definition: commctrl.h:2076
#define TB_THUMBTRACK
Definition: commctrl.h:2078
#define TB_LINEUP
Definition: commctrl.h:2073
#define TB_LINEDOWN
Definition: commctrl.h:2074
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_NOTIFY
Definition: richedit.h:61
MONSL_MONNMHDR hdr
Definition: monslctl.h:41
UINT code
Definition: winuser.h:3158
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
#define HIWORD(l)
Definition: typedefs.h:247
_In_ WDFCOLLECTION _In_ ULONG Index
BOOL WINAPI EnumDisplaySettingsExW(LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode, DWORD dwFlags)
Definition: display.c:330
#define ZeroMemory
Definition: winbase.h:1712
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define MF_BYCOMMAND
Definition: winuser.h:202
#define WM_HSCROLL
Definition: winuser.h:1742
#define TPM_RIGHTBUTTON
Definition: winuser.h:2379
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define WM_DRAWITEM
Definition: winuser.h:1644
#define CBN_SELCHANGE
Definition: winuser.h:1978
struct tagNMHDR * LPNMHDR
#define SendMessage
Definition: winuser.h:5842
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define BN_CLICKED
Definition: winuser.h:1924
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define TPM_RETURNCMD
Definition: winuser.h:2386
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define MF_GRAYED
Definition: winuser.h:129
#define MF_DISABLED
Definition: winuser.h:130

◆ ShowColorSpectrum()

static VOID ShowColorSpectrum ( IN HDC  hDC,
IN LPRECT  client,
IN DWORD  BitsPerPel,
IN PSETTINGS_DATA  pData 
)
static

Definition at line 465 of file settings.c.

466{
467 HDC hdcMem;
468 INT iBitmap;
469
471
472 if (!hdcMem)
473 return;
474
475 switch(BitsPerPel)
476 {
477 case 4: iBitmap = 0; break;
478 case 8: iBitmap = 1; break;
479 default: iBitmap = 2;
480 }
481
482 if (SelectObject(hdcMem, pData->hSpectrumBitmaps[iBitmap]))
483 {
485 client->left, client->top,
486 client->right - client->left,
487 client->bottom - client->top,
488 hdcMem, 0, 0,
489 pData->cxSource[iBitmap],
490 pData->cySource[iBitmap], SRCCOPY);
491 }
492
494}
HDC hdcMem
Definition: welcome.c:104
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define SRCCOPY
Definition: wingdi.h:333

Referenced by OnBPPChanged(), and SettingsPageProc().

◆ ShowResolutionPreview()

static VOID ShowResolutionPreview ( IN LPDRAWITEMSTRUCT  draw,
IN PSETTINGS_DATA  pData 
)
static

Definition at line 430 of file settings.c.

431{
432 HBRUSH hBrush;
433 HDC hDC;
434 HGDIOBJ hOldObj;
435 RECT rcItem = {
440 };
441
442 hDC = CreateCompatibleDC(draw->hDC);
444
445 /* FIXME: Draw resolution preview bitmap inside monitor. */
447 FillRect(hDC, &rcItem, hBrush);
448 DeleteObject(hBrush);
449
450 GdiTransparentBlt(draw->hDC,
451 draw->rcItem.left, draw->rcItem.top,
452 draw->rcItem.right - draw->rcItem.left + 1,
453 draw->rcItem.bottom - draw->rcItem.top + 1,
454 hDC,
455 0, 0,
458
459 SelectObject(hDC, hOldObj);
460 DeleteDC(hDC);
461}
GLOBAL_DATA g_GlobalData
Definition: background.c:70
#define MONITOR_BOTTOM
Definition: desk.h:74
#define MONITOR_LEFT
Definition: desk.h:71
#define MONITOR_ALPHA
Definition: desk.h:79
#define MONITOR_TOP
Definition: desk.h:72
#define MONITOR_RIGHT
Definition: desk.h:73
LONG bmMonHeight
Definition: desk.h:164
LONG bmMonWidth
Definition: desk.h:163
COLORREF desktop_color
Definition: desk.h:159
HBITMAP hMonitorBitmap
Definition: desk.h:162
BOOL WINAPI GdiTransparentBlt(HDC hdcDst, int xDst, int yDst, int wDst, int hDst, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, UINT crTransparent)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)

Referenced by SettingsPageProc().

◆ SwitchDisplayMode()

BOOL SwitchDisplayMode ( HWND  hwndDlg,
PWSTR  DeviceName,
PSETTINGS_ENTRY  seInit,
PSETTINGS_ENTRY  seNew,
OUT PLONG  rc 
)

Definition at line 771 of file settings.c.

772{
773 TCHAR Message[1024], Title[256];
775
776 RtlZeroMemory(&devmode, sizeof(devmode));
777 devmode.dmSize = (WORD)sizeof(devmode);
783
784 *rc = ChangeDisplaySettingsEx(DeviceName,
785 &devmode,
786 NULL,
788 NULL);
789 switch (*rc)
790 {
792 break;
793
798 return FALSE;
799
801 default:
805 return FALSE;
806 }
807
809 {
810 return TRUE;
811 }
812 else
813 {
818
819 *rc = ChangeDisplaySettingsEx(DeviceName,
820 &devmode,
821 NULL,
823 NULL);
824 switch (*rc)
825 {
827 return FALSE;
828
833 return FALSE;
834
836 default:
840 return FALSE;
841 }
842 }
843}
#define IDS_DISPLAY_SETTINGS
Definition: resource.h:161
#define IDS_APPLY_NEEDS_RESTART
Definition: resource.h:164
#define IDD_CONFIRMSETTINGS
Definition: resource.h:19
#define IDS_APPLY_FAILED
Definition: resource.h:163
static INT_PTR CALLBACK ConfirmDlgProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: settings.c:708
static const WCHAR Title[]
Definition: oid.c:1259
static const WCHAR Message[]
Definition: register.c:74
DWORD dmFields
Definition: wingdi.h:1622
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define DM_DISPLAYFREQUENCY
Definition: wingdi.h:1272
#define DM_PELSWIDTH
Definition: wingdi.h:1269
#define DM_BITSPERPEL
Definition: wingdi.h:1268
#define DM_PELSHEIGHT
Definition: wingdi.h:1270
#define CDS_UPDATEREGISTRY
Definition: winuser.h:181
#define DISP_CHANGE_FAILED
Definition: winuser.h:194
#define MB_OK
Definition: winuser.h:789
#define MessageBox
Definition: winuser.h:5821
#define MB_ICONINFORMATION
Definition: winuser.h:801
#define MB_ICONSTOP
Definition: winuser.h:802
#define IDYES
Definition: winuser.h:834
#define DISP_CHANGE_RESTART
Definition: winuser.h:191
#define DialogBox
Definition: winuser.h:5760

Referenced by ApplyDisplaySettings(), and DisplaySaveSettings().

◆ UpdateDisplay()

static VOID UpdateDisplay ( IN HWND  hwndDlg,
PSETTINGS_DATA  pData,
IN BOOL  bUpdateThumb 
)
static

Definition at line 30 of file settings.c.

31{
32 TCHAR Buffer[64];
33 TCHAR Pixel[64];
35 HWND hwndMonSel;
37
38 LoadString(hApplet, IDS_PIXEL, Pixel, sizeof(Pixel) / sizeof(TCHAR));
39 _stprintf(Buffer, Pixel, pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth, pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight, Pixel);
41
42 for (index = 0; index < pData->CurrentDisplayDevice->ResolutionsCount; index++)
43 {
44 if (pData->CurrentDisplayDevice->Resolutions[index].dmPelsWidth == pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth &&
45 pData->CurrentDisplayDevice->Resolutions[index].dmPelsHeight == pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight)
46 {
47 if (bUpdateThumb)
49 break;
50 }
51 }
52 if (LoadString(hApplet, (2900 + pData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel), Buffer, sizeof(Buffer) / sizeof(TCHAR)))
54
55 hwndMonSel = GetDlgItem(hwndDlg, IDC_SETTINGS_MONSEL);
56 index = (INT)SendMessage(hwndMonSel, MSLM_GETCURSEL, 0, 0);
57 if (index != (DWORD)-1 && SendMessage(hwndMonSel, MSLM_GETMONITORINFO, index, (LPARAM)&info))
58 {
59 info.Size.cx = pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth;
60 info.Size.cy = pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight;
62 }
63}
#define IDS_PIXEL
Definition: resource.h:41
#define MSLM_GETMONITORINFO
Definition: monslctl.h:161
#define MSLM_SETMONITORINFO
Definition: monslctl.h:150
#define TBM_SETPOS
Definition: commctrl.h:2036
#define CB_SELECTSTRING
Definition: winuser.h:1959

Referenced by ApplyDisplaySettings(), OnBPPChanged(), OnDisplayDeviceChanged(), OnResolutionChanged(), and SettingsPageProc().