How to detect Normal or Large font size settings (DPI)
来源:互联网 发布:淘宝人肉搜索服务 编辑:程序博客网 时间:2024/06/04 19:29
I created a script which uses a GUI, but I had a problem: if the user had the "Large Fonts" set in the Display settings, the GUI would present truncations all around.
Although AHK allows for auto-resize and auto-placement of GUI controls, I wanted to have full control of their exact position in the GUI.
After unsuccessful and/or confusing google searches, I found out that the actual font size is specified in a registry key:
msgbox, You are using normal font settings
else
msgbox, You are using LARGE font settings
exitapp
; This is the function:
; returns 0 if normal font size or 1 if LARGE font size
checkDPIsize()
{
RegRead, DPI_value, HKEY_CURRENT_USER, Control Panel\Desktop\WindowMetrics, AppliedDPI
if errorlevel=1 ; the reg key was not found - it means default settings
return 0
if DPI_value=96 ; 96 is the default font size setting
return 0
if DPI_value>96 ; A higher value should mean LARGE font size setting
return 1
}
By knowing whether the user is using normal or large fonts, I can act accordingly in the GUI definition section...
This works in Win2000 & WinXP, I don't know about earlier versions...
I though that it might be worth sharing, in case other AHKers were facing the same problem...
if checkDPIsize()=0
msgbox, You are using normal font settings
else
msgbox, You are using LARGE font settings
exitapp
; This is the function:
; returns 0 if normal font size or 1 if LARGE font size
checkDPIsize()
{
if A_OSVersion in WIN_95,WIN_98,WIN_ME ; check if old win32 OS
RegRead, DPI_value, HKEY_CURRENT_CONFIG, Display\Settings, DPILogicalX
; RegRead, DPI_value, HKEY_LOCAL_MACHINE, Config\0001\Display\Settings, DPILogicalX ; value is also stored here
else
RegRead, DPI_value, HKEY_CURRENT_USER, Control Panel\Desktop\WindowMetrics, AppliedDPI
if errorlevel=1 ; the reg key was not found - it means default settings
return 0
if DPI_value=96 ; 96 is the default font size setting
return 0
if DPI_value>96 ; A higher value should mean LARGE font size setting
return 1
}
- How to detect Normal or Large font size settings (DPI)
- Font size to large to fit in cache
- How To Find Large File Size On Linux
- How to change the font size in legend of matlab
- IDE - How to change font size in Eclipse
- How to reduce the font size of bibliography/reference
- Mozilla DPI-related Font Size Issues on Unix
- Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is rec
- Row size too large (> 8126). Changing some columns to TEXT or BLOB ...
- Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is rec
- Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is rec
- HttpClient警告“Going to buffer response body of large or unknown size. Using getResponseBodyAsStream i
- How to detect whether a module is managed code or not
- mysql Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMI
- How To Print a Form That Is Too Large for the Screen or Page
- How to use Scala on Spark to load data into Hbase/MapRDB -- normal load or bulk load.
- How to save brightness settings?
- How to read settings.db
- 最常被程序员们谎称读过的计算机书籍
- twisted的入门讲解(很不错)
- C# SQLSERVER 调用存储过程得id
- 【转】HTML代码实例:详细讲解超级链接
- PHP Pear Package 应用
- How to detect Normal or Large font size settings (DPI)
- java中判断一个字符串是否“都为数字”和“是否包含数字”和“截取数字”
- 挺漂亮的文字太长自动截断,鼠标移上显示全部信息例子
- OMAP4平台设置时钟频率
- linux下i2c接口的电容触摸屏驱动开发
- T-SQL技术收集——删除重复数据
- Cookie - Servlet,Struts中设置cookies Jsp页面接收取cookies
- 写出下面 C 函数的代码,它会返回一个无符号值,其中参数 x 的字节 i 被替换成字节 b
- Java加密技术(一)