Solved

changing caption's font

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem with Frankling Gothic Book font 5 91
Set Font and Size on Excel Template 2 114
matchUp  challenge 9 110
Not needed 13 113
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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…

803 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