VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上
来源:互联网 发布:mac游戏推荐单机游戏 编辑:程序博客网 时间:2024/06/01 09:59
函数功能:用于得到被定义的系统数据或者系统配置信息
函数原型:获取一些设备数据
// By MoreWindows( http://blog.csdn.NET/MoreWindows )
intGetDeviceCaps(
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/morewindows/article/details/8502592
由GetDeviceCaps函数的介绍可知获取屏幕的物理大小非常简单,下面给出完整的源代码:
- // 获取屏幕大小 物理大小 <a href="http://blog.csdn.net/morewindows/article/details/8502592">http://blog.csdn.net/morewindows/article/details/8502592</a>
- #include <stdio.h>
- #include <windows.h>
- 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;
- }
程序运行结果如下所示:
后面一篇《VC++获取屏幕大小第三篇物理大小GetDeviceCaps下》将介绍获取屏幕的物理大小后计算屏幕对角线长度,再换算成英寸。这样可以方便大家查看自己电脑屏幕是多少英寸的,很多笔记本用户会有意外喔^_^。欢迎继续浏览。地址:http://blog.csdn.net/morewindows/article/details/8610891
转载请标明出处,原文地址:http://blog.csdn.net/morewindows/article/details/8502592
欢迎关注微博:http://weibo.com/MoreWindows
Note: MSDN对GetDeviceCaps函数有说明:GetDeviceCaps reports info that the display driver provides. If the display driver declines to report any info,GetDeviceCaps calculates the info based on fixed calculations. If the display driver reports invalid info,GetDeviceCaps returns the invalid info. Also, if the display driver declines to report info,GetDeviceCaps might calculate incorrect info because it assumes either fixed DPI (96 DPI) or a fixed size (depending on the info that the display driver did and didn’t provide). Unfortunately, a display driver that is implemented to the Windows Display Driver Model (WDDM) (introduced in Windows Vista) causes GDI to not get the info, soGetDeviceCaps must always calculate the info.
- VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上
- VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上
- VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上
- 获取屏幕大小第二篇 物理大小GetDeviceCaps 上
- VC++获取屏幕大小第三篇 物理大小GetDeviceCaps 下
- VC++获取屏幕大小第三篇 物理大小GetDeviceCaps 下
- VC++获取屏幕大小第三篇 物理大小GetDeviceCaps 下
- 获取屏幕大小第三篇 物理大小GetDeviceCaps 下(英寸和像素转换-2540)
- vc 获取屏幕大小
- vc 获取屏幕大小
- VC++获取屏幕大小第一篇 像素大小GetSystemMetrics
- VC++获取屏幕大小第一篇 像素大小 GetSystemMetrics
- VC++获取屏幕大小第一篇 像素大小GetSystemMetrics
- 获取屏幕信息GetDeviceCaps
- vc获得屏幕大小
- vc获得屏幕大小
- VC MFC 获取屏幕大小 程序窗口大小位置 控件大小位置
- 获取屏幕大小
- qt入门教程收集
- 转 jquery选择器空格与大于号、加号与波浪号的区别
- Java-web分页操作(jsp+servlet+javaBean)
- HDU 5414 CRB and String(水~)
- 字符、字节的概念及其区别
- VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上
- select * from book where 1=1
- json数据转换异常:net.sf.json.JSONException: Java.lang.reflect.InvocationTargetException
- Java中的final共有三种用法(转)
- 计算机系统要素:第二章 布尔运算
- 设备兼容思考——RWD:响应式WEB
- json对象和json字符串区别
- JSTL标签库
- 震惊!慢SQL居然能优化到这种速度_我不服!