Click here to Skip to main content
Licence 
First Posted 4 Oct 2006
Views 58,001
Bookmarked 57 times

Title Bar Replacement Class With Cool Features

By | 12 Oct 2006 | Article
Nice looking title bar for your applications with autohide and ghost-drag capabilities.

Sample Image - TBarDemo.gif

Introduction

This article describes an easy to use, drop-in MFC class which replaces the standard title bar.

Background

While creating an application with the Media Center 2005 look and feel, I noticed the title bar. I decided to recreate it and add it to one of my own ideas. I called it the "Ghost Drag". feature.

Environment

This project was built and tested on Windows 2000 and Windows XP using Visual Studio 6 SP5 and the Microsoft Platform SDK (Feb 2003).

Using the code


The TBar class can be easily added to your window/dialog with a few easy steps.

  1. Add "TBar.h" and "TBAR.cpp" to your project.
  2. Include  "TBar.h" in your main window/dialog class.
  3. Create a member variable of type CTBar.
  4. (Optional) Add caption button images to your project.
  5. In the window initialization, create and setup the new title bar:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    // ...
    // Remove default menu
    SetMenu(NULL);

    // Create new title bar
    m_TBar.Create(this, ID_TBAR);    

    // Caption images are optional
    m_TBar.SetCloseBtnUpBmp(IDB_CAP_CLOSE_UP);
    m_TBar.SetCloseBtnDownBmp(IDB_CAP_CLOSE_DN); 
    m_TBar.SetMaxBtnUpBmp(IDB_CAP_MAX_UP);
    m_TBar.SetMaxBtnDownBmp(IDB_CAP_MAX_DN);
    m_TBar.SetResBtnUpBmp(IDB_CAP_RES_UP); 
    m_TBar.SetResBtnDownBmp(IDB_CAP_RES_DN);
    m_TBar.SetMinBtnUpBmp(IDB_CAP_MIN_UP);
    m_TBar.SetMinBtnDownBmp(IDB_CAP_MIN_DN);

// ...

History

  • Oct 4th 2006 - Origional article.
  • Oct 6th 2006 - Bugs fixed / features added.
    • Double clicking (maximize/restore) added.
    • Disabled dragging while in maximized state.
    • Added VS2003 solution file (TBarDemo.sln).
  • Oct 11th 2006 - Bugs fixed / features added.
    • Fixed bug regarding pressing one of the buttons and releasing the mouse outside of the window and the flickering problem.
    • Added (by request) the ability to remove the close button.

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

About the Author

JJMatthews

Software Developer (Senior)

United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionMenu with SDI view problem. Pinmemberkimchi19:20 30 Jun '08  
QuestionHow to replace title bar in a dialog? Pinmemberkhutchinson10:43 18 Jan '08  
QuestionHow to use this in C#? PinmemberNgh5517:42 11 Aug '07  
AnswerRe: How to use this in C#? PinmemberJJMatthews14:37 12 Aug '07  
AnswerRe: How to use this in C#? PinmemberAlpha Nerd6:20 18 Apr '08  
GeneralRe: How to use this in C#? PinmemberJJMatthews4:31 21 Apr '08  
RantRe: How to use this in C#? PinmemberAlpha Nerd9:54 2 May '08  
GeneralRe: How to use this in C#? PinmemberJJMatthews7:18 26 Mar '10  
QuestionOwn Icon in Title Bar [modified] Pinmemberdressman19816:03 22 Mar '07  
AnswerRe: Own Icon in Title Bar PinmemberJJMatthews14:39 12 Aug '07  
GeneralGhost Dragging bug Pinmembersk8er_boy28721:35 7 Dec '06  
GeneralRe: Ghost Dragging bug PinmemberJJMatthews4:22 16 Dec '06  
AnswerUse PrintWindow() for Windows XP and up Pinmemberforjer5:37 17 Jan '07  
AnswerHope this works ... PinmemberCaveFox9:42 16 Oct '06  
GeneralSmall problem PinmemberIce_2k5:44 13 Oct '06  
GeneralRe: Small problem PinmemberIce_2k6:15 13 Oct '06  
GeneralGhost dragging costs Pinmemberowillebo0:35 12 Oct '06  
GeneralOne more problem PinmemberCarterqw8:02 11 Oct '06  
GeneralRe: One more problem PinmemberJJMatthews14:57 11 Oct '06  
GeneralEnhancement PinmemberRLyda4:34 11 Oct '06  
GeneralRe: Enhancement PinmemberJJMatthews14:58 11 Oct '06  
GeneralAnother problem PinmemberAndrewSmirnov8:30 9 Oct '06  
GeneralRe: Another problem PinmemberJJMatthews12:42 10 Oct '06  
GeneralBugs report Pinmembertoxcct22:03 4 Oct '06  
GeneralRe: Bugs report PinmemberJJMatthews12:58 6 Oct '06  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 12 Oct 2006
Article Copyright 2006 by JJMatthews
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid