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

CSizingControlBar - a resizable control bar

By , 15 Aug 2000
 

  • Download source - 65 Kb

    Sample Image

    <!-- Article Starts -->

    Features of CSizingControlBar 2.43

    • Resizable control bar, that can be resized both when docked and when floating.
    • Multiple sizing control bars can be docked on the same row/column.
    • Full dynamic resizing, both when docked and floating, including diagonal resizing when floating.
    • State persistence support (SaveState/LoadState).
    • Gripper with "hide bar" flat button.
    • Memory DC flickerless NC painting.
    • Sample extension class with focus autosensing text caption. On Win98/Win2k, the caption is painted with gradient.
    • No custom resources were used (bitmaps, cursors, strings, etc.), so the integration is easier and you have full control over the resources you eventually use in derived classes.
    • Easy to use: use directly one of the CSizingControlBar* classes or derive your own control bar class, then add your child controls.

    Instructions

    Getting Started

    1. Include the following files in your project:

    sizecbar.h
    sizecbar.cpp
    scbarg.h
    scbarg.cpp
    

    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"
    

    3. Derive a class from CSizingControlBarG (you have an example in mybar.* files).

    4. In mainfrm.h, include your class' header:

    #include "mybar.h"
    
    then add a member variable to CMainFrame:
    CMyBar m_wndMyBar;
    

    5. Create the bar in CMainFrame::OnCreate(). Then set bar styles, enable it to dock... like any control bar.

    if (!m_wndMyBar.Create(_T("My Bar"), this, 123)
    {
        TRACE0("Failed to create mybar\n");
        return -1;
        // fail to create
    }
    m_wndMyBar.SetBarStyle(m_wndMyBar.GetBarStyle() |
        CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
    
    m_wndMyBar.EnableDocking(CBRS_ALIGN_ANY);
    
    EnableDocking(CBRS_ALIGN_ANY);
    
    DockControlBar(&m_wndMyBar, AFX_IDW_DOCKBAR_LEFT);
    

    Advanced Example

    The instructions above will make a docking bar with a DevStudio-like gripper (with 2 raised lines and a hide button) when docked, and with no gripper when floating.

    Let's explore some advanced features. Now we will use the CSizingControlBarCF class as a base class, and will hide the miniframe caption, showing the gripper in the floating state too. That's possible, because CSizingControlBarCF's gripper looks like a small caption. As a side effect of using a custom miniframe class, the resizing of the floating bar will be dynamic if "Show window contents while dragging" display property is enabled.

    1. Add these files to your project too:

    scbarcf.h
    scbarcf.cpp
    

    2. Change the stdafx.h file to look like this:

    #define _SCB_REPLACE_MINIFRAME
    #include "sizecbar.h"
    #include "scbarg.h"
    #include "scbarcf.h"
    #define baseCMyBar CSizingControlBarCF
    

    3. Add these lines in CMainFrame::OnCreate(), after the EnableDocking() call

    #ifdef _SCB_REPLACE_MINIFRAME
        m_pFloatingFrameClass = RUNTIME_CLASS(CSCBMiniDockFrameWnd);
    #endif //_SCB_REPLACE_MINIFRAME
    

    Remarks

    These classes are intended to be used as base classes. Do not simply add your code to the files - instead create a new class derived from CSizingControlBarG or CSizingControlBarCF and put there what you need. If you want to customize your gripper, or simply don't want a gripper, you can use CSizingControlBar as a base class.

    Window IDs: The usage of IDs in the range of AFX_IDW_CONTROLBAR_FIRST + 32 .. AFX_IDW_CONTROLBAR_LAST is required only if the bar will not be enabled for docking (that's is - it will stay fixed right under the frame's menu). But in this situation you won't be able to fully use the features of this class, so if you will enable it to dock (a reasonable guess :) then you can use any valid window ID.
    Another place where the IDs are important is the saving/loading of the bar's state. You must use different IDs for each control bar that is enabled to dock, and this includes the other bars too. For example, if you have two toolbars, you can create the first one with the default ID (which is AFX_IDW_TOOLBAR = AFX_IDW_CONTROLBAR_FIRST), but the second one must have a different ID.

    OnUpdateCmdUI: This member function is pure virtual in CControlBar (the base class of CSizingControlBar). Its purpose is to allow updating of controls at idle time (from here CCmdUI::DoUpdate() is called for the toolbars buttons, controls on dialog bars, panes of status bar, etc.).
    However, I found it very useful to update the look of the "x" flat button in CSizingControlBarG and the color of the caption in CSizingControlBarCF (no timers needed). So, if you will use this function, don't forget to call the base class' member (see mybar.cpp).

    Dynamic resizing: This feature allows redrawing of the bar during resizing. Also all the bars are repositioned and redrawn if necessary.
    The SPI_GETDRAGFULLWINDOWS system parameter is queried for this (it is enabled by the "Show window contents while dragging" checkbox in Display Properties).

    CBRS_SIZE_DYNAMIC: This bar style is required. Make sure you add it to the bar, otherwise the application will crash when the user floats a bar. You can add it using SetBarStyle() after Create(), or by changing the default style for Create() to something like: WS_VISIBLE|WS_CHILD|CBRS_TOP|CBRS_SIZE_DYNAMIC.

    State persistence: The common MFC control bars' docking state is saved using CMainFrame::SaveBarState(). In addition to the info saved by this function, the CSizingControlBar class needs to save 3 sizes. This is done in CSizingControlBar::SaveState() function, so a m_wndMyBar.SaveState() call is required. Please note that the state storing code must be placed in CMainFrame's OnClose() or DestroyWindow(), not in OnDestroy(), because at the time the WM_DESTROY message is received, the floating bars are already destroyed.
    In CMainFrame::OnCreate(), the m_wndMyBar.LoadState() call must be placed before LoadBarState().
    Alternatively, if you have more than one resizable bars, you can call once the static member SizingControlBar::GlobalSaveState() instead of calling each bar's SaveState(). The same for LoadState() - there is a CSizingControlBar::GlobalLoadState() function. See both samples here for more details.

    Precompiler flags: There are 2 symbols which can be defined to cause the floating bars to have different appearance and functionality:

    1. _SCB_REPLACE_MINIFRAME can be used to plug in CSCBMiniDockFrameWnd, which is a custom miniframe class. The main gain of using this class is that the floating bars can be resized dynamically, like all other windows. The other advantage is that the miniframe caption can be turned off, allowing the bar to display its own gripper, for increased functionality and/or custom designs.
      If you use this flag, you have to change the m_pFloatingFrameClass member of the main frame (see the advanced example above).
    2. _SCB_MINIFRAME_CAPTION can be defined only if the previous flag is also defined. It causes the custom miniframe to keep the tool window caption.
      Both CSizingControlBarG and CSizingControlBarCF classes do not display a gripper when floating if this flag is set.

    See also www.datamekanix.com for class reference, a full changelog, FAQ, a dedicated message board and more.

  • License

    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

    Cristi Posea

    United States United States
    No Biography provided

    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board.
    Search this forum  
        Spacing  Noise  Layout  Per page   
    QuestionIt is updated at the web sitememberSteve Wolf21-Jan-13 6:41 
    http://www.datamekanix.com/[^]
     
    Thank you for building & sharing this! It's going to help me out a bunch. Smile | :)
    Steve Wolf

    Generalis it memory leakmemberlichongbin12-Apr-11 18:23 
    I have read the MFC source code of the following function:
    void CFrameWnd::EnableDocking(DWORD dwDockStyle);
     
    A CDockBar object is allocated in heap:
    pDock = new CDockBar
    but where the object is freed? Is is memory leak?
    There is a will,there is a way!

    GeneralRe: is it memory leakmemberzxl2004066-Sep-11 16:26 
    Frown | :(
    I agree with you ,How do you solve it?

    GeneralRe: is it memory leakmemberSteve Wolf21-Jan-13 4:08 
    There isn't any memory leak here. The main frame keeps an array of control bar pointers, and deletes them when it is destroyed.
    Steve Wolf

    QuestionThe Code Is Very Good.I have some question.please help me!memberwzq00000011-Feb-11 15:31 
    There is a Class derive from the CSizingControlBarG.
    Now I want to control the bar,make its width less than 200.Whether it is docking or floating.I get the window poiniter and moveWindow().Its postion is Changed,but the size is not Changed.How Can I do?
    GeneralThanks Cristi Poseamemberlflljt31-Oct-10 23:36 
    Thanks Cristi Posea
    GeneralDockControlBar chrases vs2008memberjosip cagalj12-Mar-10 2:26 
    Hi I tried to use this control in myapp in VS2008, here is the code I use:
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    	if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
    		return -1;
     
    //....CREATE OTHER CONTROLS (TOOLBAR; STATUSBAR...)
    
    	if (!m_wndMyLog.Create(" Error log", this, CSize(640, 60),
                TRUE, AFX_IDW_CONTROLBAR_FIRST + 34))
    	{
            TRACE0("Failed to create mylog\n");
            return -1;      // fail to create
    	}
    	m_wndMyLog.SetBarStyle(m_wndMyLog.GetBarStyle() |
                CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
     
    
     
    	// TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable
    	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
    	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    	m_wndMyLog.EnableDocking(CBRS_ALIGN_BOTTOM);
    	EnableDocking(CBRS_ALIGN_ANY);
    	DockPane(&m_wndMenuBar);
    	DockPane(&m_wndToolBar);
    	DockControlBar(&m_wndMyLog,AFX_IDW_DOCKBAR_BOTTOM);//HERE IT CHRASES!!!
    
    //OTHER STUFF....
    
    	return 0;
    }
    
     
    When I trace it here is where it stops:
    void CFrameWnd::DockControlBar(CControlBar* pBar, CDockBar* pDockBar, LPCRECT lpRect)
    {
    	ENSURE_ARG(pBar != NULL);
    	// make sure CControlBar::EnableDocking has been called
    	ASSERT(pBar->m_pDockContext != NULL);
     
    	if (pDockBar == NULL)
    	{
    		for (int i = 0; i < 4; i++)
    		{
    			if ((dwDockBarMap[i][1] & CBRS_ALIGN_ANY) ==
    				(pBar->m_dwStyle & CBRS_ALIGN_ANY))
    			{
    				pDockBar = (CDockBar*)GetControlBar(dwDockBarMap[i][0]);
    				ASSERT(pDockBar != NULL);                   //STOPS HERE BECAUSE pDockBar is NULL!!!
    				// assert fails when initial CBRS_ of bar does not
    				// match available docking sites, as set by EnableDocking()
    				break;
    			}
    		}
    	}
    	ENSURE_ARG(pDockBar != NULL);
    	ASSERT(m_listControlBars.Find(pBar) != NULL);
    	ASSERT(pBar->m_pDockSite == this);
    	// if this assertion occurred it is because the parent of pBar was not initially
    	// this CFrameWnd when pBar's OnCreate was called
    	// i.e. this control bar should have been created with a different parent initially
    
    	pDockBar->DockControlBar(pBar, lpRect);
    }
    
     
    Any help why is this happening?
    Thanks in advance
    GeneralRe: DockControlBar chrases vs2008memberSteve Wolf21-Jan-13 4:12 
    Because you are deriving from CFrameWndEx, you're using the newer control bar framework. The newer one is not compatible with this project. You can instead derive from CFrameWnd, and you'll get the older functionality and this project should work (I had to make some very minor corrections to the code to make it compile with VS2010 and VS2012).
    Steve Wolf

    GeneralSize after DinamycRecalcLayoutmemberMember 210934722-Dec-09 0:22 
    After DinamycRecalcSize sizingbar is too width for my control, how can i reduce heigth?
    Question怎么在Dialog Based application 实现这样的效果呢?memberpophelix18-Dec-09 15:22 
    怎么在Dialog Based application 实现这样的效果呢?有没有人实现过?
    GeneralDoubleClick on TreeViewmembermbks7-Oct-09 3:24 
    Hi to all,
    how I can catch a click or double Click into Treeview on baseCMyBar ?
    tanks
     
    Mirko
    GeneralRe: DoubleClick on TreeView Solvedmembermbks8-Oct-09 19:46 
    I have solved it whit a notification:
    ON_NOTIFY(NM_DBLCLK, ID_TREELIBADD, OnNMRclickTreeAdd)
    where ID_TREELIBADD is my treeview
     
    Mirko
    GeneralProblem solved!!memberforhappy200920-Aug-09 19:00 
    Hi anybody there!!!
    I have solved the problem last time I encountered!I'd like to share my experience and the way I solved my problem!
    The way is as follows:
    For " 'static_cast' : cannot convert from 'UINT ...", I find that function and change UINT THAT_FUNCTION(...) to LRESULT THAT_FUNCTION(...).
    For " 'afxChNil' : undeclared identifier", find "afxChNil" and put it NULL, it worked just ok for me.
    By the way ,I use the compiler VS2005~~~
    QuestionWho can help me ?memberforhappy200920-Aug-09 18:25 
    I'm trying to add the CSizingControlBar class to my project,but before I compile the demo project downloaded from the site http://www.codeproject.com/KB/toolbars/sizecbar.aspx there are some errors,like:
     

    error C2065: 'afxChNil' : undeclared identifier h:\课程设计\sizecbar_src\src\sizecbar.cpp 1297
    error C2440: 'static_cast' : cannot convert from 'UINT (__thiscall CSizingControlBar::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint)' h:\课程设计\sizecbar_src\src\sizecbar.cpp 108
     

     
    I'm so confused!so I really appreciate it if anyone can give me a hand!
     
    My email:258347328@qq.com
    QuestionHow show a CListView On the CSizingContralBar?memberluoxing12-Aug-09 3:31 
    I have a program that create by MDI. It need a CSizingContralBar show the CListView, and show image in the CChilfFrame.
    I have implement a CMyListView class inherit from CListView , and how I show it on the CSizingContralBar. Thanks!
    QuestionGDI Resource Leak?memberAndornot27-Jul-09 18:51 
    Has anyone experienced any GDI resource leaks using CSizingControlBar?
    Specifically, when using it with MFC's CTreeCtrl?
     
    I may be getting some strange font leaks related to the Font Tahoma (size 8) ?
     
    It happens randomly, so I can't reproduce it. I don't know what causes it.
    The controls are always docked when this happens.
     
    I'm using a free tool called GDIUsage:
    http://msdn.microsoft.com/en-us/magazine/cc188782.aspx
    GeneralCSizingControlBar with VS2005 and Windows XPmemberkassinen20-Jul-09 21:22 
    Hi,
     
    Thank you for an excellent article. Sizing controlbar is awesome but...
    I have a problem with the docked state of the sizing controlbar. I have derived a class from CSizingControlBarG, but I can't get it working right when it is in docked state. 1. I cant resize the bar. 2. I cant grab the bar from the gripper. 3. I cant close the bar from the x. I can do all this when the bar is floating, but I want the bar to be docked all the time.
     
    Thank you already
    Questionsizecbar for Unicode?memberAndornot25-May-09 13:17 
    Hi,
    When I try to compile this library using Microsoft Visual Studio 2005, with Unicode char set, the gripper bar
    for docked controls are painted white.
     
    I don't think this problem is related to whether platform is 32-bit or 64-bit. It only appears when project
    is compiled for Unicode.
     
    How to fix?
    Generalsizecbar for 64-bit platform? [modified]memberAndornot22-May-09 0:40 
    Has anyone compiled this library for a 64-bit platform? I've successfully compiled it (only had to change GCL_HBRBACKGROUND to GCLP_HBRBACKGROUND),
    however, the gripper for docked controls are white! How to fix this problem?
     
    In CSizingControlBar::OnNcPaint(),
    I had to change GetClassLong to GetClassLongPtr and also added UlongToPtr.
     
        // erase the NC background
    	mdc.FillRect(rcDraw, CBrush::FromHandle( (HBRUSH)UlongToPtr(::GetClassLongPtr(m_hWnd, GCLP_HBRBACKGROUND))));
    
     
    However, the gripper is still painted white. Any suggestions?
     

    I also have some other warnings. Not sure if they're related to painting:
    Compiling...
    sizecbar.cpp
    .\lib\sizecbar.cpp(267) : warning C4244: 'argument' : conversion from 'INT_PTR' to 'int', possible loss of data
    .\lib\sizecbar.cpp(775) : warning C4244: 'initializing' : conversion from 'INT_PTR' to 'int', possible loss of data
    .\lib\sizecbar.cpp(884) : warning C4244: 'initializing' : conversion from 'INT_PTR' to 'int', possible loss of data
    .\lib\sizecbar.cpp(920) : warning C4244: '=' : conversion from 'INT_PTR' to 'int', possible loss of data
    .\lib\sizecbar.cpp(1001) : warning C4244: 'initializing' : conversion from 'INT_PTR' to 'int', possible loss of data
    

     
    modified on Sunday, May 24, 2009 1:34 AM

    Questioncan add resourceo of dialog to CSizingControlBar ? I want have a style like the property Bar of VS2005 !memberzhangshaobing5178-Apr-09 7:24 
    can add resourceo of dialog to CSizingControlBar ? I want have a style like the property Bar of VS2005 !
     
    My english is bad, so....Maybe I can not experss my question >..sorry! But I want your helps!
    QuestionAbout docking quesitonmemberyufenghao3-Sep-08 17:28 
    Hi, all,
     
    Here I want to create two tabs in one SDI application, I wish the frame look like below:
     
    000000000
    000000000
    000000000
    000000000111111111111111
    000000000111111111111111
    000000000111111111111111
     
    But using csizingcontrolbar, two tabs are created, but looke like below and can not changed:
     
    000000000
    000000000
    000000000
    111111111111111111111111
    111111111111111111111111
    111111111111111111111111
     

    Does anyone tell me how to modify??
     
    Regards
     
    -yufeng
     
    Email: logicbean@hotmail.com, yufenghao@gmail.com
    AnswerRe: About docking quesitonmembertangversion2-Oct-08 21:27 
    I am also asking the same question.
     
    But I try a method, modefy fuc: CalcFixedLayout, But did not succeed.
    AnswerRe: About docking quesitonmembertangversion2-Oct-08 21:53 
    you can try modify funciton NegotiateSpace
    AnswerRe: About docking questionmemberPaul Darlington14-Jan-10 4:02 
    It depends upon the sequence of the calls to EnableDocking(); probably in your CMainFrame class.
    To get the first example (illustrated in the question) call:
     
    EnableDocking(CBRS_ALIGN_TOP);
    EnableDocking(CBRS_ALIGN_LEFT);
    EnableDocking(CBRS_ALIGN_BOTTOM);
    EnableDocking(CBRS_ALIGN_RIGHT);
     
    To get the second example change the order as follows:
     
    EnableDocking(CBRS_ALIGN_TOP);
    EnableDocking(CBRS_ALIGN_BOTTOM);
    EnableDocking(CBRS_ALIGN_LEFT);
    EnableDocking(CBRS_ALIGN_RIGHT);
    GeneralIt Captures Mouse messages of Main Windowmembertheali5-Aug-08 21:44 
    Hi
     
    Any one experienced that while Floating it captures the mouse messages and make the Main Window disabled.
     
    Where as it releases if we dock it back to main window.
     
    Any help?
     
    VC++,COM ,C#

    GeneralLimited size when docking and sizing, Solved. [modified]memberc.nicos21-Jun-08 4:13 
    Hi, all
    I'm a newbie of MFC world.
    Here goes my first meaningful reply on CP:
     
    After digging in the code and MSDN( at the very first, in the replies of cource), AND messing up with
    OnSize()
    ,
    OnMouseMove()
    ,
    OnTrackUpdateSize()
    ...
    I can't find a acceptable way to accomplish the goal. cos Windows don't send mouse messages the way I thought. And I can't get a WM_GETMINMAXINFO notify of the controlbar, maybe the message pump in the base class just ignored it. A explanation is appreciated!!!
    finally I got
    CalcDynamicLayout()
    , which I thought is the key. But I can't quite understand the usage of the function, after reading MSDN and the source code I got even more confused Cry | :((
     
    But, hey, the the
    CalcDynamicLayout()
    in our base class did the whole mess right? Then, Why just use the value it returned and Only check for the limitation? Here goes:
    CSize CNicoSBar::CalcDynamicLayout(int nLength, DWORD dwMode)
    {
        CSize szRet = myBase::CalcDynamicLayout(nLength, dwMode);
        
        // Check for limits:
        CRect rcClient;
        GetDockingFrame()->GetClientRect(rcClient);
        
        if( szRet.cx > rcClient.Width() / 2 )
        {
            szRet.cx = rcClient.Width() / 2;
        }
        // Check for cy:
        .
        .
        .
        return szRet;
    }
    
    Done!
    NOTE: this affects only the docking mode, I still can't find a perfect way to limit the size of it when it is in floating mode. But maybe we hardly needed that feature(hopefully). Poke tongue | ;-P
     
    modified on Saturday, June 21, 2008 10:29 AM
     
    modified on Saturday, June 21, 2008 10:30 AM

    GeneralRe: Limited size when docking and sizing, Solved.memberJake Jun11-Aug-08 19:39 
    Really thank you for your information..^^
    GeneralRe: Limited size when docking and sizing, Solved.memberc.nicos14-Aug-08 22:39 
    I'm glad it helped.
     
    I want to make more friends all over the world.
    I love StarCraft and some ACT video games.
    MSN: c.nicos@hotmail.com
    Welcome to China, Welcome to Beijing!
    And don't forget to bring your XBOX 360
     
    pad Smile | :)

    GeneralRe: Limited size when docking and sizing, Solved.memberBigsteve8719-Aug-11 7:38 
    Another thanks for this one. You really saved me alot of time. Thumbs Up | :thumbsup:
    GeneralRe: Limited size when docking and sizing, Solved.memberc.nicos19-Aug-11 21:14 
    Glad it helped.
    After years, a simple message can still help others, that's the beauty of the internet!
    BTW, MFC is dead. Why not give .Net a try.
    I want to make more friends all over the world.
    I love StarCraft and some ACT video games.
    MSN: c.nicos@hotmail.com
    Welcome to China, Welcome to Beijing!
    And don't forget to bring your XBOX 360
     
    pad Smile | :)

    Generalchanging caption of floating toolbar dynamicallymemberhari prasad sathpadi17-Jun-08 19:54 
    I have created a toolbar derived from CToolBar class.
    by default i kept caption of toolbar as some "abc".
    i made the toolbar to floating state. then caption shows as abc. thats fine
     
    but when i select any of the menu option i want to change the caption of floating toolbar dynamically.
     
    when the toolbar is docked & brought to floating position caption is changing. But i dont want to dock the toolbar, it should be always be floating. and the title should change when toolbar is in floating.
     

    plz can any one help on this.
    GeneralAccelerators Copy, Paste, Select All ...memberJulian Popov14-Apr-08 3:19 
    Is there a way Ctrl+A (Select All), Ctrl+C (Copy), Ctrl+V (Paste) ... to start working in a sizebar edit box control (Demo1) when its on focus?
     
    ??????????????????????????????

    GeneralTabbed?!membercorax@inbox.com16-Dec-07 15:24 
    Hi there, thanks for the great code. Any plans, or help Big Grin | :-D , to futher the code by adding a tabbed option ala VS dev ide? I had a go but didn't go well!! Sigh | :sigh:
     
    Cheers
    QuestionCSizingControlBar -- Help&#65281;who can help me&#65311;memberzhujt198129-Oct-07 19:56 
    Hello everyone
    I have used the CSizingControlBar in my MDI Program;but a Gray Rectange was find in the bar! I don't why it is.
    Who can help me!
    GeneralCSizingControlBar - a resizable control barmemberSOUMEN BISWAS26-Sep-07 0:02 
    Indeed it's a nice tool in VC++. Thanks to bob19672 for providing me the link info. I've utilised the suggestions in getting a dockable bar in my application. But I could not able to implement the to and fro Error Message passing both from Transmit and Receive ends.
     
    I am developping one application in VC++ ver-6.0 using MFC. The Main Frame Window is divided into 2 using CreateStatic function of CSplitterWnd Class , upon one of which a Runtime Class namely CErrMsgView (Base Class CScrollView) is being attched. The other one, ( is again sub-divided into 2 with CreateStatic. Again it is being attached with 2 Run Time classes namely CMainView and CStatView (Base Class CFormView) respectively.
     
    The CErrMsgView Class is meant to capture all the Messages being transferred to and fro. I would like to add an option under the View Menu Heading "Show/Hide ErrMsg View". The Clck on which alternately Show or hide the ErrMsgView. Would You Please Help Me Out.
    .
     
    Initially in my application, I have used a Run Time Class ClogView derived from CScrollView and mapped to one SplitterWindow in CMainFrame control all the messaging in my application.
     
    Can You Please tell me how to map the MyBar docked control bar to use as a error message viewer.
     
    Thank You and Best Regards.
     
    Soumen Biswas
    QuestionHow to set the size of CSizingControlBars docked on the same row/column?memberMerlin Ran11-Sep-07 23:21 
    I want to place two CSizingControlBars on the bottom of my main frame, I use the same technique as presented in Demo2 of the downloaded source code:
     
         DockControlBar(&m_alarmBar, AFX_IDW_DOCKBAR_BOTTOM);
         RecalcLayout();
         CRect rBar;
         m_alarmBar.GetWindowRect(rBar);
         rBar.OffsetRect(1, 0);
         DockControlBar(&m_eventBar, AFX_IDW_DOCKBAR_BOTTOM, &rBar);
     
    The problem is that I can't control the horizonal size of each bar. If I set m_szHorz in ctor of my CSizingControlBarCF descendant, its cy has effect but cx doesn't. The only clue I found is that these two bars are the childs of the same AfxControlBar42d, but I don't know how it affects.
    I'm not proficient on MFC or Windows GUI programming, any guru could give me a hint? Thanks in advance.
    GeneralIs possible to use your control on a Dialog Based applicationmemberrbid21-May-07 20:48 
    Hello,
     
    I would like to use this control in a Dialog Based application (Not single/multiple Document application).. Is this possible?
    Any hint on how to implement this?
     
    Thanks in advance.
     

     
    -- Ricky Marek (AKA: rbid)
    -- "Things are only impossible until they are not" --- Jean-Luc Picard
     
    My articles
     

    QuestionChange border color &amp; Thin bordersmemberrm_pkt24-Jan-07 17:27 
    Thanks for the nice article.
    I have some doubts...Please
    How can I change the border color of the CSizingControlBar Window
    And also making border thin?
     
    Thanks in adavnce.
     
    rm_pkt
    GeneralDialog WindowmemberC0LDZ3R019-Jan-07 9:06 
    There is a problem with dialog based mfc applications. in colxpbar.c(1722):
     
    static void APIENTRY CalcPaneHeightsRecursive ( PPANECTRL pPC,
    int xorig,
    int *pxmin, int *pymin,
    int *pxmax, int *pymax,
    int iPaneWidthMin, int iPaneWidthMax )
    {
    SIZE siMin,siMax;
    BOOL bUpdated=FALSE;
     
    siMin.cx = siMin.cy = siMax.cx = siMax.cy = 0;
     
    if (pPC->bPDCControl) <- here stops my debugger


    i commented out all calls of this function, and now it works.
    Generalsuggested feature [modified]memberbquintero9-Jan-07 20:52 
    I've found it useful to add the following in my own project.
     
    I added a member variable:

    BOOL m_bDragLocked; // enabling this causes a docked controlbar to be locked

     
    I added two member functions:

    const BOOL CSizingControlBar::IsLocked() const
    {
    return !IsFloating() && m_bDragLocked;
    }
     
    void CSizingControlBar::EnableLock(BOOL bLockDrag)
    {
    m_bDragLocked = bLockDrag;
    }

     
    I changed one line of code:

    void CSizingControlBar::OnLButtonDown(UINT nFlags, CPoint point)
    {
    if (m_pDockBar != NULL && !IsLocked()) // Control may be locked
    ...

     
    I wouldn't want to add a whole new class for such a small feature but I found it to be useful in my project and highly suggest it as part of the base class implementation. This will allow the control to still be resized but not undocked.
     

     
    Hope that helped someone,
    Ben Quintero
     

     
    -- modified at 3:02 Wednesday 10th January, 2007
    Questionproblem with position of the dockbars [modified]memberChoi Sunok25-Dec-06 19:49 
    I have a problem with position of the dockbars.
     
    I created three docking bars.
    one is on the left, one is on the right
    and the other one is on the bottom.
     
    I want to locate three docking bars like this.
    ---------------------------
    &#9474;         &#9474;                              &#9474;         &#9474;
    &#9474;         &#9474;                              &#9474;         &#9474;
    &#9474;bar1 &#9474;                                 &#9474;bar2&#9474;
    &#9474;         &#9474;                              &#9474;         &#9474;
    &#9474;         &#9474;                              &#9474;         &#9474;
    &#9474;         &#9474;---------------&#9474;         &#9474;
    &#9474;         &#9474;         bar3            &#9474;         &#9474;
    &#9474;         &#9474;                              &#9474;         &#9474;
    -------------------------------
     
    does anybody know about this problem?
     
    help me please.
    thanks.
     

     

     
    -- modified at 1:56 Tuesday 26th December, 2006
    GeneralTo avoid warning 4312memberpnugoodman20-Nov-06 19:53 
    sizecbar.cpp - line 536
     
    mdc.FillRect(rcDraw, CBrush::FromHandle(
    (HBRUSH) (DWORD_PTR) GetClassLong(m_hWnd, GCL_HBRBACKGROUND)));

    QuestionGetting the message handler for Toolbar in Sizing control barmembershailesh429-Oct-06 19:13 
    In Sizing control bar, I have added one dialog. On that dialog, I have added one ToolBar. In that dialog's Message Map, I have added Command Handler for the ToolBar buttons. But button doesn't get Command Handler, so it is disabled.
     
    If I add command handler on MainFrame, then it works properly.
     
    Why it happens?
    Is anyone can answer?
     
    Thnaks for your co-operation.
    QuestionWhen control bar is floating,i can,t receive message .memberchihyu12-Oct-06 23:20 
    Dear all,
    When i use this class, i use CListView in my control bar .
    Then i can into mylistview::OnInitialUpdate() in docking window,but is can't int mylistview::OnInitialUpdate() in floating window. If you have any suggest, please let me kCry | :(( now thanks!
     
    chihyuchen

    QuestionCan we add multiple dialogs in control bar with only one is shown at a time?membershailesh410-Oct-06 3:46 
    This is a very Nice control.
    I have used this control in many applications.
     
    But I have one application which requires multiple dialogs in Control Bar.
     
    Depending upon some button click, I have to show different dialog in Control Bar & hide the previous one.
    Is this possoble & If yes, can you please tell me how?
     
    Thanks for developing this nice control.
    & also thanks for your Help in advance.
    -Shailesh
     

    Questionfloating,how to change width and height of the bar?memberChris_kun10-Sep-06 18:54 
    when the bar floating,how to change width and height of the bar through program?
    AnswerRe: floating,how to change width and height of the bar?memberThe Yariv9-Nov-08 20:18 
    I have the same question , anyone?
    GeneralImprovement for multiple controlsmemberSource13-Aug-06 14:07 
    I have updated the CSizingControlBar so that multiple controls are allowed and can be correctly resized. Does anybody know where I can post this changes or how I can inform the author?
    Greetings
    QuestionRe: Improvement for multiple controlsmemberRoy F.1-Sep-06 1:40 
    Are your changes small enough to post in a reply to this thread? I am having trouble with CSizingControlBar::OnTrackUpdateSize(). The line that reads "CSizingControlBar* pBar = arrSCBars[nGrowingBar];" can assert (debug) or throw (release) due to nGrowingBar being out of range. This problem sometimes occurs when dragging a resize bar to the bottom of the frame. I just started looking into this and do not have a fix yet. Does your fix address this problem?
     
    Roy F.
    AnswerRe: Improvement for multiple controlsmemberSource1-Sep-06 1:51 
    At first, my fixes do not address the issue you mentioned, sorry.
    Second, my changes are not very large, but too large to post them
    in a reply. If it is allowed, I could post a link here for downloading
    my changes.
     
    Markus

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Permalink | Advertise | Privacy | Mobile
    Web03 | 2.6.130617.1 | Last Updated 16 Aug 2000
    Article Copyright 1999 by Cristi Posea
    Everything else Copyright © CodeProject, 1999-2013
    Terms of Use
    Layout: fixed | fluid