2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Display Control Panel
4 * FILE: lib/cpl/desk/settings.c
5 * PURPOSE: Settings property page
7 * PROGRAMMERS: Trevor McCort (lycan359@gmail.com)
8 * Hervé Poussineau (hpoussin@reactos.org)
13 /* As slider control can't contain user data, we have to keep an
14 * array of RESOLUTION_INFO to have our own associated data.
16 typedef struct _RESOLUTION_INFO
20 } RESOLUTION_INFO
, *PRESOLUTION_INFO
;
22 typedef struct _SETTINGS_ENTRY
24 struct _SETTINGS_ENTRY
*Blink
;
25 struct _SETTINGS_ENTRY
*Flink
;
29 } SETTINGS_ENTRY
, *PSETTINGS_ENTRY
;
31 typedef struct _DISPLAY_DEVICE_ENTRY
33 struct _DISPLAY_DEVICE_ENTRY
*Flink
;
34 LPTSTR DeviceDescription
;
36 PSETTINGS_ENTRY Settings
; /* sorted by increasing dmPelsHeight, BPP */
38 PRESOLUTION_INFO Resolutions
;
39 DWORD ResolutionsCount
;
40 PSETTINGS_ENTRY CurrentSettings
; /* Points into Settings list */
41 SETTINGS_ENTRY InitialSettings
;
42 } DISPLAY_DEVICE_ENTRY
, *PDISPLAY_DEVICE_ENTRY
;
44 typedef struct _GLOBAL_DATA
46 PDISPLAY_DEVICE_ENTRY DisplayDeviceList
;
47 PDISPLAY_DEVICE_ENTRY CurrentDisplayDevice
;
51 } GLOBAL_DATA
, *PGLOBAL_DATA
;
54 UpdateDisplay(IN HWND hwndDlg
, PGLOBAL_DATA pGlobalData
, IN BOOL bUpdateThumb
)
60 LoadString(hApplet
, IDS_PIXEL
, Pixel
, sizeof(Pixel
) / sizeof(TCHAR
));
61 _stprintf(Buffer
, Pixel
, pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsWidth
, pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsHeight
, Pixel
);
62 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_RESOLUTION_TEXT
, WM_SETTEXT
, 0, (LPARAM
)Buffer
);
64 for (index
= 0; index
< pGlobalData
->CurrentDisplayDevice
->ResolutionsCount
; index
++)
67 if (pGlobalData
->CurrentDisplayDevice
->Resolutions
[index
].dmPelsWidth
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsWidth
&&
68 pGlobalData
->CurrentDisplayDevice
->Resolutions
[index
].dmPelsHeight
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsHeight
)
71 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_RESOLUTION
, TBM_SETPOS
, TRUE
, index
);
75 if (LoadString(hApplet
, (2900 + pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmBitsPerPel
), Buffer
, sizeof(Buffer
) / sizeof(TCHAR
)))
76 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, CB_SELECTSTRING
, (WPARAM
)-1, (LPARAM
)Buffer
);
79 static PSETTINGS_ENTRY
80 GetPossibleSettings(IN LPTSTR DeviceName
, OUT DWORD
* pSettingsCount
, OUT PSETTINGS_ENTRY
* CurrentSettings
)
86 PSETTINGS_ENTRY Settings
= NULL
;
88 PSETTINGS_ENTRY Current
;
89 DWORD bpp
, xres
, yres
, checkbpp
;
92 /* Get current settings */
93 *CurrentSettings
= NULL
;
94 hDC
= CreateIC(NULL
, DeviceName
, NULL
, NULL
);
95 bpp
= GetDeviceCaps(hDC
, PLANES
);
96 bpp
*= GetDeviceCaps(hDC
, BITSPIXEL
);
97 xres
= GetDeviceCaps(hDC
, HORZRES
);
98 yres
= GetDeviceCaps(hDC
, VERTRES
);
101 /* List all settings */
102 devmode
.dmSize
= (WORD
)sizeof(DEVMODE
);
103 devmode
.dmDriverExtra
= 0;
104 while (EnumDisplaySettingsEx(DeviceName
, iMode
, &devmode
, dwFlags
))
106 if (devmode
.dmBitsPerPel
==8 || devmode
.dmBitsPerPel
==16 || devmode
.dmBitsPerPel
==24 || devmode
.dmBitsPerPel
==32) checkbpp
=1;
109 if (devmode
.dmPelsWidth
< 640 ||
110 devmode
.dmPelsHeight
< 480 || checkbpp
== 0)
116 Current
= HeapAlloc(GetProcessHeap(), 0, sizeof(SETTINGS_ENTRY
));
119 /* Sort resolutions by increasing height, and BPP */
120 PSETTINGS_ENTRY Previous
= NULL
;
121 PSETTINGS_ENTRY Next
= Settings
;
122 Current
->dmPelsWidth
= devmode
.dmPelsWidth
;
123 Current
->dmPelsHeight
= devmode
.dmPelsHeight
;
124 Current
->dmBitsPerPel
= devmode
.dmBitsPerPel
;
125 while (Next
!= NULL
&& (
126 Next
->dmPelsHeight
< Current
->dmPelsHeight
||
127 (Next
->dmPelsHeight
== Current
->dmPelsHeight
&& Next
->dmBitsPerPel
< Current
->dmBitsPerPel
) ||
128 (Next
->dmPelsHeight
== Current
->dmPelsHeight
&&
129 Next
->dmBitsPerPel
== Current
->dmBitsPerPel
&&
130 Next
->dmPelsWidth
< Current
->dmPelsWidth
)))
135 Current
->Blink
= Previous
;
136 Current
->Flink
= Next
;
137 if (Previous
== NULL
)
140 Previous
->Flink
= Current
;
142 Next
->Blink
= Current
;
143 if (devmode
.dmPelsWidth
== xres
&& devmode
.dmPelsHeight
== yres
&& devmode
.dmBitsPerPel
== bpp
)
145 *CurrentSettings
= Current
;
152 *pSettingsCount
= NbSettings
;
157 AddDisplayDevice(IN PGLOBAL_DATA pGlobalData
, IN LPTSTR Description
, IN LPTSTR DeviceName
)
159 PDISPLAY_DEVICE_ENTRY newEntry
= NULL
;
160 LPTSTR description
= NULL
;
162 DWORD descriptionSize
;
164 PSETTINGS_ENTRY Current
;
165 DWORD ResolutionsCount
= 1;
168 newEntry
= HeapAlloc(GetProcessHeap(), 0, sizeof(DISPLAY_DEVICE_ENTRY
));
169 memset(newEntry
, 0, sizeof(DISPLAY_DEVICE_ENTRY
));
170 if (!newEntry
) goto ByeBye
;
172 newEntry
->Settings
= GetPossibleSettings(DeviceName
, &newEntry
->SettingsCount
, &newEntry
->CurrentSettings
);
173 if (!newEntry
->Settings
) goto ByeBye
;
175 newEntry
->InitialSettings
.dmPelsWidth
= newEntry
->CurrentSettings
->dmPelsWidth
;
176 newEntry
->InitialSettings
.dmPelsHeight
= newEntry
->CurrentSettings
->dmPelsHeight
;
177 newEntry
->InitialSettings
.dmBitsPerPel
= newEntry
->CurrentSettings
->dmBitsPerPel
;
179 /* Count different resolutions */
180 for (Current
= newEntry
->Settings
; Current
!= NULL
; Current
= Current
->Flink
)
182 if (Current
->Flink
!= NULL
&&
183 ((Current
->dmPelsWidth
!= Current
->Flink
->dmPelsWidth
) ||
184 (Current
->dmPelsHeight
!= Current
->Flink
->dmPelsHeight
)))
190 newEntry
->Resolutions
= HeapAlloc(GetProcessHeap(), 0, ResolutionsCount
* sizeof(RESOLUTION_INFO
));
191 if (!newEntry
->Resolutions
) goto ByeBye
;
192 newEntry
->ResolutionsCount
= ResolutionsCount
;
193 /* Fill resolutions infos */
194 for (Current
= newEntry
->Settings
, i
= 0; Current
!= NULL
; Current
= Current
->Flink
)
195 if (Current
->Flink
== NULL
|| (Current
->Flink
!= NULL
&&
196 ((Current
->dmPelsWidth
!= Current
->Flink
->dmPelsWidth
) || (Current
->dmPelsHeight
!= Current
->Flink
->dmPelsHeight
))))
198 newEntry
->Resolutions
[i
].dmPelsWidth
= Current
->dmPelsWidth
;
199 newEntry
->Resolutions
[i
].dmPelsHeight
= Current
->dmPelsHeight
;
203 descriptionSize
= (_tcslen(Description
) + 1) * sizeof(TCHAR
);
204 description
= HeapAlloc(GetProcessHeap(), 0, descriptionSize
);
205 if (!description
) goto ByeBye
;
207 nameSize
= (_tcslen(DeviceName
) + 1) * sizeof(TCHAR
);
208 name
= HeapAlloc(GetProcessHeap(), 0, nameSize
);
209 if (!name
) goto ByeBye
;
211 memcpy(description
, Description
, descriptionSize
);
212 memcpy(name
, DeviceName
, nameSize
);
213 newEntry
->DeviceDescription
= description
;
214 newEntry
->DeviceName
= name
;
215 newEntry
->Flink
= pGlobalData
->DisplayDeviceList
;
216 pGlobalData
->DisplayDeviceList
= newEntry
;
220 if (newEntry
!= NULL
)
222 if (newEntry
->Settings
!= NULL
)
224 Current
= newEntry
->Settings
;
225 while (Current
!= NULL
)
227 PSETTINGS_ENTRY Next
= Current
->Flink
;
228 HeapFree(GetProcessHeap(), 0, Current
);
232 if (newEntry
->Resolutions
!= NULL
)
233 HeapFree(GetProcessHeap(), 0, newEntry
->Resolutions
);
234 HeapFree(GetProcessHeap(), 0, newEntry
);
236 if (description
!= NULL
)
237 HeapFree(GetProcessHeap(), 0, description
);
239 HeapFree(GetProcessHeap(), 0, name
);
244 OnDisplayDeviceChanged(IN HWND hwndDlg
, IN PGLOBAL_DATA pGlobalData
, IN PDISPLAY_DEVICE_ENTRY pDeviceEntry
)
246 PSETTINGS_ENTRY Current
;
249 pGlobalData
->CurrentDisplayDevice
= pDeviceEntry
; /* Update global variable */
251 /* Fill color depths combo box */
252 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, CB_RESETCONTENT
, 0, 0);
253 for (Current
= pDeviceEntry
->Settings
; Current
!= NULL
; Current
= Current
->Flink
)
256 if (LoadString(hApplet
, (2900 + Current
->dmBitsPerPel
), Buffer
, sizeof(Buffer
) / sizeof(TCHAR
)))
258 index
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, CB_FINDSTRINGEXACT
, (WPARAM
)-1, (LPARAM
)Buffer
);
259 if (index
== (DWORD
)CB_ERR
)
261 index
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, CB_ADDSTRING
, 0, (LPARAM
)Buffer
);
262 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, CB_SETITEMDATA
, index
, Current
->dmBitsPerPel
);
267 /* Fill resolutions slider */
268 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_RESOLUTION
, TBM_CLEARTICS
, TRUE
, 0);
269 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_RESOLUTION
, TBM_SETRANGE
, TRUE
, MAKELONG(0, pDeviceEntry
->ResolutionsCount
- 1));
271 UpdateDisplay(hwndDlg
, pGlobalData
, TRUE
);
275 OnInitDialog(IN HWND hwndDlg
)
279 DISPLAY_DEVICE displayDevice
;
281 PGLOBAL_DATA pGlobalData
;
283 pGlobalData
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(GLOBAL_DATA
));
284 if (pGlobalData
== NULL
)
287 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pGlobalData
);
289 /* Get video cards list */
290 displayDevice
.cb
= (DWORD
)sizeof(DISPLAY_DEVICE
);
291 while (EnumDisplayDevices(NULL
, iDevNum
, &displayDevice
, 0))
293 if ((displayDevice
.StateFlags
& DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
) != 0)
295 if (AddDisplayDevice(pGlobalData
, displayDevice
.DeviceString
, displayDevice
.DeviceName
))
302 /* No adapter found */
303 EnableWindow(GetDlgItem(hwndDlg
, IDC_SETTINGS_BPP
), FALSE
);
304 EnableWindow(GetDlgItem(hwndDlg
, IDC_SETTINGS_RESOLUTION
), FALSE
);
305 EnableWindow(GetDlgItem(hwndDlg
, IDC_SETTINGS_RESOLUTION_TEXT
), FALSE
);
306 EnableWindow(GetDlgItem(hwndDlg
, IDC_SETTINGS_ADVANCED
), FALSE
);
308 else if (Result
== 1)
310 /* Single video adapter */
311 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_DEVICE
, WM_SETTEXT
, 0, (LPARAM
)pGlobalData
->DisplayDeviceList
->DeviceDescription
);
312 OnDisplayDeviceChanged(hwndDlg
, pGlobalData
, pGlobalData
->DisplayDeviceList
);
316 /* FIXME: multi video adapter */
317 /* FIXME: choose selected adapter being the primary one */
320 pGlobalData
->hBitmap
= LoadImage(hApplet
, MAKEINTRESOURCE(IDC_MONITOR
), IMAGE_BITMAP
, 0, 0, LR_LOADTRANSPARENT
);
321 if (pGlobalData
->hBitmap
!= NULL
)
323 GetObject(pGlobalData
->hBitmap
, sizeof(BITMAP
), &bitmap
);
325 pGlobalData
->cxSource
= bitmap
.bmWidth
;
326 pGlobalData
->cySource
= bitmap
.bmHeight
;
331 OnBPPChanged(IN HWND hwndDlg
, IN PGLOBAL_DATA pGlobalData
)
333 /* if new BPP is not compatible with resolution:
334 * 1) try to find the nearest smaller matching resolution
335 * 2) otherwise, get the nearest bigger resolution
337 PSETTINGS_ENTRY Current
;
338 DWORD dmNewBitsPerPel
;
342 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, WM_GETTEXT
, (WPARAM
)(sizeof(Buffer
) / sizeof(TCHAR
)), (LPARAM
)Buffer
);
343 index
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, CB_FINDSTRINGEXACT
, (WPARAM
)-1, (LPARAM
)Buffer
);
344 dmNewBitsPerPel
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, CB_GETITEMDATA
, index
, 0);
346 /* find if new parameters are valid */
347 Current
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
;
348 if (dmNewBitsPerPel
== Current
->dmBitsPerPel
)
354 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
356 if (dmNewBitsPerPel
< Current
->dmBitsPerPel
)
358 Current
= Current
->Blink
;
359 while (Current
!= NULL
)
361 if (Current
->dmBitsPerPel
== dmNewBitsPerPel
362 && Current
->dmPelsHeight
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsHeight
363 && Current
->dmPelsWidth
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsWidth
)
365 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
366 UpdateDisplay(hwndDlg
, pGlobalData
, TRUE
);
369 Current
= Current
->Blink
;
374 Current
= Current
->Flink
;
375 while (Current
!= NULL
)
377 if (Current
->dmBitsPerPel
== dmNewBitsPerPel
378 && Current
->dmPelsHeight
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsHeight
379 && Current
->dmPelsWidth
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsWidth
)
381 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
382 UpdateDisplay(hwndDlg
, pGlobalData
, TRUE
);
385 Current
= Current
->Flink
;
389 /* search smaller resolution compatible with current color depth */
390 Current
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->Blink
;
391 while (Current
!= NULL
)
393 if (Current
->dmBitsPerPel
== dmNewBitsPerPel
)
395 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
396 UpdateDisplay(hwndDlg
, pGlobalData
, TRUE
);
399 Current
= Current
->Blink
;
402 /* search bigger resolution compatible with current color depth */
403 Current
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->Flink
;
404 while (Current
!= NULL
)
406 if (Current
->dmBitsPerPel
== dmNewBitsPerPel
)
408 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
409 UpdateDisplay(hwndDlg
, pGlobalData
, TRUE
);
412 Current
= Current
->Flink
;
415 /* we shouldn't go there */
419 OnResolutionChanged(IN HWND hwndDlg
, IN PGLOBAL_DATA pGlobalData
, IN DWORD NewPosition
,
420 IN BOOL bUpdateThumb
)
422 /* if new resolution is not compatible with color depth:
423 * 1) try to find the nearest bigger matching color depth
424 * 2) otherwise, get the nearest smaller color depth
426 PSETTINGS_ENTRY Current
;
427 DWORD dmNewPelsHeight
= pGlobalData
->CurrentDisplayDevice
->Resolutions
[NewPosition
].dmPelsHeight
;
428 DWORD dmNewPelsWidth
= pGlobalData
->CurrentDisplayDevice
->Resolutions
[NewPosition
].dmPelsWidth
;
430 /* find if new parameters are valid */
431 Current
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
;
432 if (dmNewPelsHeight
== Current
->dmPelsHeight
&& dmNewPelsWidth
== Current
->dmPelsWidth
)
438 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
440 if (dmNewPelsHeight
< Current
->dmPelsHeight
)
442 Current
= Current
->Blink
;
443 while (Current
!= NULL
)
445 if (Current
->dmPelsHeight
== dmNewPelsHeight
446 && Current
->dmPelsWidth
== dmNewPelsWidth
447 && Current
->dmBitsPerPel
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmBitsPerPel
)
449 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
450 UpdateDisplay(hwndDlg
, pGlobalData
, bUpdateThumb
);
453 Current
= Current
->Blink
;
458 Current
= Current
->Flink
;
459 while (Current
!= NULL
)
461 if (Current
->dmPelsHeight
== dmNewPelsHeight
462 && Current
->dmPelsWidth
== dmNewPelsWidth
463 && Current
->dmBitsPerPel
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmBitsPerPel
)
465 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
466 UpdateDisplay(hwndDlg
, pGlobalData
, bUpdateThumb
);
469 Current
= Current
->Flink
;
473 /* search bigger color depth compatible with current resolution */
474 Current
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->Flink
;
475 while (Current
!= NULL
)
477 if (dmNewPelsHeight
== Current
->dmPelsHeight
&& dmNewPelsWidth
== Current
->dmPelsWidth
)
479 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
480 UpdateDisplay(hwndDlg
, pGlobalData
, bUpdateThumb
);
483 Current
= Current
->Flink
;
486 /* search smaller color depth compatible with current resolution */
487 Current
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->Blink
;
488 while (Current
!= NULL
)
490 if (dmNewPelsHeight
== Current
->dmPelsHeight
&& dmNewPelsWidth
== Current
->dmPelsWidth
)
492 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
493 UpdateDisplay(hwndDlg
, pGlobalData
, bUpdateThumb
);
496 Current
= Current
->Blink
;
499 /* we shouldn't go there */
505 MessageBox(NULL
, TEXT("That button doesn't do anything yet"), TEXT("Whoops"), MB_OK
);
508 /* Property page dialog callback */
510 SettingsPageProc(IN HWND hwndDlg
, IN UINT uMsg
, IN WPARAM wParam
, IN LPARAM lParam
)
512 PGLOBAL_DATA pGlobalData
;
514 pGlobalData
= (PGLOBAL_DATA
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
519 OnInitDialog(hwndDlg
);
523 DWORD controlId
= LOWORD(wParam
);
524 DWORD command
= HIWORD(wParam
);
526 if (controlId
== IDC_SETTINGS_ADVANCED
&& command
== BN_CLICKED
)
528 else if (controlId
== IDC_SETTINGS_BPP
&& command
== CBN_SELCHANGE
)
529 OnBPPChanged(hwndDlg
, pGlobalData
);
534 switch (LOWORD(wParam
))
544 DWORD newPosition
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_RESOLUTION
, TBM_GETPOS
, 0, 0);
545 OnResolutionChanged(hwndDlg
, pGlobalData
, newPosition
, TRUE
);
550 OnResolutionChanged(hwndDlg
, pGlobalData
, HIWORD(wParam
), FALSE
);
557 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
558 if (lpnm
->code
== (UINT
)PSN_APPLY
)
560 if (pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsWidth
!= pGlobalData
->CurrentDisplayDevice
->InitialSettings
.dmPelsWidth
561 || pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsHeight
!= pGlobalData
->CurrentDisplayDevice
->InitialSettings
.dmPelsHeight
562 || pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmBitsPerPel
!= pGlobalData
->CurrentDisplayDevice
->InitialSettings
.dmBitsPerPel
)
564 /* FIXME: Need to test changes */
565 /* Apply new settings */
568 RtlZeroMemory(&devmode
, sizeof(DEVMODE
));
569 devmode
.dmSize
= (WORD
)sizeof(DEVMODE
);
570 devmode
.dmPelsWidth
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsWidth
;
571 devmode
.dmPelsHeight
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsHeight
;
572 devmode
.dmBitsPerPel
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmBitsPerPel
;
573 devmode
.dmFields
= DM_PELSWIDTH
| DM_PELSHEIGHT
| DM_BITSPERPEL
;
574 rc
= ChangeDisplaySettingsEx(
575 pGlobalData
->CurrentDisplayDevice
->DeviceName
,
582 case DISP_CHANGE_SUCCESSFUL
:
583 pGlobalData
->CurrentDisplayDevice
->InitialSettings
.dmPelsWidth
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsWidth
;
584 pGlobalData
->CurrentDisplayDevice
->InitialSettings
.dmPelsHeight
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsHeight
;
585 pGlobalData
->CurrentDisplayDevice
->InitialSettings
.dmBitsPerPel
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmBitsPerPel
;
587 case DISP_CHANGE_FAILED
:
588 MessageBox(NULL
, TEXT("Failed to apply new settings..."), TEXT("Display settings"), MB_OK
| MB_ICONSTOP
);
590 case DISP_CHANGE_RESTART
:
591 MessageBox(NULL
, TEXT("You need to restart your computer to apply changes."), TEXT("Display settings"), MB_OK
| MB_ICONINFORMATION
);
594 MessageBox(NULL
, TEXT("Unknown error when applying new settings..."), TEXT("Display settings"), MB_OK
| MB_ICONSTOP
);
607 hdc
= BeginPaint(hwndDlg
, &ps
);
609 hdcMem
= CreateCompatibleDC(hdc
);
610 SelectObject(hdcMem
, pGlobalData
->hBitmap
);
612 TransparentBlt(hdc, 98, 0,
613 pGlobalData->cxSource,
614 pGlobalData->cySource, hdcMem, 0, 0,
615 pGlobalData->cxSource,
616 pGlobalData->cySource, 0xFF80FF);
619 EndPaint(hwndDlg
, &ps
);
626 PDISPLAY_DEVICE_ENTRY Current
= pGlobalData
->DisplayDeviceList
;
627 while (Current
!= NULL
)
629 PDISPLAY_DEVICE_ENTRY Next
= Current
->Flink
;
630 PSETTINGS_ENTRY CurrentSettings
= Current
->Settings
;
631 while (CurrentSettings
!= NULL
)
633 PSETTINGS_ENTRY NextSettings
= CurrentSettings
->Flink
;
634 HeapFree(GetProcessHeap(), 0, CurrentSettings
);
635 CurrentSettings
= NextSettings
;
637 HeapFree(GetProcessHeap(), 0, Current
);
641 DeleteObject(pGlobalData
->hBitmap
);
643 HeapFree(GetProcessHeap(), 0, pGlobalData
);