Quantcast
Channel: C++博客-所有随笔
Viewing all articles
Browse latest Browse all 7882

c++获取屏幕大小

$
0
0
API:
要取得屏幕大小,可以用下面几个函数:
int  cx   =  GetSystemMetricsSM_CXFULLSCREEN );
int  cy   =  GetSystemMetricsSM_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


王海光 2013-08-13 14:09 发表评论

Viewing all articles
Browse latest Browse all 7882

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>