Thread: Setting Fonts for all of the window object

  1. #1
    Registered User
    Join Date
    Aug 2001
    Location
    Fort Worth, TX
    Posts
    53

    Setting Fonts for all of the window object

    I am trying to set the faunt for the buttons and labels on the scrren. I am using CreateWindow and using CreateWindow for buttons.

    SelectObject(GetDC(hwnd),(HFONT) GetStockObject(ANSI_VAR_FONT));

    How can I get the FONT to set and stay set????

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Use SendMessage to send a WM_SETFONT for each control. If you've got a lot of controls and the font is the same for each one, an EnumChildProc is useful:
    Code:
    BOOL CALLBACK SetChildFonts(HWND hControl,LPARAM lParam)
    {
    SendMessage(hControl,WM_SETFONT,lParam,MAKELPARAM(1,0));
    }
    and invoke it with EnumChildWindows from, for example, the parent's WM_CREATE handler:
    Code:
    case WM_CREATE:
      {
      EnumChildWindows(hwnd,SetChildFonts, (LPARAM)GetStockObject(ANSI_VAR_FONT));
      }
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adding buttons, edit boxes, etc to the window
    By rainmanddw in forum Windows Programming
    Replies: 1
    Last Post: 04-10-2006, 03:07 PM
  2. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 04:33 PM
  3. Problem with creating new window, from another window
    By Garfield in forum Windows Programming
    Replies: 6
    Last Post: 01-11-2004, 02:10 PM
  4. MFC :: Finding Child Window of a CWnd* Object?
    By SyntaxBubble in forum Windows Programming
    Replies: 2
    Last Post: 09-06-2003, 09:06 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM