5

What is the Win32 API call to determine the system-wide font (in particular the color) for say Menus.

This would be equivalent to going into Appearance Settings - Advanced - and then choosing Menu as the item to look at.

I can use GetSysColor to find the colors of various system-wide window elements, but cannot find the equivalent for fonts.

zadam
  • 2,416
  • 2
  • 23
  • 32

3 Answers3

6

You can use SystemParametersInfo to find these fonts:

SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ...) returns a NONCLIENTMETRICS structure containing LOGFONT structures for:

  • lfCaptionFont -- font used for both "Active Title Bar" and "Inactive Title Bar"
  • lfSmCaptionFont -- font used for small title bars, "Palette Title"
  • lfMenuFont -- font used in menu bars.
  • lfStatusFont -- font used in status bars and tooltips
  • lfMessageFont -- font used in message boxes.

SystemParametersInfo(SPI_GETICONTITLELOGFONT, ...) returns a LOGFONT structure for the text accompanying icons.


In C# / .NET you can use the System.Drawing.SystemFonts class (WinForms) or the System.Windows.SystemFonts class (WPF).

Community
  • 1
  • 1
CodesInChaos
  • 106,488
  • 23
  • 218
  • 262
3

GetSysColor(COLOR_MENUTEXT) gives you the menu font colour.

SystemParametersInfo Will allow you to recover some font information, likewise GetStockObject for drawing on the device context.

But the system font is (probably) either Tahoma (on XP/W2K) or MS Sans Serif depending on how you set up your Dialog.

See http://blogs.msdn.com/oldnewthing/archive/2005/02/04/366987.aspx for more.

David L Morris
  • 1,461
  • 1
  • 12
  • 19
  • `SPI_GETNONCLIENTMETRICS` and `SPI_GETICONTITLELOGFONT` seem to be the relevant keys to pass to `SystemParametersInfo` – CodesInChaos Feb 11 '16 at 11:30
0

In C#, there's Control.DefaultFont, and for native access, this blog describes the win32 API call for getting it. The API call is SystemParametersInfo().

Phil Reif
  • 386
  • 1
  • 8