Alex Rivera | Logout

Can't detect when Windows Font Size has changed C++ MFC

Asked 2008-10-16T23:32:10.003
9

I'm trying to determine how I can detect when the user changes the Windows Font Size from Normal to Extra Large Fonts, the font size is selected by executing the following steps on a Windows XP machine:

  1. Right-click on the desktop and select Properties.
  2. Click on the Appearance Tab.
  3. Select the Font Size: Normal/Large Fonts/Extra Large Fonts

My understanding is that the font size change results in a DPI change, so here is what I've tried so far.


My Goal:

I want to detect when the Windows Font Size has changed from Normal to Large or Extra Large Fonts and take some actions based on that font size change. I assume that when the Windows Font Size changes, the DPI will also change (especially when the size is Extra Large Fonts


What I've tried so far:

I receive several messages including: WM_SETTINGCHANGE, WM_NCCALCSIZE, WM_NCPAINT, etc... but none of these messages are unique to the situation when the font size changes, in other words, when I receive the WM_SETTINGSCHANGE message I want to know what changed.

In theory when I define the OnSettingChange and Windows calls it, the lpszSection should tell me what the changing section is, and that works fine, but then I check the given section by calling SystemParametersInfo and I pass in the action SPI_GETNONCLIENTMETRICS, and I step through the debugger and I make sure that I watch the data in the returned NONCLIENTMETRICS for any font changes, but none occur.

Even if that didn't work, I should still be able to check the DPI when the Settings change. I really wouldn't care about the other details, every time I get the WM_SETTINGCHANGE message, I would just check the DPI and perform the actions I'm interested in performing, but I'm not able to get the system DPI either.

I have tried to get the DPI by invoking the method GetSystemMetrics, also for each DC:

Dekstop DC->GetDeviceCaps L

Edit
Report

1 Answer

1

See http://msdn.microsoft.com/en-us/library/ms701681(VS.85).aspx , this is explained there (quote: "If you do not cancel dpi scaling, this call returns the default value of 96 dpi.")

answered 2008-11-12T22:53:59.900

Your Answer