Click here to Skip to main content
15,890,399 members
Articles / Desktop Programming / MFC

Customized Skinned Caption for MDI

Rate me:
Please Sign up or sign in to vote.
3.09/5 (19 votes)
16 Jun 20022 min read 580.8K   5.1K   82   43
Make your customized skinned caption bar for MDI

Sample Image - CustomCaptionMDI.gif

Introduction

For all those who want to customize the caption bars in their applications, here is the solution. This is the first stage of my effort in this direction, so the code here is not of very good quality. I feel there is room for improvements and changes. Please feel free to write back to me if you find any bugs.

The demo project contains two classes to customize your caption bar. The first class is named CBeeChildFrame and will allow you to customize the caption bar for child frames and CBeeMainFrame lets you customize the main frame window.

It's very easy to implement the classes. You just have to specify the skin images for the caption bar's active and inactive states and the colors of the bar. (I'm looking for a better way to stretch the images so that I can get rid off the colors.)

So download and enjoy. All the best!!!

How to Skin the Caption Bars?

It's very easy to implement caption bar classes. After you have included the images for the active and inactive states of the caption bar and the images for close, minimise, maximise and restore buttons (you will get the best results if you have images for mouse over, inactive and normal states of the buttons) and have included the files of both classes, i.e., CBeeChildFrame and CBeeMainFrame, just add the following code to the constructor of your child frame class to skin the caption bar:

C++
CChildFrame::CChildFrame()
{
    SetTitleImages(IDB_ACTIVE,IDB_INACTIVE);
    SetTitleFontColor(RGB(255,171,197));
    AddCloseButton(IDB_CLOSE_UP,IDB_CLOSE_DN,
                       IDB_CLOSE_UP_GR,IDB_CLOSE_UP_GR);
    AddMaximizeButton(IDB_MAX_UP,IDB_MAX_DN_GR,
                           IDB_MAX_UP_GR,IDB_MAX_DN_GR);
    AddMinimiseButton(IDB_MIN_UP,IDB_MIN_DN,
                           IDB_MIN_UP_GR,IDB_MIN_DN_GR);
    AddRestoreButton(IDB_RESTORE_UP,IDB_RESTORE_DN,
                   IDB_RESTORE_UP_GR,IDB_RESTORE_DN_GR);
    SetActiveWindowGradient(RGB(1,76,133),
                                      RGB(146,164,176));
    SetInactiveWindowGradient(RGB(122,122,122),
                                      RGB(250,250,250));
}

and add the following to skin the caption bar of your main frame:

C++
CMainFrame::CMainFrame()
{
    SetTitleImages(IDB_ACTIVE,IDB_INACTIVE);
    SetTitleFontColor(RGB(255,171,197));
    AddCloseButton(IDB_CLOSE_UP,IDB_CLOSE_DN,
                       IDB_CLOSE_UP_GR,IDB_CLOSE_UP_GR);
    AddMaximizeButton(IDB_MAX_UP,IDB_MAX_DN_GR,
                           IDB_MAX_UP_GR,IDB_MAX_DN_GR);
    AddMinimiseButton(IDB_MIN_UP,IDB_MIN_DN,
                           IDB_MIN_UP_GR,IDB_MIN_DN_GR);
    AddRestoreButton(IDB_RESTORE_UP,IDB_RESTORE_DN,
                   IDB_RESTORE_UP_GR,IDB_RESTORE_DN_GR);
    SetActiveWindowGradient(RGB(1,76,133),
                                      RGB(146,164,176));
    SetInactiveWindowGradient(RGB(122,122,122),
                                      RGB(250,250,250));
}

Now all is done. You have skinned the caption bars in your MDI applications.
Now since this is my first article on Code Project and it's very late at night, I'll explain this article in a couple of days, so please send me your feedback about the demo project.

Revision History

  • 17th June, 2002 - Initial revision
  • 17th June, 2002 - Reformatted

License

This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below. A list of licenses authors might use can be found here.


Written By
Web Developer
Hong Kong Hong Kong
innovating, managing and developing next generation media products and services

Comments and Discussions

 
GeneralSize and XP Pin
26-Jun-02 6:28
suss26-Jun-02 6:28 
GeneralRe: Size and XP Pin
Takeru Koushirou7-Jul-02 6:51
Takeru Koushirou7-Jul-02 6:51 
GeneralRe: Size and XP Pin
Balkrishna Talele29-Dec-03 1:06
Balkrishna Talele29-Dec-03 1:06 
GeneralOne more ugly bug Pin
18-Jun-02 10:40
suss18-Jun-02 10:40 
GeneralRe: One more ugly bug Pin
23-Jun-02 18:52
suss23-Jun-02 18:52 
GeneralRe: One more ugly bug Pin
Takeru Koushirou7-Jul-02 6:48
Takeru Koushirou7-Jul-02 6:48 
GeneralRe: One more ugly bug Pin
Balkrishna Talele29-Dec-03 1:13
Balkrishna Talele29-Dec-03 1:13 
GeneralUgly bug Pin
18-Jun-02 10:36
suss18-Jun-02 10:36 
GeneralRe: Ugly bug Pin
Ashok Jaiswal23-Jun-02 19:02
Ashok Jaiswal23-Jun-02 19:02 
GeneralRe: Ugly bug Pin
Marcus Carey24-Mar-04 16:08
Marcus Carey24-Mar-04 16:08 
QuestionGood job!! but,Can this port to MFC Dialog application? Pin
phped17-Jun-02 18:20
phped17-Jun-02 18:20 
AnswerRe: Good job!! but,Can this port to MFC Dialog application? Pin
Ashok Jaiswal23-Jun-02 22:27
Ashok Jaiswal23-Jun-02 22:27 
GeneralReally Cool !!! But ... Pin
17-Jun-02 13:38
suss17-Jun-02 13:38 
GeneralRe: Really Cool !!! But ... Pin
Ashok Jaiswal23-Jun-02 19:06
Ashok Jaiswal23-Jun-02 19:06 
Generala simple solution is... Pin
sun_tzu2-Apr-03 13:57
sun_tzu2-Apr-03 13:57 
GeneralVery good Pin
Brian Delahunty17-Jun-02 5:59
Brian Delahunty17-Jun-02 5:59 
GeneralCool... Pin
Stefan Spenz17-Jun-02 2:25
Stefan Spenz17-Jun-02 2:25 
GeneralRe: Cool... Pin
Brian Delahunty17-Jun-02 5:58
Brian Delahunty17-Jun-02 5:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.