请教哪个Windows API能修改屏幕的分辨率?

sunstrom 2003-04-13 06:45:06
我在设计程序的时候需要动态修改屏幕的分辨率,请各位老大指教一下哪个API能修改屏幕的分辨率?
...全文
551 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuv2002 2003-04-14
  • 打赏
  • 举报
回复
bool SetPixelAndColor(HDC hdc, unsigned int Width, unsigned int Height, int BitsPerPixel)
{

DEVMODE CurMode;
int result=1;
for(int i=0; result ; i++)
result = EnumDisplaySettings(NULL, i, &CurMode);
//CurMode.dmPelsWidth =GetDeviceCaps(hdc, HORZRES);
//CurMode.dmPelsHeight =GetDeviceCaps(hdc, VERTRES);
CurMode.dmPelsWidth = Screen->Width;
CurMode.dmPelsHeight = Screen->Height;

if(CurMode.dmPelsWidth!=Width || CurMode.dmPelsHeight!=Height){
CurMode.dmPelsWidth = Width;
CurMode.dmPelsHeight = Height;
CurMode.dmBitsPerPel = BitsPerPixel;
CurMode.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
result = ChangeDisplaySettings(&CurMode, CDS_UPDATEREGISTRY);
return (result==DISP_CHANGE_SUCCESSFUL);
}
else
return false;

}

举个例子
SetPixelAndColor(NULL,800,600,24);
是将分面率换成800X600X真彩24位
Behard 2003-04-14
  • 打赏
  • 举报
回复
ChangeDisplaySettings Or ChangeDisplaySettingsEX
chinayang 2003-04-14
  • 打赏
  • 举报
回复
ChangeDisplaySettings

The ChangeDisplaySettings function changes the settings of the default display device to the graphics mode specified in lpDevMode. To change the settings of a specified display device, use the ChangeDisplaySettingsEx function.

LONG ChangeDisplaySettings(
LPDEVMODE lpDevMode,
DWORD dwflags
);

Parameters
lpDevMode
Pointer to a DEVMODE structure that describes the graphics mode to switch to.
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. Member Meaning
dmBitsPerPel Bits per pixel
dmPelsWidth Pixel width
dmPelsHeight Pixel height
dmDisplayFlags Mode flags
dmDisplayFrequency Mode frequency
dmPosition Windows 98, Windows NT 5.0 and later: Position of the device in a multi-monitor configuration



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_DISPLAYFREQUENCY Use the dmDisplayFrequency value.
DM_POSITION Windows 98, Windows NT 5.0 and later: Use the dmPosition 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 and 0 for the dwFlags 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.
CDS_FULLSCREEN The mode is temporary in nature.
Windows NT: If you change to and from another desktop, this mode will not be reset.

CDS_GLOBAL The settings will be saved in the global settings area so that they will affect all users on the machine. Otherwise, only the settings for the user are modified. This flag is only valid when specified with the CDS_UPDATEREGISTRY flag.
CDS_SET_PRIMARY This device will become the primary device.
CDS_RESET The settings should be changed, even if the requested settings are the same as the current settings.
CDS_NORESET The settings will be saved in the registry, but will not take affect. This flag is only valid when specified with the CDS_UPDATEREGISTRY flag.


Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to change to that graphics mode.

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 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.

SharpKing515 2003-04-14
  • 打赏
  • 举报
回复
搜索。。。有旧贴。
awllll 2003-04-13
  • 打赏
  • 举报
回复
SetDisplayMode
myy 2003-04-13
  • 打赏
  • 举报
回复
EnumDisplaySettings
ChangeDisplaySettings

//不知道 2K/XP 下好不好用, :D

1,221

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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