Changing font size of CStatic

This is a discussion on Changing font size of CStatic within the Windows Programming forums, part of the Platform Specific Boards category; How do I change the size of the font in my dynamically created CStatic? Here's the call to create: Code: ...

  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,255
    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, 04:32 PM
  5. changing edit control font
    By bennyandthejets in forum Windows Programming
    Replies: 6
    Last Post: 12-22-2002, 02:17 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21