Click here to Skip to main content
Click here to Skip to main content

Office XP look & feel controls

, 22 Jan 2002 CPOL
Rate this:
Please Sign up or sign in to vote.
Some controls (toolbar, button, combobox, ...) with the Office XP look and feel.

Sample Image


Yet another owner drawn toolbar. This one has the Office XP look & feel. Have a look to the source code (ToolbarXP.h and ToolbarXP.cpp) for more details. Some parts of code are copied from other articles. Thanks to their authors!

How to use the CToolBarXP class

Include the ToolbarXP.h file and just replace the CToolBar m_wndToolBar declaration in your files by CToolBarXP m_wndToolBar. That's all ! (see the demo)

Other classes

CButtonXP, CListBoxXP, CComboBoxXP: Flat controls with "mouseover" and "mouseout" effects.
CStatusBarXP: Flat statusbar.
CPopup: Allow any control to be popped over frame (as shown in the image).
CWindowsManagerDlg: MDI child window manager.

CBufferDC: An easy-to-use class to simplify the bufferized drawing.

Example: Replace in your code:

void CToolBarXP::OnPaint ()
    CPaintDC cDC (this);

    cDC.FillSolidRect (CRect(10,10,100,100), 255);
    cDC.MoveTo (10, 10);
    cDC.LineTO (100, 100);
    // Etc...
void CToolBarXP::OnPaint ()
    CPaintDC cpDC (this); // Modified line
    CBufferDC cDC (cpDC); // Added line

    cDC.FillSolidRect (CRect(10,10,100,100), 255);
    cDC.MoveTo (10, 10);
    cDC.LineTO (100, 100);
    // Etc...
And it works too with any HDC (see the CButtonXP::DrawItem method for another exemple).
The only constraint: you have to do all drawing with the same CBufferDC instance. You cannot have a first part in the OnEraseBkgnd and another one in the OnPaint.

CPenDC and CBrushDC: Simplify the use of local CPen and CBrush objects.

Without those classes:

    // ...
    CPen pen (PS_SOLID, 1, RGB(0,0,255));
    CBrush brush (RGB(0,255,0));
    CPen* pOldPen = cDC.SelectObject (&pen);
    CBrush* pOldBrush = cDC.SelectObject (&brush);
    cDC.Rectangle (10,10,100,100);
    cDC.SelectObject (pOldPen);
    cDC.SelectObject (pOldBrush);
    // ...
With them:
    // ...
    CPenDC pen (cDC, RGB(0,0,255));
    CBrushDC brush (cDC, RGB(0,255,0));
    cDC.Rectangle (10,10,100,100);
    // ...

CClientRect and CWindowRect: Encapsulate GetClientRect and GetWindowRect calls.


    // ...
    CRect rcClient;
    GetClientRect (rcClient);
    cDC.FillSolidRect (rcClient, 255);
    // ...
    // ...
    cDC.FillSolidRect (CClientRect (this), 255);
    // ...

CWindowText: Encapsulate GetWindowText calls.


    // ...
    CString sText;
    GetWindowText (sText);
    // ...
    // ...
    cDC.DrawText (CWindowText (this), rc, DT_SINGLELINE|DT_CENTER|DT_VCENTER);
    // ...


Thanks to Christian Rodemeyer for his RGB<->HLS conversion methods from the article CColor - RGB and HLS combined in one class.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Jean-Michel LE FOL
Web Developer CSC
France France
Jean-Michel LE FOL is a GraphTalk product architect.
GraphTalk is a set of products which cover the whole scope of the development process. GraphTalk is used by the main insurance compagnies over the world.
The development team is currently based in France near Paris.

Comments and Discussions

QuestionQuestion about article: Office XP look & feel controls PinmemberNenad Smiljkovic6-Jun-13 20:22 
GeneralFound a way to display 24 bit images in CMenuXP, if anyone is interested PinmemberAxiom66615-Mar-06 16:10 
GeneralRe: Found a way to display 24 bit images in CMenuXP, if anyone is interested PinmemberAxiom66620-Mar-06 7:54 
GeneralSetButtonText Pinmembersujee8-Oct-04 3:07 
Question? CMenuXP::OnMeasureItem ? PinmemberFrank Lagattuta24-Sep-04 18:32 
GeneralOffice XP Style Edit Control PinmemberJigar Mehta23-Jun-04 23:58 
GeneralOffice XP style task pane PinmemberSeshagiri7-Apr-04 0:25 
GeneralWindows XP style vs Office XP style PinmemberMarco van der Kolk1-Oct-03 23:51 
GeneralException in Draw.cpp PinmemberJaime Stuardo31-Aug-03 16:51 
GeneralRe: Exception in Draw.cpp Pinmemberagfirehead14-Sep-03 20:02 
GeneralLoading and saving toolbar position PinmemberArthurit19-Jul-03 0:03 
GeneralRe: Loading and saving toolbar position PinmemberJean-Michel LE FOL20-Jul-03 9:27 
GeneralRe: Loading and saving toolbar position PinmemberArthurit20-Jul-03 23:55 
GeneralBug Pinmemberwz_zhou2-Jun-03 2:56 
GeneralIcon style doesn't work in CButtonXP control Pinmemberjstuardo19-Apr-03 8:54 
GeneralRe: Icon style doesn't work in CButtonXP control PinmemberDJ Mantra4-Feb-05 2:47 
GeneralIncompatible with Win95 Pinmemberadamtegen25-Mar-03 5:36 
GeneralRe: Incompatible with Win95 PinmemberMarco van der Kolk29-Sep-03 5:20 
GeneralRe: Incompatible with Win95 Pinmemberpippa6-Apr-04 4:44 
QuestionHow to change the combo's height. PinmemberDuc Truong11-Mar-03 22:38 
GeneralThe disabled imagem seems a little orange Pinmemberfpm126-Dec-02 11:40 
GeneralXP-style NOT shown Pinmemberdarthmaul3-Dec-02 5:58 
GeneralAbout the compiled demo PinmemberJean-Michel LE FOL3-Dec-02 22:29 
Generala bug! PinsussAnonymous22-Aug-02 0:23 
GeneralRe: a bug! PinmemberTakahiro Araki16-Jan-03 14:24 
GeneralAn error with toolbar PinsussDMTR3-Aug-02 13:40 
GeneralRe: An error with toolbar Pinmemberahmoy14-Feb-04 8:42 
GeneralRe: An error with toolbar Pinmemberahmoy16-Feb-04 15:39 
GeneralJean-Michel, lire svp. PinmemberStephane F.8-Jul-02 23:21 
GeneralRe: Jean-Michel, lire svp. PinmemberAlexMarbus3-Aug-02 11:57 
GeneralRe: Jean-Michel, lire svp. PinsussAnonymous10-Nov-02 6:31 
GeneralWindows API programming Pinmemberbuck18-Jun-02 10:53 
GeneralRe: Windows API programming PinmemberDimitris Vassiliades4-Jul-03 8:03 
GeneralText on ToolBar Buttons Pinmemberjmgurgel31-May-02 8:39 
GeneralEdit control PinmemberRED13-May-02 11:42 
GeneralRe: Edit control Pinmemberxr1st0s27-Jan-03 14:24 
GeneralRe: Edit control Pinmembera1ring30-Jun-03 4:22 
QuestionButton Text? PinmemberAnonymous4-May-02 17:36 
Generala problem PinmemberAnonymous23-Apr-02 3:47 
GeneralSolution PinmemberJean-Michel LE FOL29-Apr-02 2:16 
GeneralText Labels On Right PinmemberAnonymous7-Apr-02 12:52 
GeneralRe: Text Labels On Right Pinmemberjmgurgel31-May-02 8:42 
GeneralBase Class Pinmemberjmgurgel23-Mar-02 7:31 
QuestionShading? PinmemberMiguel Lopes20-Mar-02 1:03 
GeneralGreat Code, I like it ... PinmemberMassimo Germi6-Mar-02 10:14 
GeneralGood job, but ... PinmemberAnonymous5-Mar-02 10:22 
GeneralNew problem PinmemberCosmoS2k7-Feb-02 7:36 
GeneralRe: New problem PinmemberJean-Michel LE FOL7-Feb-02 12:04 
GeneralGoof but... PinmemberCosmoS2k6-Feb-02 21:02 
GeneralRe: Goof but... PinmemberJean-Michel LE FOL6-Feb-02 23:24 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 23 Jan 2002
Article Copyright 2002 by Jean-Michel LE FOL
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid