Solved

changing caption's font

Posted on 1997-08-07
3
539 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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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…
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…

623 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