关于 ChangeDisplaySettings 动态调整屏幕分辨率

billxia 2002-10-25 09:23:41
现在已经有了一些资料,缺少在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
...全文
860 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jamy_li 2002-10-31
  • 打赏
  • 举报
回复
对,我也发现了!不过,我来晚了
billxia 2002-10-26
  • 打赏
  • 举报
回复
已经看过,但发现一个问题,当我的程序中途中断了,就没有办法回到原来的屏幕尺寸了
pufan 2002-10-25
  • 打赏
  • 举报
回复
http://www.pdriver.com/bbs3/cgi-bin/topic.cgi?forum=6&topic=6581&show=0
看看此贴.
billxia 2002-10-25
  • 打赏
  • 举报
回复
写错了,是希望知道在哪个动态库中

680

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder API 调用
社区管理员
  • API 调用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧