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
;
91 /* Get current settings */
92 *CurrentSettings
= NULL
;
93 hDC
= CreateIC(NULL
, DeviceName
, NULL
, NULL
);
94 bpp
= GetDeviceCaps(hDC
, PLANES
);
95 bpp
*= GetDeviceCaps(hDC
, BITSPIXEL
);
96 xres
= GetDeviceCaps(hDC
, HORZRES
);
97 yres
= GetDeviceCaps(hDC
, VERTRES
);
100 /* List all settings */
101 devmode
.dmSize
= (WORD
)sizeof(DEVMODE
);
102 devmode
.dmDriverExtra
= 0;
103 while (EnumDisplaySettingsEx(DeviceName
, iMode
, &devmode
, dwFlags
))
105 if (devmode
.dmBitsPerPel
==8 || devmode
.dmBitsPerPel
==16 || devmode
.dmBitsPerPel
==24 || devmode
.dmBitsPerPel
==32) checkbpp
=1;
108 if (devmode
.dmPelsWidth
< 640 ||
109 devmode
.dmPelsHeight
< 480 || checkbpp
== 0)
115 Current
= HeapAlloc(GetProcessHeap(), 0, sizeof(SETTINGS_ENTRY
));
118 /* Sort resolutions by increasing height, and BPP */
119 PSETTINGS_ENTRY Previous
= NULL
;
120 PSETTINGS_ENTRY Next
= Settings
;
121 Current
->dmPelsWidth
= devmode
.dmPelsWidth
;
122 Current
->dmPelsHeight
= devmode
.dmPelsHeight
;
123 Current
->dmBitsPerPel
= devmode
.dmBitsPerPel
;
124 while (Next
!= NULL
&& (
125 Next
->dmPelsHeight
< Current
->dmPelsHeight
||
126 (Next
->dmPelsHeight
== Current
->dmPelsHeight
&& Next
->dmBitsPerPel
< Current
->dmBitsPerPel
) ||
127 (Next
->dmPelsHeight
== Current
->dmPelsHeight
&&
128 Next
->dmBitsPerPel
== Current
->dmBitsPerPel
&&
129 Next
->dmPelsWidth
< Current
->dmPelsWidth
)))
134 Current
->Blink
= Previous
;
135 Current
->Flink
= Next
;
136 if (Previous
== NULL
)
139 Previous
->Flink
= Current
;
141 Next
->Blink
= Current
;
142 if (devmode
.dmPelsWidth
== xres
&& devmode
.dmPelsHeight
== yres
&& devmode
.dmBitsPerPel
== bpp
)
144 *CurrentSettings
= Current
;
151 *pSettingsCount
= NbSettings
;
156 AddDisplayDevice(IN PGLOBAL_DATA pGlobalData
, IN LPTSTR Description
, IN LPTSTR DeviceName
)
158 PDISPLAY_DEVICE_ENTRY newEntry
= NULL
;
159 LPTSTR description
= NULL
;
161 DWORD descriptionSize
;
163 PSETTINGS_ENTRY Current
;
164 DWORD ResolutionsCount
= 1;
167 newEntry
= HeapAlloc(GetProcessHeap(), 0, sizeof(DISPLAY_DEVICE_ENTRY
));
168 memset(newEntry
, 0, sizeof(DISPLAY_DEVICE_ENTRY
));
169 if (!newEntry
) goto ByeBye
;
171 newEntry
->Settings
= GetPossibleSettings(DeviceName
, &newEntry
->SettingsCount
, &newEntry
->CurrentSettings
);
172 if (!newEntry
->Settings
) goto ByeBye
;
174 newEntry
->InitialSettings
.dmPelsWidth
= newEntry
->CurrentSettings
->dmPelsWidth
;
175 newEntry
->InitialSettings
.dmPelsHeight
= newEntry
->CurrentSettings
->dmPelsHeight
;
176 newEntry
->InitialSettings
.dmBitsPerPel
= newEntry
->CurrentSettings
->dmBitsPerPel
;
178 /* Count different resolutions */
179 for (Current
= newEntry
->Settings
; Current
!= NULL
; Current
= Current
->Flink
)
180 if (Current
->Flink
!= NULL
&&
181 ((Current
->dmPelsWidth
!= Current
->Flink
->dmPelsWidth
) || (Current
->dmPelsHeight
!= Current
->Flink
->dmPelsHeight
)))
183 newEntry
->Resolutions
= HeapAlloc(GetProcessHeap(), 0, ResolutionsCount
* sizeof(RESOLUTION_INFO
));
184 if (!newEntry
->Resolutions
) goto ByeBye
;
185 newEntry
->ResolutionsCount
= ResolutionsCount
;
186 /* Fill resolutions infos */
187 for (Current
= newEntry
->Settings
, i
= 0; Current
!= NULL
; Current
= Current
->Flink
)
188 if (Current
->Flink
== NULL
|| (Current
->Flink
!= NULL
&&
189 ((Current
->dmPelsWidth
!= Current
->Flink
->dmPelsWidth
) || (Current
->dmPelsHeight
!= Current
->Flink
->dmPelsHeight
))))
191 newEntry
->Resolutions
[i
].dmPelsWidth
= Current
->dmPelsWidth
;
192 newEntry
->Resolutions
[i
].dmPelsHeight
= Current
->dmPelsHeight
;
196 descriptionSize
= (_tcslen(Description
) + 1) * sizeof(TCHAR
);
197 description
= HeapAlloc(GetProcessHeap(), 0, descriptionSize
);
198 if (!description
) goto ByeBye
;
200 nameSize
= (_tcslen(DeviceName
) + 1) * sizeof(TCHAR
);
201 name
= HeapAlloc(GetProcessHeap(), 0, nameSize
);
202 if (!name
) goto ByeBye
;
204 memcpy(description
, Description
, descriptionSize
);
205 memcpy(name
, DeviceName
, nameSize
);
206 newEntry
->DeviceDescription
= description
;
207 newEntry
->DeviceName
= name
;
208 newEntry
->Flink
= pGlobalData
->DisplayDeviceList
;
209 pGlobalData
->DisplayDeviceList
= newEntry
;
213 if (newEntry
!= NULL
)
215 if (newEntry
->Settings
!= NULL
)
217 Current
= newEntry
->Settings
;
218 while (Current
!= NULL
)
220 PSETTINGS_ENTRY Next
= Current
->Flink
;
221 HeapFree(GetProcessHeap(), 0, Current
);
225 if (newEntry
->Resolutions
!= NULL
)
226 HeapFree(GetProcessHeap(), 0, newEntry
->Resolutions
);
227 HeapFree(GetProcessHeap(), 0, newEntry
);
229 if (description
!= NULL
)
230 HeapFree(GetProcessHeap(), 0, description
);
232 HeapFree(GetProcessHeap(), 0, name
);
237 OnDisplayDeviceChanged(IN HWND hwndDlg
, IN PGLOBAL_DATA pGlobalData
, IN PDISPLAY_DEVICE_ENTRY pDeviceEntry
)
239 PSETTINGS_ENTRY Current
;
242 pGlobalData
->CurrentDisplayDevice
= pDeviceEntry
; /* Update global variable */
244 /* Fill color depths combo box */
245 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, CB_RESETCONTENT
, 0, 0);
246 for (Current
= pDeviceEntry
->Settings
; Current
!= NULL
; Current
= Current
->Flink
)
249 if (LoadString(hApplet
, (2900 + Current
->dmBitsPerPel
), Buffer
, sizeof(Buffer
) / sizeof(TCHAR
)))
251 index
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, CB_FINDSTRINGEXACT
, (WPARAM
)-1, (LPARAM
)Buffer
);
252 if (index
== (DWORD
)CB_ERR
)
254 index
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, CB_ADDSTRING
, 0, (LPARAM
)Buffer
);
255 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, CB_SETITEMDATA
, index
, Current
->dmBitsPerPel
);
260 /* Fill resolutions slider */
261 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_RESOLUTION
, TBM_CLEARTICS
, TRUE
, 0);
262 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_RESOLUTION
, TBM_SETRANGE
, TRUE
, MAKELONG(0, pDeviceEntry
->ResolutionsCount
- 1));
264 UpdateDisplay(hwndDlg
, pGlobalData
, TRUE
);
268 OnInitDialog(IN HWND hwndDlg
)
272 DISPLAY_DEVICE displayDevice
;
274 PGLOBAL_DATA pGlobalData
;
276 pGlobalData
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(GLOBAL_DATA
));
277 if (pGlobalData
== NULL
)
280 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pGlobalData
);
282 /* Get video cards list */
283 displayDevice
.cb
= (DWORD
)sizeof(DISPLAY_DEVICE
);
284 while (EnumDisplayDevices(NULL
, iDevNum
, &displayDevice
, 0))
286 if ((displayDevice
.StateFlags
& DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
) != 0)
288 if (AddDisplayDevice(pGlobalData
, displayDevice
.DeviceString
, displayDevice
.DeviceName
))
295 /* No adapter found */
296 EnableWindow(GetDlgItem(hwndDlg
, IDC_SETTINGS_BPP
), FALSE
);
297 EnableWindow(GetDlgItem(hwndDlg
, IDC_SETTINGS_RESOLUTION
), FALSE
);
298 EnableWindow(GetDlgItem(hwndDlg
, IDC_SETTINGS_RESOLUTION_TEXT
), FALSE
);
299 EnableWindow(GetDlgItem(hwndDlg
, IDC_SETTINGS_ADVANCED
), FALSE
);
301 else if (Result
== 1)
303 /* Single video adapter */
304 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_DEVICE
, WM_SETTEXT
, 0, (LPARAM
)pGlobalData
->DisplayDeviceList
->DeviceDescription
);
305 OnDisplayDeviceChanged(hwndDlg
, pGlobalData
, pGlobalData
->DisplayDeviceList
);
309 /* FIXME: multi video adapter */
310 /* FIXME: choose selected adapter being the primary one */
313 pGlobalData
->hBitmap
= LoadImage(hApplet
, MAKEINTRESOURCE(IDC_MONITOR
), IMAGE_BITMAP
, 0, 0, LR_LOADTRANSPARENT
);
314 if (pGlobalData
->hBitmap
!= NULL
)
316 GetObject(pGlobalData
->hBitmap
, sizeof(BITMAP
), &bitmap
);
318 pGlobalData
->cxSource
= bitmap
.bmWidth
;
319 pGlobalData
->cySource
= bitmap
.bmHeight
;
324 OnBPPChanged(IN HWND hwndDlg
, IN PGLOBAL_DATA pGlobalData
)
326 /* if new BPP is not compatible with resolution:
327 * 1) try to find the nearest smaller matching resolution
328 * 2) otherwise, get the nearest bigger resolution
330 PSETTINGS_ENTRY Current
;
331 DWORD dmNewBitsPerPel
;
335 SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, WM_GETTEXT
, (WPARAM
)(sizeof(Buffer
) / sizeof(TCHAR
)), (LPARAM
)Buffer
);
336 index
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, CB_FINDSTRINGEXACT
, (WPARAM
)-1, (LPARAM
)Buffer
);
337 dmNewBitsPerPel
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_BPP
, CB_GETITEMDATA
, index
, 0);
339 /* find if new parameters are valid */
340 Current
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
;
341 if (dmNewBitsPerPel
== Current
->dmBitsPerPel
)
347 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
349 if (dmNewBitsPerPel
< Current
->dmBitsPerPel
)
351 Current
= Current
->Blink
;
352 while (Current
!= NULL
)
354 if (Current
->dmBitsPerPel
== dmNewBitsPerPel
355 && Current
->dmPelsHeight
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsHeight
356 && Current
->dmPelsWidth
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsWidth
)
358 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
359 UpdateDisplay(hwndDlg
, pGlobalData
, TRUE
);
362 Current
= Current
->Blink
;
367 Current
= Current
->Flink
;
368 while (Current
!= NULL
)
370 if (Current
->dmBitsPerPel
== dmNewBitsPerPel
371 && Current
->dmPelsHeight
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsHeight
372 && Current
->dmPelsWidth
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsWidth
)
374 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
375 UpdateDisplay(hwndDlg
, pGlobalData
, TRUE
);
378 Current
= Current
->Flink
;
382 /* search smaller resolution compatible with current color depth */
383 Current
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->Blink
;
384 while (Current
!= NULL
)
386 if (Current
->dmBitsPerPel
== dmNewBitsPerPel
)
388 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
389 UpdateDisplay(hwndDlg
, pGlobalData
, TRUE
);
392 Current
= Current
->Blink
;
395 /* search bigger resolution compatible with current color depth */
396 Current
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->Flink
;
397 while (Current
!= NULL
)
399 if (Current
->dmBitsPerPel
== dmNewBitsPerPel
)
401 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
402 UpdateDisplay(hwndDlg
, pGlobalData
, TRUE
);
405 Current
= Current
->Flink
;
408 /* we shouldn't go there */
412 OnResolutionChanged(IN HWND hwndDlg
, IN PGLOBAL_DATA pGlobalData
, IN DWORD NewPosition
,
413 IN BOOL bUpdateThumb
)
415 /* if new resolution is not compatible with color depth:
416 * 1) try to find the nearest bigger matching color depth
417 * 2) otherwise, get the nearest smaller color depth
419 PSETTINGS_ENTRY Current
;
420 DWORD dmNewPelsHeight
= pGlobalData
->CurrentDisplayDevice
->Resolutions
[NewPosition
].dmPelsHeight
;
421 DWORD dmNewPelsWidth
= pGlobalData
->CurrentDisplayDevice
->Resolutions
[NewPosition
].dmPelsWidth
;
423 /* find if new parameters are valid */
424 Current
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
;
425 if (dmNewPelsHeight
== Current
->dmPelsHeight
&& dmNewPelsWidth
== Current
->dmPelsWidth
)
431 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
433 if (dmNewPelsHeight
< Current
->dmPelsHeight
)
435 Current
= Current
->Blink
;
436 while (Current
!= NULL
)
438 if (Current
->dmPelsHeight
== dmNewPelsHeight
439 && Current
->dmPelsWidth
== dmNewPelsWidth
440 && Current
->dmBitsPerPel
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmBitsPerPel
)
442 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
443 UpdateDisplay(hwndDlg
, pGlobalData
, bUpdateThumb
);
446 Current
= Current
->Blink
;
451 Current
= Current
->Flink
;
452 while (Current
!= NULL
)
454 if (Current
->dmPelsHeight
== dmNewPelsHeight
455 && Current
->dmPelsWidth
== dmNewPelsWidth
456 && Current
->dmBitsPerPel
== pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmBitsPerPel
)
458 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
459 UpdateDisplay(hwndDlg
, pGlobalData
, bUpdateThumb
);
462 Current
= Current
->Flink
;
466 /* search bigger color depth compatible with current resolution */
467 Current
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->Flink
;
468 while (Current
!= NULL
)
470 if (dmNewPelsHeight
== Current
->dmPelsHeight
&& dmNewPelsWidth
== Current
->dmPelsWidth
)
472 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
473 UpdateDisplay(hwndDlg
, pGlobalData
, bUpdateThumb
);
476 Current
= Current
->Flink
;
479 /* search smaller color depth compatible with current resolution */
480 Current
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->Blink
;
481 while (Current
!= NULL
)
483 if (dmNewPelsHeight
== Current
->dmPelsHeight
&& dmNewPelsWidth
== Current
->dmPelsWidth
)
485 pGlobalData
->CurrentDisplayDevice
->CurrentSettings
= Current
;
486 UpdateDisplay(hwndDlg
, pGlobalData
, bUpdateThumb
);
489 Current
= Current
->Blink
;
492 /* we shouldn't go there */
498 MessageBox(NULL
, TEXT("That button doesn't do anything yet"), TEXT("Whoops"), MB_OK
);
501 /* Property page dialog callback */
503 SettingsPageProc(IN HWND hwndDlg
, IN UINT uMsg
, IN WPARAM wParam
, IN LPARAM lParam
)
505 PGLOBAL_DATA pGlobalData
;
507 pGlobalData
= (PGLOBAL_DATA
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
512 OnInitDialog(hwndDlg
);
516 DWORD controlId
= LOWORD(wParam
);
517 DWORD command
= HIWORD(wParam
);
519 if (controlId
== IDC_SETTINGS_ADVANCED
&& command
== BN_CLICKED
)
521 else if (controlId
== IDC_SETTINGS_BPP
&& command
== CBN_SELCHANGE
)
522 OnBPPChanged(hwndDlg
, pGlobalData
);
527 switch (LOWORD(wParam
))
537 DWORD newPosition
= (DWORD
) SendDlgItemMessage(hwndDlg
, IDC_SETTINGS_RESOLUTION
, TBM_GETPOS
, 0, 0);
538 OnResolutionChanged(hwndDlg
, pGlobalData
, newPosition
, TRUE
);
543 OnResolutionChanged(hwndDlg
, pGlobalData
, HIWORD(wParam
), FALSE
);
550 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
551 if (lpnm
->code
== (UINT
)PSN_APPLY
)
553 if (pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsWidth
!= pGlobalData
->CurrentDisplayDevice
->InitialSettings
.dmPelsWidth
554 || pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsHeight
!= pGlobalData
->CurrentDisplayDevice
->InitialSettings
.dmPelsHeight
555 || pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmBitsPerPel
!= pGlobalData
->CurrentDisplayDevice
->InitialSettings
.dmBitsPerPel
)
557 /* FIXME: Need to test changes */
558 /* Apply new settings */
561 RtlZeroMemory(&devmode
, sizeof(DEVMODE
));
562 devmode
.dmSize
= (WORD
)sizeof(DEVMODE
);
563 devmode
.dmPelsWidth
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsWidth
;
564 devmode
.dmPelsHeight
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsHeight
;
565 devmode
.dmBitsPerPel
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmBitsPerPel
;
566 devmode
.dmFields
= DM_PELSWIDTH
| DM_PELSHEIGHT
| DM_BITSPERPEL
;
567 rc
= ChangeDisplaySettingsEx(
568 pGlobalData
->CurrentDisplayDevice
->DeviceName
,
575 case DISP_CHANGE_SUCCESSFUL
:
576 pGlobalData
->CurrentDisplayDevice
->InitialSettings
.dmPelsWidth
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsWidth
;
577 pGlobalData
->CurrentDisplayDevice
->InitialSettings
.dmPelsHeight
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmPelsHeight
;
578 pGlobalData
->CurrentDisplayDevice
->InitialSettings
.dmBitsPerPel
= pGlobalData
->CurrentDisplayDevice
->CurrentSettings
->dmBitsPerPel
;
580 case DISP_CHANGE_FAILED
:
581 MessageBox(NULL
, TEXT("Failed to apply new settings..."), TEXT("Display settings"), MB_OK
| MB_ICONSTOP
);
583 case DISP_CHANGE_RESTART
:
584 MessageBox(NULL
, TEXT("You need to restart your computer to apply changes."), TEXT("Display settings"), MB_OK
| MB_ICONINFORMATION
);
587 MessageBox(NULL
, TEXT("Unknown error when applying new settings..."), TEXT("Display settings"), MB_OK
| MB_ICONSTOP
);
600 hdc
= BeginPaint(hwndDlg
, &ps
);
602 hdcMem
= CreateCompatibleDC(hdc
);
603 SelectObject(hdcMem
, pGlobalData
->hBitmap
);
605 TransparentBlt(hdc
, 98, 0,
606 pGlobalData
->cxSource
,
607 pGlobalData
->cySource
, hdcMem
, 0, 0,
608 pGlobalData
->cxSource
,
609 pGlobalData
->cySource
, 0xFF80FF);
612 EndPaint(hwndDlg
, &ps
);
619 PDISPLAY_DEVICE_ENTRY Current
= pGlobalData
->DisplayDeviceList
;
620 while (Current
!= NULL
)
622 PDISPLAY_DEVICE_ENTRY Next
= Current
->Flink
;
623 PSETTINGS_ENTRY CurrentSettings
= Current
->Settings
;
624 while (CurrentSettings
!= NULL
)
626 PSETTINGS_ENTRY NextSettings
= CurrentSettings
->Flink
;
627 HeapFree(GetProcessHeap(), 0, CurrentSettings
);
628 CurrentSettings
= NextSettings
;
630 HeapFree(GetProcessHeap(), 0, Current
);
634 DeleteObject(pGlobalData
->hBitmap
);
636 HeapFree(GetProcessHeap(), 0, pGlobalData
);