Click here to Skip to main content
12,956,358 members (79,583 online)
Click here to Skip to main content
Add your own
alternative version


65 bookmarked
Posted 4 Dec 2003

Pinnable ControlBar

, 4 Dec 2003 CPOL
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

You may also be interested in...

Comments and Discussions

AnswerRe: hi,Ziran. Have you try to add an item to the list control? Pin
vt123456789022-Aug-06 18:13
membervt123456789022-Aug-06 18:13 
GeneralResize = Flash is serious [modified] Pin
supau31-Jul-06 22:14
membersupau31-Jul-06 22:14 
GeneralRe: Resize = Flash is serious [modified] Pin
ziran lin1-Aug-06 15:23
memberziran lin1-Aug-06 15:23 
GeneralResize during startup Pin
isonic27-Jul-06 2:50
memberisonic27-Jul-06 2:50 
GeneralRe: Resize during startup Pin
ziran lin1-Aug-06 15:44
memberziran lin1-Aug-06 15:44 
QuestionHow can I put a formview in the tabctrl Pin
vt123456789016-Jun-06 13:23
membervt123456789016-Jun-06 13:23 
AnswerRe: How can I put a formview in the tabctrl Pin
Ziran_lin16-Jun-06 14:21
memberZiran_lin16-Jun-06 14:21 
GeneralRe: How can I put a formview in the tabctrl Pin
vt123456789016-Jun-06 19:45
membervt123456789016-Jun-06 19:45 
Thanks a lot. I do it. I would like to share my experience here.

I try to use a formview to place controls. There are many ways to create a formview and put it in the tabctrl. They all encount such or that problems. I overcome all of them, and successfully put the formview in the tabctrl. Now there are two big problems hint me from using this mothd. First, when I put the program in debug model, there aways occures assert failed; when I put the program in release model, the menu doesn't response. I could't tolerance such a big bug. The problem is really a hard one. I have tried many ways to fix those problems, but failed.

Now I try your way to put a child dialog in the tabctrl. ok. It works. I can write code just as in a dialog. It is really convenient.

Thank you, Ziran.

Best regards.

Generalload / save state Pin
LoganKale12-Jun-06 4:54
memberLoganKale12-Jun-06 4:54 
Generalmissplasing of the control bar Pin
LoganKale7-Jun-06 4:38
memberLoganKale7-Jun-06 4:38 
GeneralRe: missplasing of the control bar [modified] Pin
Ziran_lin7-Jun-06 14:57
memberZiran_lin7-Jun-06 14:57 
GeneralRe: missplasing of the control bar Pin
LoganKale12-Jun-06 4:55
memberLoganKale12-Jun-06 4:55 
GeneralDisplay a modeless dialog Pin
alwittta4-May-06 21:00
memberalwittta4-May-06 21:00 
GeneralRe: Display a modeless dialog Pin
Ziran_lin22-May-06 11:24
memberZiran_lin22-May-06 11:24 
QuestionHow to set the initial bar state as hide? Pin
humorstar16-Jul-05 14:49
memberhumorstar16-Jul-05 14:49 
AnswerRe: How to set the initial bar state as hide? Pin
Vinicius Pontes6-Feb-06 2:14
memberVinicius Pontes6-Feb-06 2:14 
AnswerRe: How to set the initial bar state as hide? Pin
James Poag25-Jan-07 6:11
memberJames Poag25-Jan-07 6:11 
GeneralAbout License... Pin
Joseph Mendez29-Dec-04 23:18
memberJoseph Mendez29-Dec-04 23:18 
GeneralRe: About License... Pin
ziran30-Dec-04 6:40
memberziran30-Dec-04 6:40 
GeneralCSizingControlBar::OnLButtonUp doesn't work! Pin
wenzhai9-Dec-04 15:40
memberwenzhai9-Dec-04 15:40 
Questionhow to add darg and drop support to tree items? Pin
mahatma_cis29-Jul-04 19:34
membermahatma_cis29-Jul-04 19:34 
AnswerRe: how to add darg and drop support to tree items? Pin
ziran29-Jul-04 20:06
memberziran29-Jul-04 20:06 
GeneralRe: how to add darg and drop support to tree items? Pin
mahatma_cis1-Aug-04 19:44
membermahatma_cis1-Aug-04 19:44 
GeneralRe: how to add darg and drop support to tree items? Pin
ziran2-Aug-04 13:08
memberziran2-Aug-04 13:08 
GeneralRe: how to add darg and drop support to tree items? Pin
mahatma_cis2-Aug-04 19:30
membermahatma_cis2-Aug-04 19: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.170525.1 | Last Updated 5 Dec 2003
Article Copyright 2003 by ziran lin
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid