|
ChangeDisplaySettingsEx |
|
Description
The ChangeDisplaySettingsEx function changes the settings of the specified display device to the specified graphics mode.
C++ Syntax
PowerBASIC Syntax
Unicode version:
Parameters
lpszDeviceName
[in] Pointer to a null-terminated string that specifies the display device whose graphics mode will change. Only display device names as returned by EnumDisplayDevices are valid. See EnumDisplayDevices for further information on the names associated with these display devices.
The lpszDeviceName parameter can be NULL. A NULL value specifies the default display device. The default device can be determined by calling EnumDisplayDevices and checking for the DISPLAY_DEVICE_PRIMARY_DEVICE flag.
lpDevMode
[in] Pointer to a DEVMODE structure that describes the new graphics mode. If lpDevMode is NULL, all the values currently in the registry will be used for the display setting. Passing NULL for the lpDevMode parameter and 0 for the dwFlags parameter is the easiest way to return to the default mode after a dynamic mode change.
The dmSize member of DEVMODE must be initialized to the size, in bytes, of the DEVMODE structure. The dmDriverExtra member of DEVMODE must be initialized to indicate the number of bytes of private driver data following the DEVMODE structure. In addition, you can use any or all of the following members of the DEVMODE structure.
In addition to using one or more of the preceding DEVMODE members, you must also set one or more of the following values in the dmFields member to change the display setting.
hwnd
Reserved; must be NULL.
dwflags
[in] Indicates how the graphics mode should be changed. This parameter can be one of the following values.
Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to change to them.
If CDS_UPDATEREGISTRY is specified and it is possible to change the graphics mode dynamically, the information is stored in the registry and DISP_CHANGE_SUCCESSFUL is returned. If it is not possible to change the graphics mode dynamically, the information is stored in the registry and DISP_CHANGE_RESTART is returned.
Windows NT/2000/XP: If CDS_UPDATEREGISTRY is specified and the information could not be stored in the registry, the graphics mode is not changed and DISP_CHANGE_NOTUPDATED is returned.
Return Value
The ChangeDisplaySettings function returns one of the following values.
Remarks
To ensure that the DEVMODE structure passed to ChangeDisplaySettingsEx is valid and contains only values supported by the display driver, use the DEVMODE returned by the EnumDisplaySettings function.
When adding a display monitor to a multiple-monitor system programmatically, set DEVMODE.dmFields to DM_POSITION and specify a position (in DEVMODE.dmPosition) for the monitor you are adding that is adjacent to at least one pixel of the display area of an existing monitor. To detach the monitor, set DEVMODE.dmFields to DM_POSITION but set DEVMODE.dmPelsWidth and DEVMODE.dmPelsHeight to zero.
When the display mode is changed dynamically, the WM_DISPLAYCHANGE message is sent to all running applications with the following message parameters.
To change the settings for more than one display at the same time, first call ChangeDisplaySettingsEx for each device individually to update the registry without applying the changes. Then call ChangeDisplaySettingsEx once more, with a NULL device, to apply the changes. For example, to change the settings for two displays, do the following:
ChangeDisplaySettingsEx (lpszDeviceName1, lpDevMode1, %NULL, (%CDS_UPDATEREGISTRY OR %CDS_NORESET), BYVAL %NULL) ChangeDisplaySettingsEx (lpszDeviceName2, lpDevMode2, %NULL, (%CDS_UPDATEREGISTRY OR %CDS_NORESET), BYVAL %NULL) ChangeDisplaySettingsEx (%NULL, BYVAL %NULL, %NULL, 0, BYVAL %NULL)
Windows 95/98/Me: ChangeDisplaySettingsW is supported by the Microsoft Layer for Unicode.
|
