Click here to Skip to main content
15,881,559 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.1K   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

 
Questionhow to change the background of menubar and status bar Pin
BlrBoy26-Jun-07 0:58
BlrBoy26-Jun-07 0:58 
Generalgod example, but many gdi leaks! (solution inside) Pin
CodeFlatter22-Oct-05 6:02
CodeFlatter22-Oct-05 6:02 
QuestionCan you update the code with all bugfixes Pin
tim63510-Jul-05 22:45
tim63510-Jul-05 22:45 
AnswerRe: Can you update the code with all bugfixes Pin
Anonymous11-Jul-05 15:20
Anonymous11-Jul-05 15:20 
Generalgod job!! suggest use uskin-- another personal free skin lib Pin
thirdwolf26-Jun-05 17:39
thirdwolf26-Jun-05 17:39 
GeneralSystem Menu Pin
feeeto30-Mar-05 22:30
feeeto30-Mar-05 22:30 
QuestionHow to change the color of the caption bar with win32 API Pin
njdibfm20-Jan-05 18:23
njdibfm20-Jan-05 18:23 
GeneralChildFrame caption Cancel (X) button on PocketPC Pin
Mike Landis18-Jan-05 11:37
Mike Landis18-Jan-05 11:37 
GeneralAnother ugly bug Pin
Yacine9500029-Jul-04 5:12
Yacine9500029-Jul-04 5:12 
GeneralRe: Another ugly bug Pin
Anonymous31-May-05 19:09
Anonymous31-May-05 19:09 
GeneralCDialog with a round rect Pin
Anonymous11-Jun-03 4:36
Anonymous11-Jun-03 4:36 
GeneralCDialog with a round rect Pin
Anonymous11-Jun-03 4:36
Anonymous11-Jun-03 4:36 
Generalreally cool Pin
Raphael Amorim11-Feb-03 10:55
professionalRaphael Amorim11-Feb-03 10:55 
GeneralAnother way for skinnable SDI/MDI/Dialog application Pin
jedyking22-Jan-03 6:31
jedyking22-Jan-03 6:31 
GeneralRe: Another way for skinnable SDI/MDI/Dialog application Pin
-wolfy-17-Mar-03 12:15
-wolfy-17-Mar-03 12:15 
GeneralRe: Another way for skinnable SDI/MDI/Dialog application Pin
Calder19-Jan-04 9:48
Calder19-Jan-04 9:48 
GeneralRe: Another way for skinnable SDI/MDI/Dialog application Pin
TrungHuynh1-Jun-04 21:28
TrungHuynh1-Jun-04 21:28 
Generalalmost compiles but... Pin
m1k3d3s22-Jan-03 5:45
m1k3d3s22-Jan-03 5:45 
GeneralRe: almost compiles but... Pin
Anonymous11-Feb-03 23:58
Anonymous11-Feb-03 23:58 
Generalpls let me know Pin
Member 14594726-Dec-02 18:53
Member 14594726-Dec-02 18:53 
How to change the color of the title bars of dialog box in sdi application
Blush | :O
GeneralGod job.but.... Pin
xipeng10-Nov-02 20:47
xipeng10-Nov-02 20:47 
GeneralRe: God job.but.... Pin
Anonymous10-Nov-02 22:06
Anonymous10-Nov-02 22:06 
GeneralRe: God job.but.... Pin
xipeng11-Nov-02 3:35
xipeng11-Nov-02 3:35 
GeneralMemory leaks! Pin
dicker18-Aug-02 23:42
dicker18-Aug-02 23:42 
GeneralRe: Memory leaks! Pin
Sam.Liang21-May-04 1:53
Sam.Liang21-May-04 1:53 

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.