Solved

Setting font in GroupBox

Posted on 2013-11-01
10
128 Views
Last Modified: 2015-05-17
The code below used to work in VC++ v6.0. It has stopped working in VS2010, Win 8.
The idea is to set the font of all the controls in a dialog box at runtime.  The code works below works exactly as expected EXCEPT that the font in the group box controls is not changed.  I suppose I could try sub classing  the group boxes but I would rather do something easier.   Don't feel bad, I don't really expect to get a solution here ...

This code is in the OnInitDialog() function:
	CWnd* pChildWnd = GetWindow(GW_CHILD);
	int iCount = 0;
	while (pChildWnd)
	{
		CString sTest;
		iCount ++;
		sTest.Format("control %d",iCount);

		pChildWnd->SetWindowText(sTest);
		pChildWnd->SetFont(m_pfont);
		pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT);
	}

Open in new window

0
Comment
Question by:Hey_Bud
  • 3
  • 2
10 Comments
 

Accepted Solution

by:
Hey_Bud earned 0 total points
Comment Utility
Solved!

The dialog box was not derived from CDialog,  but from a third party dialog class which apparently does not work "exactly" as expected.  If the dialog box is derived from CDialog, everything works as expected.

Thank you ...
0
 
LVL 32

Expert Comment

by:sarabande
Comment Utility
are you using id numbers for the group boxes? or do they have IDC_STATIC as id?

if the latter you may try to change that.

in your test, does the text of the group boxes change by the call of SetWindowText?

if no, the text label of a group box probably has changed to a child window of the group box control. if so, you would need to have a further loop for each control to get their child windows as well. this nested loop also would help to set the font of combo boxes both for the edit and the list part.

Sara
0
 

Author Comment

by:Hey_Bud
Comment Utility
I said:
"The code works below works exactly as expected"

If each dialog item did not have a unique ID, this would not have happened.


"the text label of a group box probably has changed to a child window of the group box "

Really?
Good Grief!

I  have indicated what was wrong above.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 32

Expert Comment

by:sarabande
Comment Utility
"If the dialog box is derived from CDialog, everything works as expected."

sorry I missed that comment.

the text label of a group box probably has changed to a child window of the group box
Really?
Good Grief!
hmm. it was a guess as you stated that the groupbox control doesn't accept a new font for the control. the change you made by deriving from CDialog instead of  a 3rd-party dialog, does not explain why your original code did not work for group boxes. the control would apply the new font if it was a CGroupbox or was derived from CGroupBox beside they added an own paint function or the text part was a child window or they restored the old font after your function. you probably can see with spy what happened.

Sara
0
 

Author Comment

by:Hey_Bud
Comment Utility
I have contacted the third party vendor.  They  have admitted this bug and sent a fix.  I have no further need to pursue this matter.
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
@Hey_Bud

Please accept your comment: http:#a39625094 as the solution.

aikimark -- zone advisor
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now