Click to See Complete Forum and Search --> : How Can I predetermine the position of ToolBar?


Simon Pettman
April 1st, 1999, 08:47 AM
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

pettman.s@gll.co.uk

Hans Wedemeyer
April 2nd, 1999, 12:54 PM
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

Gomez Addams
April 2nd, 1999, 01:04 PM
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::DockControlBarLeftOf( 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);
}