Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

changing caption's font

Posted on 1997-08-07
3
Medium Priority
?
540 Views
Last Modified: 2013-12-03
Hi,
I'm creating an MDI application and I'd like to change the caption's font of my Child Frame.
I tried to call SystemParametersInfo from various message handlers (OnCreate, OnNcPaint, OnActivate, OnShowWindow, OnNcActivate, OnPaint) but it doesn't seems to work - nothing happens!
Where have I to put SystemParametersInfo in order to properly change the caption's font?
Is it possible to do that in some other ways?

Many thanks in advance!
0
Comment
Question by:vencese
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
ID: 1303316
The following code is used to change current caption font to be italic. You only need to call it once.

NONCLIENTMETRICS noncmt = { sizeof(NONCLIENTMETRICS) };
if (::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &noncmt, 0))
{
    noncmt.lfCaptionFont.lfItalic = TRUE;
    ::SystemParametersInfo(SPI_SETNONCLIENTMETRICS, 0, &noncmt,
                           SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
}

But, this will change the caption font globally, which means all the windows will be affected. If you would like to change only your child frame, you have to override OnNcPaint to draw the nonclient area yourself. It is not trivial.
0
 

Author Comment

by:vencese
ID: 1303317
I'd like to override OnNcPaint in order to have a frame with
a border, a caption, a minimize box and a maximize box.
I'll increase points to 200.
Can you send me the code to do that?
(if you need more points, I will give you)

Many thanks for your help!

0
 
LVL 23

Expert Comment

by:chensu
ID: 1303318
You can see MFC source code for good examples of how to override OnNcPaint(). The following files contain the code. CMiniFrameWnd::OnNcPaint() is specially useful for you.

mfc\src\BARCORE.CPP : void CControlBar::EraseNonClient()
mfc\src\BARDOCK.CPP : void CDockBar::OnNcPaint()
mfc\src\BARSTAT.CPP : void CStatusBar::OnNcPaint()
mfc\src\BARTOOL.CPP : void CToolBar::OnNcPaint()
mfc\src\CTLTRACK.CPP : void COleControl::OnNcPaint()
mfc\src\WINMINI.CPP : void CMiniFrameWnd::OnNcPaint()

Thank you for your generous offering. Add a comment here if you encounter any problems when you go ahead with the code, I might be able to help you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
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…
Suggested Courses

715 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