我不确定我做错了什么。我的基于 CDialog 的 MFC 应用程序中有一个功能可以增加一些常用控件中的字体。这是通过向他们发送带有较大字体的WM_SETFONT消息来完成的:
//No error checks for brevity
HFONT hFnt = (HFONT)::SendMessage(hCtrlWnd, WM_GETFONT, 0, 0);
LOGFONT lfFont;
::GetObject(hFnt, sizeof(lfFont), &lfFont);
BOOL bPositive = lfFont.lfHeight >= 0;
long nFontSz = abs(lfFont.lfHeight);
nFontSz += nFontDelta;
lfFont.lfHeight = bPositive ? nFontSz : -nFontSz;
HFONT hNewFont = ::CreateFontIndirect(&lfFont);
::SendMessage(hCtrlWnd, WM_SETFONT, (WPARAM)hNewFont, TRUE);
//Need to DeleteObject hNewFont when control gets a new font or is destroyed
这适用于大多数控件,除了 DateTime 选择器(或者更准确地说,它的月历SysMonthCal32
窗口类。)
这是 Windows XP 上的屏幕截图,它可以按预期工作:
正常放大倍率:
放大:
但这是我在 Windows 10 上得到的正常放大倍数:
并且(应该是)放大,但不是:
那么为什么它在 XP 上工作并停止,从 Vista 开始呢?