From: Harry "harry dot news at armadillo dot on
Hi,

While converting an application from Windows API to wx, I'm encountering
a problem
matching exactly the fonts of controls for compatibility with the
version the users are used to.

The quick-and-dirty solution would be to wrap up the Windows font
handles (HFONT) as wxFont.
Can this be done ? And how ?

Regards
Harry
From: Vadim Zeitlin on
On Thu, 24 Apr 2008 17:20:05 +0200 Harry <"harry dot news at armadillo dot fr"@riobu.com> wrote:

H> The quick-and-dirty solution would be to wrap up the Windows font
H> handles (HFONT) as wxFont.
H> Can this be done ? And how ?

By using wxFont::Create(wxNativeFontInfo, HFONT). wxNativeFontInfo itself
can be obtained from LOGFONT, i.e. something like this should work
(warning, this code is completely untested and does no error checking):

// create a wxFont from the given HFONT, taking ownership of it
wxFont CreateFontFromHFONT(HFONT hfont)
{
LOGFONT lf;
::GetObject(hfont, sizeof(lf), &lf);
wxFont font;
font.Create(wxNativeFontInfo(lf), hfont);
return font;
}

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/