Font of Objects on Form

This is a discussion on Font of Objects on Form within the Windows Programming forums, part of the Platform Specific Boards category; I am very new to Windows GUI programming and am having an issue with setting the font on multiple controls. ...

  1. #1
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    398

    Font of Objects on Form

    I am very new to Windows GUI programming and am having an issue with setting the font on multiple controls. The code I currently have will correctly set the font I desire on my first button, but not on the second one.

    Code:
    //Create the button font
    hf = CreateFont(14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Courier New");
    
    //Create Open/Exit Buttons, User-Defined
    butOpen = CreateButton(hwnd, TEXT("Open"), 170, 10);
    butExit = CreateButton(hwnd, TEXT("Exit"), 170, 38);
    
    //Set the button font
    SendDlgItemMessageA(hwnd, GetDlgCtrlID(butOpen), WM_SETFONT, (WPARAM)hf, TRUE);
    SendDlgItemMessageA(hwnd, GetDlgCtrlID(butExit), WM_SETFONT, (WPARAM)hf, TRUE);
    
    //Show the form
    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);
    I will eventually need to add more so I definitely need this to work.

    Also on another note I have heard about an enumeration method of child controls, but have yet to find a good explanation. I would like someone to help me with the issue above, but I wouldn't mind some "pseudo-code" or a good explanation of how to enumerate child objects along with related functions in order to set the same font or same attributes to a list of controls.

    Thanks!

    Edit: Never mind. I decided to put them under the WM_CREATE event in WndProc and it fixed the error. Unsure why though...
    Last edited by carrotcake1029; 03-22-2009 at 08:02 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Set default font for all objects?
    By Dampy in forum Windows Programming
    Replies: 1
    Last Post: 05-31-2008, 05:57 PM
  2. problem with my font manager
    By hannibar in forum C Programming
    Replies: 1
    Last Post: 03-07-2006, 07:03 AM
  3. destroywindow() problem
    By algi in forum Windows Programming
    Replies: 6
    Last Post: 03-27-2005, 10:40 PM
  4. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 09:18 PM
  5. chain of objects within pop framework help needed
    By Davey in forum C++ Programming
    Replies: 0
    Last Post: 04-15-2004, 10:01 AM

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