小标
2018-08-15
来源 :
阅读 1357
评论 0
摘要:本文主要向大家介绍了VC编程:VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上,通过具体的内容向大家展示,希望对大家学习VC编程有所帮助。
本文主要向大家介绍了VC编程:VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上,通过具体的内容向大家展示,希望对大家学习VC编程有所帮助。
下面来看看GetDeviceCaps函数的用法:
函数功能:用于得到被定义的系统数据或者系统配置信息
函数原型:获取一些设备数据
// By MoreWindows( //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.
//blog.csdn.net/morewindows/article/details/8502592
由GetDeviceCaps函数的介绍可知获取屏幕的物理大小非常简单,下面给出完整的源代码:
[cpp]
// 获取屏幕大小 物理大小 <A href="//blog.csdn.net/morewindows/article/details/8502592">//blog.csdn.net/morewindows/article/details/8502592</A>
#include <stdio.h>
#include <windows.h>
int main()
{
printf(" 获取屏幕大小 物理大小\n");
printf(" -- By MoreWindows( //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;
}
// 获取屏幕大小 物理大小 //blog.csdn.net/morewindows/article/details/8502592
#include <stdio.h>
#include <windows.h>
int main()
{ www.2cto.com
printf(" 获取屏幕大小 物理大小\n");
printf(" -- By MoreWindows( //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/MFC频道!
喜欢 | 1
不喜欢 | 0
您输入的评论内容中包含违禁敏感词
我知道了

请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号