c++获取屏幕大小

API:

要取得屏幕大小,可以用下面几个函数:

# include <windows.h>
int
cx = GetSystemMetrics( SM_CXFULLSCREEN ); int cy = GetSystemMetrics( SM_CYFULLSCREEN );

通过上边两个函数获取的是 显示屏幕的大小,但不包括任务栏等区域。

int  cx   =   GetSystemMetrics(   SM_CXSCREEN   );   
int  cy   =   GetSystemMetrics(   SM_CYSCREEN   );

这两个函数获取的是真正屏幕的大小。
MFC:

HDC hDC =  ::GetDC(HWND(NULL));               // 得到屏幕DC  
int x  =  ::GetDeviceCaps(hDC,HORZRES);       //
int y  =  ::GetDeviceCaps(hDC,VERTRES);        //
::ReleaseDC(HWND(NULL),hDC);                  // 释放DC
posted @ 2017-10-28 12:23  小懒鼠  阅读(7055)  评论(0)    收藏  举报