码迷,mamicode.com
首页 > 编程语言 > 详细

c++获取屏幕大小

时间:2017-10-28 13:50:28      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:显示   blog   任务栏   显示屏   sys   border   code   include   大小   

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

c++获取屏幕大小

标签:显示   blog   任务栏   显示屏   sys   border   code   include   大小   

原文地址:http://www.cnblogs.com/xiaolanshu/p/7746484.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!