Setting Fonts for all of the window object

This is a discussion on Setting Fonts for all of the window object within the Windows Programming forums, part of the Platform Specific Boards category; I am trying to set the faunt for the buttons and labels on the scrren. I am using CreateWindow and ...

  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, 04:07 PM
  2. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 05: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, 10:06 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM

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