How to get a system font ?

  • Thread starter Thread starter Herve Bocuse
  • Start date Start date
H

Herve Bocuse

Hi,

In C++ I was used to this code to get a GUI system font :

LOGFONT lf;
::SystemParametersInfo(SPI_GETICONTITLELOGFONT,sizeof(LOGFONT),&lf,0);
HFONT hFont = ::CreateFontIndirect(&lf);

How can I get such a font in C# ?

Thank you

Herve
 
Herve,

You can use the same API calls to get the handle to the font in .NET
(through the P/Invoke layer). Once you do that, you can create a Font
object by calling the static FromHfont method on the Font class, passing the
handle to the font.

Hope this helps.
 
Back
Top