Fonts in static controls

From: David Webber (dave_at_musical.demon.co.uk)
Date: 12/10/04


Date: Fri, 10 Dec 2004 10:31:29 -0000

I am having difficulty setting the font in a static control in a
dialogue.

I have a LOGFONT from which I do CFont::CreateFontIndirect (and
preserve the CFont for the lifetime of the dialogue), and then use
CWnd::SetFont() on the control from within OnInitDialog().

The face and size of the font appear as directed, but I am always
getting the default character set (in my case ANSI_CHARSET) instead
of the one set in the LOGFONT (which in this case is
EASTEUROPE_CHARSET).

The EASTEUROPE_CHARSET is obtained very nicely from the same LOGFONT
when I construct a Font for DrawText in my application's document
window.

Any ideas how to get the desired character set in the static
control?

I think that people with EASTEUROPE_CHARSET as default always see
that, even if the LOGFONT is western, (I'm looking into it) so it
looks like Windows is overriding the character set with the local(e)
default?

[Context: my application is an old-fashioned non-unicode application
and the above happens under XP (though I suspect it may also happen
under win98).]

Dave

-- 
David Webber
Author MOZART the music processor for Windows - 
http://www.mozart.co.uk
For discussion/support see 
http://www.mozart.co.uk/mzusers/mailinglist.htm


Relevant Pages

  • Re: Problem setting FontSize in CTreeCtrl
    ... a CTreeCtrl object. ... LOGFONT lf; ... and the font is destroyed. ... the control is dstroyed, so you must add code that will retrieve the font and destroy it ...
    (microsoft.public.vc.mfc)
  • Re: Need critical input on this
    ... pointer variable. ... that the TYPE of the expression must be LOGFONT*. ... saved your excellent bit result example with my font reference code. ... Again I will store this entire reply in my reference folder and I ...
    (microsoft.public.vc.mfc)
  • Re: Need critical input on this
    ... I looked on the net for changing a font in a resource control had stuff ... Then I created a Listbox in the resource editor ... // Declare old LOGFONT to save just in case I needed it later ...
    (microsoft.public.vc.mfc)
  • Re: Font question
    ... I use lf to initialize a CHOOSEFONT struct for ChooseFont. ... it's initialized with "Courier New" size 12. ... CreateFont(), that will later correspond to the "Size" shown in the font ... LOGFONT that is returned is the LOGFONT used to create the font. ...
    (microsoft.public.vc.language)
  • Re: Font is too thin
    ... Just create your own font by calling CreateFontIndirectwith a properly ... configured LOGFONT. ... The below WTL example shows how to create a normal and a bold 8pt Tahoma ... HDC hDC = GetDC; ...
    (microsoft.public.pocketpc.developer)