Click here to Skip to main content
13,007,704 members (79,183 online)
Click here to Skip to main content
Add your own
alternative version


69 bookmarked
Posted 1 Jul 2003

A Technique to Customize the Title Bar of Windows

, 1 Jul 2003
Rate this:
Please Sign up or sign in to vote.
Use an easy-to-use templated class to custom the title bar of windows.


This uses a technique of customizing the title bar by simulating the window's title bar's behavior with a substitute window. The former window title bar is removed from the window region, and a substitute window which behaves just like a window title bar is created at the position where the window's title bar should be. The demo project provides a framework to achieve this job, and also two kinds of title bar looks: one is somewhat like window title bars on X Windows, and the other is my creation.


I read a good article on customization of window's title bar through window subclassing written by James Brown. Soon I found that it is not so easy to achieve a complex visual effect that I want by the window subclassing technique. MS seems to not like programmers to change the default behavior of Windows user interface elements, thus many programmers have to "create" new user interface elements by themselves. This is an example of such a condition.


Titlebar: Derive your window classes that need title bar customization from this class, and specify a title bar substitute class and a button class as template arguments.

TitlebarSubstitute: The base class of the title bar's substitute window. This implements most of the window title bar's behavior. To achieve various visual effects, just derive your own substitute window class from it, and override its virtual methods. The most important virtual methods of TitlebarSubstitute is DoPaint, which is responsible for drawing all title bar elements except system buttons. There are two classes derived from TitlebarSubstitute in the demo project, LinuxTitlebarSubstitute which makes a window title bar like the first screenshot, and WrittenInMidnight like in the second screenshot.

PushButton: A custom-draw button class, the base class of all system buttons classes.

Using the Code

First, derive your window class from class Titlebar. For example:

class CMainFrame : public CFrameWindowImpl<CMAINFRAME>, public CUpdateUI<CMAINFRAME>, 
  public CMessageFilter, public CIdleHandler,
  public FreshUI::Titlebar <
    CMainFrame, FreshUI::LinuxTitlebarSubstitute <
      FreshUI::LinuxSystemButton > >

Chain a message map to class Titlebar:

typedef FreshUI::Titlebar <
  CMainFrame, FreshUI::LinuxTitlebarSubstitute <
    FreshUI::LinuxSystemButton > > baseClass;

    // ...

Call Titlebar::Init. For general windows, you should call this method in OnCreate; for dialogs, call it in OnInitDialog. For example:

  UINT /*uMsg*/,
  WPARAM /*wParam*/,
  LPARAM /*lParam*/,
  BOOL& /*bHandled*/)
  // ...
  // Initialize Titlebar
  return 0;


  • 07-02-2003 - Initial upload


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

Junlei Li
Web Developer
China China
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralPlease help ...not able to run this program…error that I’m not getting Pin
rImrose8-Apr-09 4:54
memberrImrose8-Apr-09 4:54 
AnswerRe: Please help ...not able to run this program…error that I’m not getting Pin
Clebson Derivan3-Feb-10 12:40
memberClebson Derivan3-Feb-10 12:40 
QuestionHow can I do the same in VB.NET or C#.NET Pin
Member 312797922-Mar-09 2:27
memberMember 312797922-Mar-09 2:27 
GeneralDblClick on titlebar problem Pin
Magnus Persson28-Aug-08 4:34
memberMagnus Persson28-Aug-08 4:34 
GeneralVisual Studio 2005 Compatibility Fix Pin
illlogic28-Aug-06 20:17
memberilllogic28-Aug-06 20:17 
Generalthis in MFC Pin
Mircea Grelus12-Oct-05 5:42
memberMircea Grelus12-Oct-05 5:42 
QuestionRe: this in MFC Pin
The Triggerman31-Oct-06 0:13
memberThe Triggerman31-Oct-06 0:13 
AnswerRe: this in MFC Pin
Mircea Grelus31-Oct-06 0:33
memberMircea Grelus31-Oct-06 0:33 
GeneralCant compile in VC7+WTL7 Pin
daveice6-Sep-05 7:09
memberdaveice6-Sep-05 7:09 
GeneralRe: Cant compile in VC7+WTL7 Pin
Kromllar19-Sep-05 1:51
sussKromllar19-Sep-05 1:51 
GeneralTitle text Pin
TheinstruTara20-Jul-05 22:15
memberTheinstruTara20-Jul-05 22:15 
QuestionTitle bar not being hidden? Pin
rtmyers27-Jul-04 6:41
memberrtmyers27-Jul-04 6:41 
AnswerRe: Title bar not being hidden? Pin
Anonymous6-Aug-04 6:41
sussAnonymous6-Aug-04 6:41 
GeneralExcellent job.Thank you Pin
DavidRipple22-Feb-04 0:30
memberDavidRipple22-Feb-04 0:30 
QuestionWhite durt dot on titlebar? Pin
Anonymous5-Jul-03 21:18
sussAnonymous5-Jul-03 21:18 
AnswerRe: White durt dot on titlebar? Pin
Junlei Li6-Jul-03 5:28
memberJunlei Li6-Jul-03 5:28 
GeneralRe: Re: White durt dot on titlebar? Pin
Anonymous6-Jul-03 22:22
sussAnonymous6-Jul-03 22:22 
GeneralRe: Re: White durt dot on titlebar? Pin
Junlei Li8-Jul-03 4:20
memberJunlei Li8-Jul-03 4:20 
GeneralWon`t compile. Pin
Ilushka3-Jul-03 0:34
memberIlushka3-Jul-03 0:34 
GeneralRe: Won`t compile. Pin
Anonymous3-Jul-03 2:52
sussAnonymous3-Jul-03 2:52 
GeneralRe: Won`t compile. Pin
Ilushka10-Jul-03 22:54
memberIlushka10-Jul-03 22:54 
GeneralRe: Won`t compile. Pin
Junlei Li11-Jul-03 19:24
memberJunlei Li11-Jul-03 19:24 
GeneralRe: Won`t compile. Pin
toddor_sturt13-Dec-04 14:36
membertoddor_sturt13-Dec-04 14:36 
GeneralIncluded header &quot;ATLRES.H&quot; missing Pin
vijay_visana3-Jul-03 0:03
membervijay_visana3-Jul-03 0:03 
GeneralRe: Included header &quot;ATLRES.H&quot; missing Pin
Anonymous3-Jul-03 2:51
sussAnonymous3-Jul-03 2:51 

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.170628.1 | Last Updated 2 Jul 2003
Article Copyright 2003 by Junlei Li
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid