设为首页 加入收藏

TOP

VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上
2014-11-23 19:09:48 】 浏览:3329
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位图平..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目