can wxFont be created from native handle ? (msw)

Vadim Zeitlin vadim at wxwidgets.org
Sat Apr 26 16:18:43 PDT 2008


On Fri, 25 Apr 2008 19:59:33 +0200 Harry <"harry dot news at armadillo dot fr"@riobu.com> wrote:

H> It almost works, except that wxNativeFontInfo has no constructor with 
H> LOGFONT.

 It does in trunk, with 2.8 you use default ctor and assign your LOGFONT to
its lf member.

H> I found an undocumented function in fontutil.cpp which I use as follows:
H> 
H> extern wxFont wxCreateFontFromLogFont(const LOGFONT *logFont);
H> 
H> wxFont CreateFontFromHFONT(HFONT hfont)
H> {
H>     LOGFONT   lf;
H>     ::GetObject(hfont, sizeof lf, &lf);
H>     return wxCreateFontFromLogFont(&lf);
H> }

 This is not at all the same because it creates _another_ HFONT. In
particular this one doesn't take ownership of the provided hfont whereas
the version I posted did.

 Regards,
VZ

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



More information about the wx-users mailing list