Objective Toolkit : Chapter 15 User Interface Extensions : Gradient Caption Extension
Gradient Caption Extension
The gradient caption extension provides a simple emulation of the smooth gradient caption effects introduced in Microsoft Office for Windows 95. The extension also allows you to control the alignment of caption text.
NOTE >> In order to match the Windows XP look and feel in a themed application, gradient caption extension will be automatically disabled if running under Windows XP and hosting application is themed.
Figure 116 – Example Application with the Gradient Caption
The Gradient Caption Classes
The gradient caption feature is incorporated into the existing SECFrameWnd and SECMDIFrameWnd.
Figure 117 – Objective Toolkit Gradient Frame Class Hierarchy
SECFrameWnd
The SECFrameWnd class derives from CFrameWnd and adds support for the gradient caption. The class also adds support for extended docking windows.
SECMDIFrameWnd
The SECMDIFrameWnd class derives from CMDIFrameWnd and adds support for the gradient caption and extended docking window features.
Using the Gradient Caption Feature
To incorporate the gradient caption into your application:
1. Change the base class of your main frame window class, which is usually CMainFrame. If you’re working with an MDI application, replace the base class (CMDIFrameWnd) with SECMDIFrameWnd. If you’re working with an SDI application, replace the base class (CFrameWnd) with SECFrameWnd.
2. Enable the gradient caption by calling EnableCustomCaption() from your frame window’s OnCreate() member.
 
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
 
// Enable the gradient caption feature.
EnableCustomCaption(TRUE);
 
return 0;
}
To change the font of the caption text:
1. Derive a class from either SECMDIFrameWnd or SECFrameWnd. See the preceding procedure for more information.
2. Override the CreateCaptionAppFont() method or the CreateCaptionDocFont() method or both. For example, the code below shows how to italicize the document font.
 
void CMyFrameWnd::CreateCaptionDocFont(CFont& font)
{
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(ncm);
VERIFY(SystemParametersInfo(
SPI_GETNONCLIENTMETRICS,
0, &ncm, 0));
ncm.lfCaptionFont.lfItalic = TRUE;
font.CreateFontIndirect(&ncm.lfCaptionFont);
}