Thread: Changing font size of CStatic

  1. #1
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257

    Changing font size of CStatic

    How do I change the size of the font in my dynamically created CStatic?

    Here's the call to create:
    Code:
    myStaticf[i]->Create(_T(Param[i]), WS_CHILD|WS_VISIBLE|SS_CENTER,
    			CRect(x1,y,x2,y+h), this);
    Everything is relative...

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    I'm not too familiar with MFC (hawk, spit ), but flicking through MSDN, CStatic inherits SetFont from its CWnd base class. Assuming you have a HFONT lined up and called hfont:-
    Code:
    myStaticf[i]->SetFont(CFont::FromHandle(hfont), TRUE);
    To change its size, you would have to use GetFont to get a CFont, then play with it a bit before SetFont.

  3. #3
    Registered User
    Join Date
    May 2005
    Location
    Toronto, Canada
    Posts
    257
    I actually just decreased the size of the field and the text shrunk to fit it. ie:
    Code:
    myStaticf[i]->Create(_T(Param[i]), WS_CHILD|WS_VISIBLE|SS_CENTER,
    			CRect(x1,y,x2,y+h), this);
    change h from 20 to 15, the text fit in it...
    Everything is relative...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 01:30 PM
  2. How to Change Text File Font Size
    By space in forum Windows Programming
    Replies: 3
    Last Post: 08-07-2006, 11:42 PM
  3. An exercise in optimization
    By Prelude in forum Contests Board
    Replies: 10
    Last Post: 04-29-2005, 03:06 PM
  4. The relation between Font Size & Dialog Units
    By Templario in forum Windows Programming
    Replies: 4
    Last Post: 02-27-2003, 05:32 PM
  5. changing edit control font
    By bennyandthejets in forum Windows Programming
    Replies: 6
    Last Post: 12-22-2002, 03:17 AM