Click here to Skip to main content
Click here to Skip to main content
Go to top

Pinnable ControlBar

, 4 Dec 2003
Rate this:
Please Sign up or sign in to vote.
This article is based on Cristi Posea's CSizeControlBar


This article is based on the article CSizingControlBar - a resizable control bar by Cristi Posea. It implements a control bar that can be pinned.

Using the code

  1. Include the following files in your project:
  2. Add these lines to your stdafx.h (if the files are in a different directory, include the path - see the stdafx.h file in the samples):
    #include "sizecbar.h"
    #include "scbarg.h"
    #include "scbarcf.h"
    #include "PinDockBar.h"
    #include "DrawFrame.h"
    #include "AutoHideBar.h
  3. Derive classes from CPinDockBar (you have an example in mybar.* files).
  4. In mainfrm.h, include your class' header, i.e.
    #include "mybar.h"

    Then add member variables to CMainFrame, i.e.

        CMyBar m_MyBar;
        CMyBar2 m_MyBar2;
        CMyBar2 m_MyBar2_1;
  5. In mainfrm.h, Add following macro in the CMainFrame class definition
    class CMainFrame : public CFrameWnd
  6. In mainfrm.cpp, add following macro:
  7. In mainfrm.cpp, add following macro in the message map of the class:
    BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  8. Create the bar in CMainFrame::OnCreate(). Then set bar styles, enable it to dock... like any control bar. Using EnablePinDocking(..) instead of EnableDocking, i.e.
  9. Set your imagelist for the AutoHideBar array m_AutoHideBar[0..3]
        m_ImgList.Create(IDB_TAB, 16, 1, RGB(255,0,255));
        for(int i = 0;i < 4; i ++)
  10. CPinDockBar is an abstract class, you need to implement two functions for your class:
        void AddToDrawBar(CAutoHideBar * pDrawBar);
        void RemoveFromDrawBar(CAutoHideBar * pDrawBar);

AddToDrawBar is called when a control sizing bar needs to move its child control(s) to side pane. RemoveFromDrawBar is called when a control sizing bar needs to take back its child control(s) from side pane.

The functions could be like this:

void CMyBar2::AddToDrawBar(CAutoHideBar * pDrawBar)
    CRect rt;
    CString szStr;
    pDrawBar->AddButton(szStr, DRAWBTNSTYLE_BTN, &m_List, 
        this, &rt, this, 0);

void CMyBar2::RemoveFromDrawBar(CAutoHideBar * pDrawBar)
    CRect rect;
    GetParentFrame()->ShowControlBar(this, TRUE, FALSE);

    m_List.MoveWindow(9,9, rect.Width() - 18, rect.Height() - 9 - 9);



LoadBarState() and SaveState() not implemented


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


About the Author

ziran lin
Software Developer
United States United States
No Biography provided

Comments and Discussions

QuestionUnable to compile under Microsoft visual studio 2010 [modified] Pinmemberpoonampawar1120-Jun-13 18:58 
I have used this code in MS VS 2003 and it works fine. But I need to run the same code in VS 2010. But getting few errors on compilation , such as:
error LNK2001:unresolved external symbol "protected:static struct AFX_MSGMAP const* _stdcall CPinDockBar::GetThisMessageMap(void)"(?
I have changed return type of some functions from UINT to LRESULT(as given for VS2005), but it is still not working.
Please help me by providing the source code which is supported by VS2010 (if any).

modified 21-Jun-13 1:06am.

Questionhow can i change this application to a .dll [modified] PinmemberJijesh Balakrishnan8-May-12 1:40 
QuestionLicense Terms PinmemberScott Bartine7-Dec-11 11:44 
AnswerRe: License Terms Pinmemberziran lin8-Dec-11 7:26 
QuestionInfinite loop? PinmemberGuppa8-Feb-10 14:42 
GeneralUnable to compile under VS 2005 PinmemberPetoG25-Oct-07 0:26 
GeneralRe: Unable to compile under VS 2005 Pinmemberscrat_amir25-Oct-07 4:34 
GeneralRe: Unable to compile under VS 2005 Pinmemberraynewmedical1-Jun-09 21:48 
QuestionHow can I deal with the notify message? Pinmemberfeifa1685-Oct-07 2:30 
QuestionLoadBarState & SaveBarState Pinmemberr.teox11-Jul-07 3:16 
GeneralDoes not work in MDI project Pinmemberneyadakim17-May-07 0:36 
QuestionRe: Does not work in MDI project Pinmemberr.teox11-Jul-07 5:51 
GeneralVisual Studio 2003 Pinmemberrkshdixit10-Apr-07 19:02 
GeneralTooltip for auto hide button Pinmemberscrat_amir2-Apr-07 20:52 
GeneralThe outlook style in MDI Pinmemberlaronze20-Mar-07 2:43 
GeneralRe: The outlook style in MDI PinmemberZiran_lin22-Mar-07 10:32 
AnswerRe: The outlook style in MDI Pinmemberr.teox11-Jul-07 5:46 
Generala fatal error Pinmemberping_linux17-Dec-06 5:51 
GeneralRe: a fatal error PinmemberPetoG21-Jan-09 1:59 
Generalsetting m_pFloatingFrameClass protected data member PinmemberIonut Codrut10-Sep-06 3:54 
GeneralRe: setting m_pFloatingFrameClass protected data member Pinmemberziran lin12-Sep-06 13:32 
GeneralRe: setting m_pFloatingFrameClass protected data member PinmemberIonut Codrut12-Sep-06 21:05 
GeneralRe: setting m_pFloatingFrameClass protected data member Pinmemberziran lin13-Sep-06 10:22 
GeneralRe: setting m_pFloatingFrameClass protected data member PinmemberIonut Codrut13-Sep-06 20:16 
GeneralRe: setting m_pFloatingFrameClass protected data member Pinmemberziran lin14-Sep-06 15:28 

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 | Mobile
Web03 | 2.8.140916.1 | Last Updated 5 Dec 2003
Article Copyright 2003 by ziran lin
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid