关于 ChangeDisplaySettings 动态调整屏幕分辨率
现在已经有了一些资料,缺少在pb 中的定义,或者能知道是使用哪一个数据库的也行。附现有资料如下.
函数功能:该函数把缺省显示设备的设置改变为由lpDevMode设定的图形模式,要改变一个特定显示设备的设置,请使用ChangeDisplaySettingEx函数。
函数原型:LONG ChangeDisplaySettings (LPDEVMODE lpDevMode, DWORD dwflags);
参数:
lpDevMode:指向一个描述转变图表的DEVMODE的指针。DEVMODE的dmSize参数必须依DEVMODE结构的大小、字节进行初始化,dmDriveExtra参数必须初始化来显示DEVMODE随后的驱动数据的字节数,另外还可以选用以下参数:
dmBitsPerPel每个像素的位数,dmPelsWidth像素宽度,dmPelsHeight像度高度,dmDisplayFlage模式标志。
dmDisplayFrequency模式频率。
dmposition在多显示配置中设备的位置(适用于Windows 98、Windows NT 5.0及以后版本)。
除了设置好DEVMOD结构中诸多元素的值之外,还必须要正确地设置dmFields元素中的标志。这些标志表明了DEVMODE结构中哪个元素在改变显示设置时使用了。如果在dmFields中没有设置正确的位,那么显示设置将不会发生变化。请设置好以下的标志:
DM_BITSPERPEL使用dmBitsPerPel的值,DM_PELSWIDTH使用dmPelsWidth的值,
DM_PELSHEIGHT使用dmPelsHeight的值,DM_DISPLAYFLAGS使用dmDisplayFlags的值,
DM_DISPLAYFREQUENCY使用dmDisplayFrequency的值。
DM_POSITION使用fdmPosition的值(适用于Windows98、WindowsNT5.0)。
如果lpDevMode为空。那么显示设置就使用注册表中的所有当前值。在显示模式动态地调整之后要想再回到缺省的模式,最简单的办法就是把lpDevMode参数置为空,使dwFlags参数置为0。
dwflags:表明了图形模式如何改变,它可能是如下的几种形式中的一种:
0:表明当前屏幕的图形模式要动态地改变。
CDS_UPDATEREGISTRY:表明当前屏幕的图形模式会动态地变化,并且该图形模式会更新注册表。该模式信息存贮在用户档案中。
CDS_TEST:系统检测是否要设置被请求的图形模式。
CDS_FULLSCREEN:从本质上讲该模式是暂时的。
CDS_GLOBAL:该设置保存在全局设置区域内, 因此它们会影响所有的用户。该标志仅在与标志一起使用时才有效。CDS_SET_PRIMARY:该设备成为首要设备。
CDS_RESET:设置要改变,即使请求的设置与当前设置一样。CDS_NORESET:设置保存在注册表中,但是它不起作用,该标志只有与CDS_UPDATEREGISTRY标志一起使用时才有效。
指定CDS_TEST允许一个应用确定哪个图形模式真正的有效。但并不会使系统变为那个有效的图形模式。
如果CDS_UPDATEREGISTRY被指定并且它可能会动态地改变图形模式。则注册表中保存该信息并且返回DISP_CHANGE_SUCCESSFUL如果不可能使用图形模式动态地改变,则注册表中保存该信息并且返回DISP_CHANGE_RESTART。
Windows NT:如果指定了CDS_UPDATEREGISTRY并且在注册表中不能保存该信息,则图形模式不会改变,并且返回DISP_CHANGE_NOTUPDATERD。
返回值:ChangeDisplaySettings函数的返回值如下:
DISP_CHANGE_SUCCESSFUL:设备改变成功。
DISP_CHANGE_RESTART:为使图形模式生效计算机必须重新启动。
DISP_CHANGE_BADFLAGS:标志的无效设置被传送。
DISP_CHANGE_NOTUPDATED:在WindowsNT中不能把设置写入注册表。
DISP_CHANGE_BADPARA:一个无效的参数被传递。它可以包括一个无效的标志或标志的组合。
DISP_CHANGE_FAILED:指定图形模式的显示驱动失效。
DISP_CHANGE_ADMODE:不支持图形模式。
注释:为了保证传递给ChangeDisplaySetting的DEVMODE结构是有效的,并且仅包含显示驱动支持的值,可以使用由EnumDisplaySettings函数返回的DEVMODE。
当显示模式被动态地改变时,WM_DISPLAYCHANGE消息带着如下的消息参数传递给所有正在运行的应用:
wParam每像素点的新位数,LOWORD(lParam)新像素宽度,HIWORD(lParam)新像素高度。
速查:Windows NT:3.51及以上版本;Windows:95及以上版本;Windows CE:不支持;头文件:winuser.h;库文件:user32.lib;Unicode:在Windows NT上实现为Unicode和ANSI两种版本。
The ChangeDisplaySettings function changes the display settings to the specified graphics mode.
LONG ChangeDisplaySettings(
LPDEVMODE lpDevMode,
DWORD dwflags
);
Parameters
lpDevMode
Pointer to a DEVMODE structure that describes the graphics mode to switch to. The dmSize member must be initialized to the size, in bytes, of the DEVMODE structure. The following fields in the DEVMODE structure are used:
Member Meaning
dmBitsPerPel Bits per pixel
dmPelsWidth Pixel width
dmPelsHeight Pixel height
dmDisplayFlags Mode flags
dmDisplayFrequency Mode frequency
In addition to setting a value in one or more of the preceding DEVMODE members, you must also set the appropriate flags in the dmFields member. The flags indicate which members of the DEVMODE structure are used for the display settings change. If the appropriate bit is not set in dmFields, the display setting will not be changed. Set one or more of the following flags:
Flag Meaning
DM_BITSPERPEL Use the dmBitsPerPel value.
DM_PELSWIDTH Use the dmPelsWidth value.
DM_PELSHEIGHT Use the dmPelsHeight value.
DM_DISPLAYFLAGS Use the dmDisplayFlags value.
DM_DISPLAYFREQENCY Use the dmDisplayFrequency value.
If lpDevMode is NULL, all the values currently in the registry will be used for the display setting. Passing NULL for the
lpDevMode parameter is the easiest way to return to the default mode after a dynamic mode change.
dwflags
Indicates how the graphics mode should be changed. May be one of the following:
Flag Meaning
0 The graphics mode for the current screen will be changed dynamically.
CDS_UPDATEREGISTRY The graphics mode for the current screen will be changed dynamically and the graphics mode will be updated in the registry. The mode information is stored in the USER profile.
CDS_TEST The system tests if the requested graphics mode could be set.
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: If the information could not be stored in the registry, the graphics mode is not changed and DISP_CHANGE_NOTUPDATED is returned.
Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to change to that graphics mode.
Return Values
Returns one of the following values:
Value Meaning
DISP_CHANGE_SUCCESSFUL The settings change was successful.
DISP_CHANGE_RESTART The computer must be restarted in order for the graphics mode to work.
DISP_CHANGE_BADFLAGS An invalid set of flags was passed in.
DISP_CHANGE_FAILED The display driver failed the specified graphics mode.
DISP_CHANGE_BADMODE The graphics mode is not supported.
DISP_CHANGE_NOTUPDATED Windows NT only: Unable to write settings to the registry.
Remarks
Using the DEVMODE returned by the EnumDisplaySettings function ensures that the DEVMODE passed to ChangeDisplaySettings is valid and contains only values supported by the display driver.
When the display mode is changed dynamically, the WM_DISPLAYCHANGE message is sent to all running applications with the following message parameters:
Parameters Meaning
wParam New bits per pixel
LOWORD(lParam) New pixel width
HIWORD(lParam) New pixel height
See Also
CreateDC, DEVMODE, EnumDisplaySettings, WM_DISPLAYCHANGE
函数功能:该函数把缺省显示设备的设置改变为由lpDevMode设定的图形模式,要改变一个特定显示设备的设置,请使用ChangeDisplaySettingEx函数。
函数原型:LONG ChangeDisplaySettings (LPDEVMODE lpDevMode, DWORD dwflags);
参数:
lpDevMode:指向一个描述转变图表的DEVMODE的指针。DEVMODE的dmSize参数必须依DEVMODE结构的大小、字节进行初始化,dmDriveExtra参数必须初始化来显示DEVMODE随后的驱动数据的字节数,另外还可以选用以下参数:
dmBitsPerPel每个像素的位数,dmPelsWidth像素宽度,dmPelsHeight像度高度,dmDisplayFlage模式标志。
dmDisplayFrequency模式频率。
dmposition在多显示配置中设备的位置(适用于Windows 98、Windows NT 5.0及以后版本)。
除了设置好DEVMOD结构中诸多元素的值之外,还必须要正确地设置dmFields元素中的标志。这些标志表明了DEVMODE结构中哪个元素在改变显示设置时使用了。如果在dmFields中没有设置正确的位,那么显示设置将不会发生变化。请设置好以下的标志:
DM_BITSPERPEL使用dmBitsPerPel的值,DM_PELSWIDTH使用dmPelsWidth的值,
DM_PELSHEIGHT使用dmPelsHeight的值,DM_DISPLAYFLAGS使用dmDisplayFlags的值,
DM_DISPLAYFREQUENCY使用dmDisplayFrequency的值。
DM_POSITION使用fdmPosition的值(适用于Windows98、WindowsNT5.0)。
如果lpDevMode为空。那么显示设置就使用注册表中的所有当前值。在显示模式动态地调整之后要想再回到缺省的模式,最简单的办法就是把lpDevMode参数置为空,使dwFlags参数置为0。
dwflags:表明了图形模式如何改变,它可能是如下的几种形式中的一种:
0:表明当前屏幕的图形模式要动态地改变。
CDS_UPDATEREGISTRY:表明当前屏幕的图形模式会动态地变化,并且该图形模式会更新注册表。该模式信息存贮在用户档案中。
CDS_TEST:系统检测是否要设置被请求的图形模式。
CDS_FULLSCREEN:从本质上讲该模式是暂时的。
CDS_GLOBAL:该设置保存在全局设置区域内, 因此它们会影响所有的用户。该标志仅在与标志一起使用时才有效。CDS_SET_PRIMARY:该设备成为首要设备。
CDS_RESET:设置要改变,即使请求的设置与当前设置一样。CDS_NORESET:设置保存在注册表中,但是它不起作用,该标志只有与CDS_UPDATEREGISTRY标志一起使用时才有效。
指定CDS_TEST允许一个应用确定哪个图形模式真正的有效。但并不会使系统变为那个有效的图形模式。
如果CDS_UPDATEREGISTRY被指定并且它可能会动态地改变图形模式。则注册表中保存该信息并且返回DISP_CHANGE_SUCCESSFUL如果不可能使用图形模式动态地改变,则注册表中保存该信息并且返回DISP_CHANGE_RESTART。
Windows NT:如果指定了CDS_UPDATEREGISTRY并且在注册表中不能保存该信息,则图形模式不会改变,并且返回DISP_CHANGE_NOTUPDATERD。
返回值:ChangeDisplaySettings函数的返回值如下:
DISP_CHANGE_SUCCESSFUL:设备改变成功。
DISP_CHANGE_RESTART:为使图形模式生效计算机必须重新启动。
DISP_CHANGE_BADFLAGS:标志的无效设置被传送。
DISP_CHANGE_NOTUPDATED:在WindowsNT中不能把设置写入注册表。
DISP_CHANGE_BADPARA:一个无效的参数被传递。它可以包括一个无效的标志或标志的组合。
DISP_CHANGE_FAILED:指定图形模式的显示驱动失效。
DISP_CHANGE_ADMODE:不支持图形模式。
注释:为了保证传递给ChangeDisplaySetting的DEVMODE结构是有效的,并且仅包含显示驱动支持的值,可以使用由EnumDisplaySettings函数返回的DEVMODE。
当显示模式被动态地改变时,WM_DISPLAYCHANGE消息带着如下的消息参数传递给所有正在运行的应用:
wParam每像素点的新位数,LOWORD(lParam)新像素宽度,HIWORD(lParam)新像素高度。
速查:Windows NT:3.51及以上版本;Windows:95及以上版本;Windows CE:不支持;头文件:winuser.h;库文件:user32.lib;Unicode:在Windows NT上实现为Unicode和ANSI两种版本。
The ChangeDisplaySettings function changes the display settings to the specified graphics mode.
LONG ChangeDisplaySettings(
LPDEVMODE lpDevMode,
DWORD dwflags
);
Parameters
lpDevMode
Pointer to a DEVMODE structure that describes the graphics mode to switch to. The dmSize member must be initialized to the size, in bytes, of the DEVMODE structure. The following fields in the DEVMODE structure are used:
Member Meaning
dmBitsPerPel Bits per pixel
dmPelsWidth Pixel width
dmPelsHeight Pixel height
dmDisplayFlags Mode flags
dmDisplayFrequency Mode frequency
In addition to setting a value in one or more of the preceding DEVMODE members, you must also set the appropriate flags in the dmFields member. The flags indicate which members of the DEVMODE structure are used for the display settings change. If the appropriate bit is not set in dmFields, the display setting will not be changed. Set one or more of the following flags:
Flag Meaning
DM_BITSPERPEL Use the dmBitsPerPel value.
DM_PELSWIDTH Use the dmPelsWidth value.
DM_PELSHEIGHT Use the dmPelsHeight value.
DM_DISPLAYFLAGS Use the dmDisplayFlags value.
DM_DISPLAYFREQENCY Use the dmDisplayFrequency value.
If lpDevMode is NULL, all the values currently in the registry will be used for the display setting. Passing NULL for the
lpDevMode parameter is the easiest way to return to the default mode after a dynamic mode change.
dwflags
Indicates how the graphics mode should be changed. May be one of the following:
Flag Meaning
0 The graphics mode for the current screen will be changed dynamically.
CDS_UPDATEREGISTRY The graphics mode for the current screen will be changed dynamically and the graphics mode will be updated in the registry. The mode information is stored in the USER profile.
CDS_TEST The system tests if the requested graphics mode could be set.
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: If the information could not be stored in the registry, the graphics mode is not changed and DISP_CHANGE_NOTUPDATED is returned.
Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to change to that graphics mode.
Return Values
Returns one of the following values:
Value Meaning
DISP_CHANGE_SUCCESSFUL The settings change was successful.
DISP_CHANGE_RESTART The computer must be restarted in order for the graphics mode to work.
DISP_CHANGE_BADFLAGS An invalid set of flags was passed in.
DISP_CHANGE_FAILED The display driver failed the specified graphics mode.
DISP_CHANGE_BADMODE The graphics mode is not supported.
DISP_CHANGE_NOTUPDATED Windows NT only: Unable to write settings to the registry.
Remarks
Using the DEVMODE returned by the EnumDisplaySettings function ensures that the DEVMODE passed to ChangeDisplaySettings is valid and contains only values supported by the display driver.
When the display mode is changed dynamically, the WM_DISPLAYCHANGE message is sent to all running applications with the following message parameters:
Parameters Meaning
wParam New bits per pixel
LOWORD(lParam) New pixel width
HIWORD(lParam) New pixel height
See Also
CreateDC, DEVMODE, EnumDisplaySettings, WM_DISPLAYCHANGE
...全文
相关推荐
VC++ 动态改变Windows分辨率
总的来说,VC++动态改变Windows分辨率涉及到对Windows API的深入理解和灵活运用。通过枚举和设置DEVMODE结构体,开发者可以在程序中实现屏幕分辨率的动态调整。
易语言设置屏幕分辨率
通过以上步骤,我们可以使用易语言轻松地实现屏幕分辨率的动态调整。这种功能在开发桌面应用或者演示程序时非常有用,例如,适应不同大小的显示器或优化特定场景的视觉效果。
vb6_屏幕分辨率调节
屏幕分辨率是指屏幕上像素点的数量,通常以宽度*高度的形式表示,例如1920*1080。通过编写特定的代码,我们可以使程序根据需求动态调整屏幕分辨率,为用户提供个性化的视觉体验。
能够改变屏幕分辨率的程序
在程序的内部实现上,往往需要调用操作系统的API接口,比如在Windows操作系统中,它可能会使用ChangeDisplaySettings函数来实现动态调整分辨率的目的。
易语言实现屏幕分辨率设置的完整教程
易语言是一种简体中文编程语言,它极大地简化了编程的过程,使初学者可以快速上手,并且提供了强大的功能来满足专业开发需求。它基于事件驱动机制,支持面向对象编程,使得程序的结构更加清晰。易语言的一大特色是拥有大量的中文命令和函数,极大地降低了编程语言的学习门槛,同时支持API调用,让开发者可以深入系统底层进行开发。graph TD;A[易语言] -->|面向对象编程| B[高级编程技巧]A -->|中文命令和函数| C[易学易用]A -->|系统API调用| D[系统底层开发]


API 调用
