Solved

changing caption's font

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
Adobe Acrobat Pro: how to copy style? 2 139
Dell Alienware Graphics Amplifier Driver for non-Alienware systems 18 664
True Type Font Files? 4 122
Numbers in fonts funny displayed... 11 51
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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…

752 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