You are on page 1of 1

Here's how to get the handle for the windows System Font, hSysFont := GetStockObject(SYSTEM_FONT); the font used

in the Taskbar is the active Caption Font and you can get the Font Log for that font from the NonClientMetrics returned with the SystemParametersIn fo function. Here is a procedure I have used to get a few of the windows fonts procedure GetSystemFonts; var NonClMetrics: TNonClientMetrics; TempLogF: TLogFont; CaptionFont, MenuFont, MessFont, IconFont, StatusFont: THandle; CapFontHeight: Integer; CapFontName: String; begin NonClMetrics.cbSize := SizeOf(NonClMetrics); SystemParametersInfo( SPI_GETNONCLIENTMETRICS, // system parameter to query or set 0, @NonClMetrics, // address of NonClientMetrics 0 ); {The SystemParametersInfo function queries or sets systemwide parameters with SPI_GETNONCLIENTMETRICS you get the metrics associated with the standard nonclient area of windows.} CaptionFont := CreateFontIndirect(NonClMetrics.lfCaptionFont); CapFontName := String(NonClMetrics.lfCaptionFont.lfFaceName); CapFontHeight := NonClMetrics.lfCaptionFont.lfHeight; MenuFont := CreateFontIndirect(NonClMetrics.lfMenuFont); StatusFont := CreateFontIndirect(NonClMetrics.lfStatusFont); MessFont := CreateFontIndirect(NonClMetrics.lfMessageFont); {see API help for index NONCLIENTMETRICS, to see other info in NonClMetrics} SystemParametersInfo(SPI_GETICONTITLELOGFONT,SizeOf(TempLogF),@TempLogF,0); {this gets the font used under icons} IconFont := CreateFontIndirect(TempLogF); end; if you want to use these font handles as delphi fonts you can do a handle assign ment Edit1.Font.Handle := CaptionFont; or Form1.Canvas.Font.Handle := CaptionFont; you should DeleteObject when you are finished with the fonts DeleteObject(CaptionFont); DeleteObject(MenuFont); ask questions if it's unclear

You might also like