VC得到屏幕的当前分辨率方法(5种)

本文介绍了在VC中获取屏幕当前分辨率的5种方法,包括Windows API调用、EnumDisplaySettings、GetDeviceCaps以及利用GetSystemMetrics和GetDC。同时提到了如何处理屏幕分辨率变化的动态适应和获取桌面客户区大小,以及与任务栏相关的处理。
摘要由CSDN通过智能技术生成
vc得到屏幕的当前分辨率方法:
1.Windows API调用
int width = GetSystemMetrics ( SM_CXSCREEN );
int height= GetSystemMetrics ( SM_CYSCREEN );
如果想动态自适应分辨率的变化,处理WM_DISPLAYCHANGE消息.
2.获得分辨率
BOOL EnumDisplaySettings(
LPCTSTR lpszDeviceName, // display device
DWORD iModeNum, // graphics mode
LPDEVMODE lpDevMode // graphics mode settings
);

改变分辨率
LONG ChangeDisplaySettings(
LPDEVMODE lpDevMode, // graphics mode
DWORD dwflags // graphics mode options
);
3.用GetDeviceCaps

int GetDeviceCaps(
HDC hdc, // handle to the device context
int nIndex // index of capability to query
);

4.用GetDeviceCaps
HDC hdcScreen = GetDC( NULL );
int cx = GetDeviceCaps( hdcScreen, HORZRES );
int cy = GetDeviceCaps( hdcScreen, VERTRES );
DeleteObject( hdcScreen );
其中nIndex可以取:
HORZRES VERTRES 或
分别表示:
HORZRES :Width, in pixels, of the screen.
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值