Click here to Skip to main content
12,827,765 members (45,682 online)
Click here to Skip to main content
Add your own
alternative version


60 bookmarked
Posted 4 Oct 2006

Title Bar Replacement Class With Cool Features

, 12 Oct 2006
Rate this:
Please Sign up or sign in to vote.
Nice looking title bar for your applications with autohide and ghost-drag capabilities.

Sample Image - TBarDemo.gif


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


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.


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

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

    // Caption images are optional

// ...


  • 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.


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

Software Developer
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionWindows 10??? Pin
John L. Murphy13-Dec-16 4:04
memberJohn L. Murphy13-Dec-16 4:04 
AnswerRe: Windows 10??? Pin
JJMatthews15-Dec-16 22:36
memberJJMatthews15-Dec-16 22:36 
GeneralRe: Windows 10??? Pin
John L. Murphy17-Dec-16 4:54
memberJohn L. Murphy17-Dec-16 4:54 
QuestionMenu with SDI view problem. Pin
kimchi30-Jun-08 20:20
memberkimchi30-Jun-08 20:20 
QuestionHow to replace title bar in a dialog? Pin
khutchinson18-Jan-08 11:43
memberkhutchinson18-Jan-08 11:43 
QuestionHow to use this in C#? Pin
Ngh5511-Aug-07 18:42
memberNgh5511-Aug-07 18:42 
AnswerRe: How to use this in C#? Pin
JJMatthews12-Aug-07 15:37
memberJJMatthews12-Aug-07 15:37 
AnswerRe: How to use this in C#? Pin
Alpha Nerd18-Apr-08 7:20
memberAlpha Nerd18-Apr-08 7:20 
GeneralRe: How to use this in C#? Pin
JJMatthews21-Apr-08 5:31
memberJJMatthews21-Apr-08 5:31 
RantRe: How to use this in C#? Pin
Alpha Nerd2-May-08 10:54
memberAlpha Nerd2-May-08 10:54 
GeneralRe: How to use this in C#? Pin
JJMatthews26-Mar-10 8:18
memberJJMatthews26-Mar-10 8:18 
QuestionOwn Icon in Title Bar [modified] Pin
dressman198122-Mar-07 7:03
memberdressman198122-Mar-07 7:03 
AnswerRe: Own Icon in Title Bar Pin
JJMatthews12-Aug-07 15:39
memberJJMatthews12-Aug-07 15:39 
GeneralGhost Dragging bug Pin
sk8er_boy2877-Dec-06 22:35
membersk8er_boy2877-Dec-06 22:35 
GeneralRe: Ghost Dragging bug Pin
JJMatthews16-Dec-06 5:22
memberJJMatthews16-Dec-06 5:22 
AnswerUse PrintWindow() for Windows XP and up Pin
forjer17-Jan-07 6:37
memberforjer17-Jan-07 6:37 
AnswerHope this works ... Pin
CaveFox16-Oct-06 10:42
memberCaveFox16-Oct-06 10:42 
GeneralSmall problem Pin
Ice_2k13-Oct-06 6:44
memberIce_2k13-Oct-06 6:44 
GeneralRe: Small problem Pin
Ice_2k13-Oct-06 7:15
memberIce_2k13-Oct-06 7:15 
GeneralGhost dragging costs Pin
owillebo12-Oct-06 1:35
memberowillebo12-Oct-06 1:35 
GeneralOne more problem Pin
Carterqw11-Oct-06 9:02
memberCarterqw11-Oct-06 9:02 
GeneralRe: One more problem Pin
JJMatthews11-Oct-06 15:57
memberJJMatthews11-Oct-06 15:57 
GeneralEnhancement Pin
RLyda11-Oct-06 5:34
memberRLyda11-Oct-06 5:34 
GeneralRe: Enhancement Pin
JJMatthews11-Oct-06 15:58
memberJJMatthews11-Oct-06 15:58 
GeneralAnother problem Pin
AndrewSmirnov9-Oct-06 9:30
memberAndrewSmirnov9-Oct-06 9:30 

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.

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