Solved

Win32 VC++: Multiple Fonts in One Dialog?

Posted on 1997-06-22
4
316 Views
Last Modified: 2013-12-03
Hello.

Using VC++ 5.0 and MFC, I am trying to create a dialog
which will be able to display one text field in a large
font and the rest of the fields and buttons in a normal,
smaller font. So far, I have only been able to do this with
a splitter view, but I would like to know how it can be
done in a single dialog or form view. The basic problem is
that the font attribute is attached to the entire dialog
and not to specific fields contained within.

Please let me know how I can create one dialog with fields
in different fonts without using a splitter view.

Thanks.
0
Comment
Question by:FNORD0
  • 2
4 Comments
 

Author Comment

by:FNORD0
Comment Utility
Edited text of question
0
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
Comment Utility
You can create some Static Controls with different fonts in the dialog box.

BOOL CYourDialog::OnInitDialog()
{
    ...
    // m_font is a member variable of CYourDialog
    m_font.CreatePointFont(12, "Arial");
    CWnd *pStatic = this->GetDlgItem(ID_STATIC1);
    pStatic->SetFont(&m_font);
    ...
}

You can also use this method to change the font of the buttons.

You can even change the color of the static controls. See MFC Technical Notes: TN062: Message Reflection for Windows Controls.
0
 

Author Comment

by:FNORD0
Comment Utility
Great answer. I'm going to try that right now. Thanks!
0
 

Expert Comment

by:Jeffrey1
Comment Utility
This works great!  If you are looking at how to change the font in a contol on your dialog, look no more.  This is clean, simple, and it works.

One thing, though; the first parameter in CreatePointFont() is in tenths of a point.  In the above example, to get 12 point, you would need a value of 120.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

762 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

10 Experts available now in Live!

Get 1:1 Help Now