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 发布