设为首页 加入收藏

TOP

VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上
2014-11-23 19:09:48 来源: 作者: 【 】 浏览:19
Tags:获取 屏幕 大小 第二篇 物理 GetDeviceCaps
下面来看看GetDeviceCaps函数的用法:
函数功能:用于得到被定义的 系统数据或者系统配置信息
函数原型:获取一些设备数据
// By MoreWindows( http://blog.csdn.net/MoreWindows )
int GetDeviceCaps(
HDChdc, // handle to DC
int nIndex // index of capability
);
参数说明:
第一个参数表示设备环境的HDC句柄。
第二个参数与GetSystemMetrics函数的参数类似,有很多种取值,这里就不一一列举了,常用的有二个:
HORZSIZE
Width, in millimeters, of the physical screen.
VERTSIZE
Height, in millimeters, of the physical screen.
http://blog.csdn.net/more windows/article/details/8502592
由GetDeviceCaps函数的介绍可知获取屏幕的物理大小非常简单,下面给出完整的源代码:
[cpp]
#include
#include
int main()
{
printf(" 获取屏幕大小 物理大小\n");
printf(" -- By MoreWindows( http://blog.csdn.net/MoreWindows ) --\n\n");
int nScreenWidth, nScreenHeight;
HDC hdcScreen = GetDC(NULL); //获取屏幕的HDC
nScreenWidth = GetDeviceCaps(hdcScreen, HORZSIZE);
nScreenHeight = GetDeviceCaps(hdcScreen, VERTSIZE);
printf("屏幕大小(毫米) 宽:%d 高:%d\n", nScreenWidth, nScreenHeight);
return 0;
}
// 获取屏幕大小 物理大小 http://blog.csdn.net/morewindows/article/details/8502592
#include
#include
int main()
{ www.2cto.com
printf(" 获取屏幕大小 物理大小\n");
printf(" -- By MoreWindows( http://blog.csdn.net/MoreWindows ) --\n\n");
int nScreenWidth, nScreenHeight;
HDC hdcScreen = GetDC(NULL); //获取屏幕的HDC
nScreenWidth = GetDeviceCaps(hdcScreen, HORZSIZE);
nScreenHeight = GetDeviceCaps(hdcScreen, VERTSIZE);
printf("屏幕大小(毫米) 宽:%d 高:%d\n", nScreenWidth, nScreenHeight);
return 0;
}程序运行结果如下所示:
\
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇VC++获取屏幕大小第三篇 物理大小.. 下一篇图像编程学习笔记2――bmp位图平..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: