CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Location
    UK (South)
    Posts
    93

    How Can I predetermine the position of ToolBar?



    My second ToolBar when create sits directly underneath the standard ToolBar.


    I want it to be by the side.


    How do I do this?


    Simon Pettman


    Research Engineer

    Goodmans Loudspeakers Ltd

    [email protected]

  2. #2

    Re: How Can I predetermine the position of ToolBar?

    There is no CBRS_NO_ALIGN
    #define CBRS_NO_ALIGN 0X0000L do this in the stdafx.h and it's used everywhere

    m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    to
    m_wndToolBar.EnableDocking ( CBRS_NO_ALIGN );

    Then Float the tool bar and set it's position as needed

    FloatControlBar(&m_wndToolBar,CPoint(200,200));

    regards
    Hans Wedemeyer



  3. #3
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: How Can I predetermine the position of ToolBar?

    Try this function which I found on the MSDN and is also on this site.
    As you can see it should be a member of your CMainFrame class.


    void CMainFrame:ockControlBarLeftOf( CToolBar* RightBar, CToolBar* LeftBar )
    {
    CRect rect;
    DWORD dw;
    UINT n;

    // get MFC to adjust the dimensions of all docked ToolBars
    // so that GetWindowRect will be accurate
    RecalcLayout();
    LeftBar->GetWindowRect(&rect);
    rect.OffsetRect(1,0);
    dw = LeftBar->GetBarStyle();
    n = 0;
    n = (dw & CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
    n = (dw & CBRS_ALIGN_BOTTOM && n==0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
    n = (dw & CBRS_ALIGN_LEFT && n==0) ? AFX_IDW_DOCKBAR_LEFT : n;
    n = (dw & CBRS_ALIGN_RIGHT && n==0) ? AFX_IDW_DOCKBAR_RIGHT : n;

    // When we take the default parameters on rect, DockControlBar will dock
    // each Toolbar on a seperate line. By calculating a rectangle, we in effect
    // are simulating a Toolbar being dragged to that location and docked.
    DockControlBar(RightBar,n,&rect);
    }




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured