获取系统的DPI设置

来源:互联网 发布:狄念和知礼婚后的故事 编辑:程序博客网 时间:2024/04/28 17:42

在Measure控件的宽度的时候,有时候需要考虑DPI的缩放,一个简单的函数调用就可以解决:GetDeviceCaps()会返回当前的DPI值,一般是96,Win7下面设置为125%,就变成了120。


// Use "A" to measure the hint list width. "M" is too long and displayText// can be too short, see DID#1482150. And we also need to take DPI into// consider.m_textWidthMax = dc.GetTextExtent(displayText, displayText.GetLength()).cx + 2;m_textWidthMax *= (dc.GetDeviceCaps(LOGPIXELSX)/96);