Solved

Win32 VC++: Multiple Fonts in One Dialog?

Posted on 1997-06-22
4
317 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maze travler 6 55
how not to pass environment to child process by using ShellExecute or ShellExecuteEx 16 114
c++ syntax question 9 48
Least Squares Curve Fitting 4 77
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

776 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