VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上
函數(shù)功能:用于得到被定義的系統(tǒng)數(shù)據(jù)或者系統(tǒng)配置信息
函數(shù)原型:獲取一些設備數(shù)據(jù)
//?By?MoreWindows(?http://blog.csdn.NET/MoreWindows?) ?
int GetDeviceCaps(
?????? HDChdc,???? // handle to DC
?????? int nIndex?? // index of capability
);
參數(shù)說明:
第一個參數(shù)表示設備環(huán)境的HDC句柄。
第二個參數(shù)與GetSystemMetrics函數(shù)的參數(shù)類似,有很多種取值,這里就不一一列舉了,常用的有二個:
| 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函數(shù)的介紹可知獲取屏幕的物理大小非常簡單,下面給出完整的源代碼:
[cpp] view plaincopy print?程序運行結(jié)果如下所示:
?
?
?
后面一篇《VC++獲取屏幕大小第三篇物理大小GetDeviceCaps下》將介紹獲取屏幕的物理大小后計算屏幕對角線長度,再換算成英寸。這樣可以方便大家查看自己電腦屏幕是多少英寸的,很多筆記本用戶會有意外喔^_^。歡迎繼續(xù)瀏覽。地址:http://blog.csdn.net/morewindows/article/details/8610891
?
轉(zhuǎn)載請標明出處,原文地址:http://blog.csdn.net/morewindows/article/details/8502592
歡迎關注微博:http://weibo.com/MoreWindows
?
Note: ?MSDN對GetDeviceCaps函數(shù)有說明: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, so GetDeviceCaps must always calculate the info.
?
總結(jié)
以上是生活随笔為你收集整理的VC++获取屏幕大小第二篇 物理大小GetDeviceCaps 上的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 闲置服务器 虚拟服务器,闲置主机搭建服务
- 下一篇: VC++获取屏幕大小第三篇 物理大小Ge