How to get a system font ?

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
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top