By default in MFC, the font of the dialog\'s title bar is in correspondence with the system settings. How can I change the font style?
This is not just an MFC default; it works that way for all Windows applications. That's because the operating system draws the title bar for all windows, and naturally the operating system respects the settings that the user has configured.
If you want to change that and override the user's settings (and I really question why you would want to do such a thing), then you will need to take the drawing of the window's entire non-client area (which includes the title bar) into your own hands. This is achieved by handling the WM_NCPAINT message (or I suppose in MFC, handling a member function of your window named something like OnWmNcPaint
).
But be forewarned: this is a fairly advanced task, and difficult to get right. Additionally, it will break the glass styling and other translucent effects of the Aero theme. I have no idea what it does on Windows 8 since I haven't tried it yet, but I imagine it breaks things there, too.
To make it work properly with the Aero theme, you will need to detect at runtime whether Aero is enabled, and if it is, jump through some additional hoops. If the Aero theme is not enabled, then you fall back to the old method of handling the WM_NCPAINT
message.
Did I mention that I don't recommend this? There's a reason that this is a global system setting, not something intended to be overridden by applications. If the user wants to use an ugly font in their title bars, then that is their prerogative.