Solved

changing caption's font

Posted on 1997-08-07
3
529 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
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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…

772 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

11 Experts available now in Live!

Get 1:1 Help Now