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
VC得到屏幕的当前分辨率方法(5种)
最新推荐文章于 2022-01-06 10:43:35 发布
本文介绍了在VC中获取屏幕当前分辨率的5种方法,包括Windows API调用、EnumDisplaySettings、GetDeviceCaps以及利用GetSystemMetrics和GetDC。同时提到了如何处理屏幕分辨率变化的动态适应和获取桌面客户区大小,以及与任务栏相关的处理。

最低0.47元/天 解锁文章
5699





