Click here to Skip to main content
13,002,676 members (62,525 online)
Click here to Skip to main content
Add your own
alternative version


65 bookmarked
Posted 4 Dec 2003

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

You may also be interested in...

Comments and Discussions

GeneralRe: setting m_pFloatingFrameClass protected data member [modified] Pin
Ionut Codrut15-Sep-06 22:19
memberIonut Codrut15-Sep-06 22:19 
Hi Ziran!
Everything seems to work fine! Now I got NO doubled frame and my dialog is dockable with double click on the title bar. I hope the your tricky offset to be safe I do not test it very well!
Now I have another problem: when I push the pin button (on the instant bar) I got no reaction - nothing happend. I insert some break point in the code, but it seems that the debbuger don't reach, not enter - in OnPushPinOn(..) member function. I check out all the declaration and their positions in the code, but I'm not sure that the press button message goes in coresponding function, probably becose it is a DLL COM. You have any ideea how I can achive this push button message in my case?
Important: the debugger reach CPinDockBar::OnNcLButtonUp(..)
Kind regards!

-- modified at 4:33 Saturday 16th September, 2006
GeneralRe: setting m_pFloatingFrameClass protected data member Pin
ziran lin18-Sep-06 15:54
memberziran lin18-Sep-06 15:54 
Questionhi,Ziran. Have you try to add an item to the list control? Pin
vt123456789022-Aug-06 15:11
membervt123456789022-Aug-06 15:11 
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 

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.170626.1 | Last Updated 5 Dec 2003
Article Copyright 2003 by ziran lin
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid