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...