@@ -106,10 +106,24 @@ GdiGetHandleUserData(
106106 return pentry -> pUser ;
107107}
108108
109+ VOID
110+ PrintAvailableDisplayModes (void )
111+ {
112+ DEVMODEW dm = { .dmSize = sizeof (dm ) };
113+ ULONG iMode = 0 ;
114+
115+ printf ("Available display modes:\n" );
116+ while (EnumDisplaySettingsW (NULL , iMode ++ , & dm ))
117+ {
118+ printf (" %ux%u @ %u bpp, freq: %u Hz\n" ,
119+ dm .dmPelsWidth , dm .dmPelsHeight , dm .dmBitsPerPel , dm .dmDisplayFrequency );
120+ }
121+ }
122+
109123BOOL
110124ChangeScreenBpp (
111125 _In_ ULONG cBitsPixel ,
112- _Out_ PULONG pcOldBitsPixel )
126+ _Out_ PDEVMODEW pdmOld )
113127{
114128 DEVMODEW dm = { .dmSize = sizeof (dm ) };
115129
@@ -119,18 +133,26 @@ ChangeScreenBpp(
119133 return FALSE;
120134 }
121135
122- * pcOldBitsPixel = dm .dmBitsPerPel ;
136+ printf ("ChangeScreenBpp(%lu): Old display settings: %ux%u @ %u bpp\n" ,
137+ cBitsPixel , dm .dmPelsWidth , dm .dmPelsHeight , dm .dmBitsPerPel );
138+
139+ * pdmOld = dm ;
123140
124141 if (dm .dmBitsPerPel != cBitsPixel )
125142 {
126143 dm .dmBitsPerPel = cBitsPixel ;
127- if (ChangeDisplaySettingsExW ( NULL , & dm , NULL , CDS_UPDATEREGISTRY | CDS_GLOBAL , NULL ) != DISP_CHANGE_SUCCESSFUL )
144+ if (ChangeDisplaySettingsW ( & dm , 0 ) != DISP_CHANGE_SUCCESSFUL )
128145 {
129- printf ("Failed to change display settings to %lu bpp. Current bpp: %u\n" , cBitsPixel , * pcOldBitsPixel );
146+ printf ("Failed to change display settings.\n" );
147+ PrintAvailableDisplayModes ();
130148 return FALSE;
131149 }
132150 }
133151
152+ EnumDisplaySettingsW (NULL , ENUM_CURRENT_SETTINGS , & dm );
153+ printf ("ChangeScreenBpp(%lu): New display settings: %ux%u @ %u bpp\n" ,
154+ cBitsPixel , dm .dmPelsWidth , dm .dmPelsHeight , dm .dmBitsPerPel );
155+
134156 return TRUE;
135157}
136158
0 commit comments