Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:19:55+00:00 2026-06-05T19:19:55+00:00

I have problems with creating a simple Group-Box-Control via CreateWindowEx. The font-size/-style of its

  • 0

I have problems with creating a simple Group-Box-Control via CreateWindowEx. The font-size/-style of its caption just doesn’t look right.

I have created a simple Windows Dialog (containing group-boxes, buttons…) with the Visual Studio – Resource Manager. When I load that dialog with DialogBox(…) everything looks normal but when I create another group-box-control on that same dialog via CreateWindowEx(…) the caption of the new control has a different font-size/-style.

With Microsoft Spy++ I was able to see the dwExStyle and dwStyle values of the other groub-boxes, but even when I use the same values in CreateWindowEx I still get a different look.

Here is the code I use to create the new group-box:

HWND hGroup1 = GetDlgItem(_hWnd, IDC_GROUPBOX1);
HWND hGroup2 = CreateWindowEx(            
    WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_NOPARENTNOTIFY,
    L"Button",
    L"Hallo",
    WS_CHILDWINDOW | WS_VISIBLE | BS_GROUPBOX,
    20, 20, 250, 250,
    hGroup1,
    nullptr,
    _hInstance,
    nullptr);

Here is a screen capture of the dialog:

http://imageshack.us/photo/my-images/856/groupboxfontissue.png/

Please let me know where I went wrong and what I can do to fix it.

[EDIT-1]

In regards to Jonathan Potter and Superman, as you suggested I set the font-handle of the new group-box to the same as for the other controls.

HFONT hFont1 = (HFONT)SendMessage(hGroup1, WM_GETFONT, 0, 0); 
HFONT hFont2 = (HFONT)SendMessage(hGroup2, WM_GETFONT, 0, 0);
HFONT hFont3 = (HFONT)SendMessage(_hWnd, WM_GETFONT, 0, 0);
SendMessage(hGroup2, WM_SETFONT, (WPARAM)hFont1, TRUE);

hFont2 = (HFONT)SendMessage(hGroup2, WM_GETFONT, 0, 0);

At the end of this code, I can see that all controls and the dialog window have the same font-handle but only the controls which were created with the Resource Manager have the correct font (which is the system font).

Is there anything else I can do???

[EDIT-2]

I cannot believe it… it works now! Thank you all very much for your help!

I just had to set the hWndParent value in CreateWindowEx(…) to the dialog handle and then use WM_GETFONT and WM_SETFONT to copy the right font.

I wish you all a nice weekend.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:19:56+00:00Added an answer on June 5, 2026 at 7:19 pm

    Controls you create manually (via CreateWindowEx) do not get their font set automatically, and will default to the “system font” (which is what you see in your screenshot). Instead, you need to set the control’s font once it has been created. For example,

    SendMessage(hGroup2, WM_SETFONT, (WPARAM)SendMessage(hGroup1, WM_GETFONT, 0, 0), TRUE);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having big problems while creating a simple program in C. I have the
I have problem with creating a simple MySQL trigger in C#. I'm using StringBuilder
I have been having problems with creating a download list of files for a
I'm creating an application and I have problems with Cursor . I have an
I am creating a simple game database and I am having some problems. There
I have problems creating a ruby extension to export a C++ library I wrote
So I am creating a simple server test on my Centos 5.x box and
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have a problem creating a std::map<int, int> from a vector of pointers, called
I have a problem creating the following SQL Statement using LINQ & C# select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.