Change the display mode directly in the program
You can access the hkey_current_config/display/setings in the system registry to learn the current display resolution and number of colors.
However, the following methods are commonly used:
Key API functions are enumdisplaysettings and changedisplaysettings. The former is used to obtain all the display modes supported by the current display driver, while the latter is used to change the display mode. If a program changes the display mode, Windows sends the wm_displaychange message to all running programs. To obtain the current display mode, you can use the following function, which is more reliable than accessing the registry.
Bool cvideomodes: getcurrentvideosettings (devmode * devmode)
{
Hwnd hwnddesktop = getdomaintopwindow ();
HDC = getdc (hwnddesktop );
Devmode-> dmsize = sizeof (devmode );
Devmode-> dmbitsperpel = getdevicecaps (HDC, bitspixel );
Devmode-> dmpelswidth = getsystemmetrics (sm_cxscreen );
Devmode-> dmpelsheight = getsystemmetrics (sm_cyscreen );
Devmode-> dmfields = dm_bitsperpel | dm_pelswidth | dm_pelsheight;
Return true;
}
The following code shows how to use enumdisplaysettings to obtain all currently supported display modes:
Int modenum, done;
Devmode;
Done = 0;
Modenum = 0;
Do
{
Done =! Enumdisplaysettings (null, modenum, & devmode );
Addtolist (& devmode );
Modenum ++;
} While (! Done );
You can set the display mode as follows:
Rc = changedisplaysettings (& devmodecds_fullscreen); The devmode here is
Obtained by using enumdisplaysettings.
If the setting is normal, the returned value is disp_change_successful.