Solved

Win32 VC++: Multiple Fonts in One Dialog?

Posted on 1997-06-22
4
319 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
ID: 1164016
Edited text of question
0
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
ID: 1164017
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
ID: 1164018
Great answer. I'm going to try that right now. Thanks!
0
 

Expert Comment

by:Jeffrey1
ID: 2701922
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

839 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