|
-
September 24th, 2003, 08:59 AM
#1
Sticky Toolbars ... ?
When creating a toolbar, how can I create a toolbar, that will stick to any of the 4 side of an MDI envirmonment ...
So that when you click and drag, that the toolbar can't be a toolbox, instead, can only be "dockable" to the left, right, bottom, top sides ...
Normally if one create a toolbar, the toolbar can be removed and float freely, I want to remove the floating setting, and rather have it dock automatically to either of the 4 sides .... How should I go about creating this ...
I had a look at some examples that the MSDN supplied, but it's not entirely what I want, I've read up on this also, an I came across the OnCreate where the Code is generated for creation of toolbar ...
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
now if I want to create a second toolbar, but I would like this to be "sticky", I should alter the code here, and add another toolbar, and set it's properties, but what properties needs to be set .. ?
Because I don't want the toolbar "floating", I want it to be "sticky" to either of the 4 sides ... ? And I think I've got it right when I say I need to use the method EnableDocking()
dwStyle
Specifies whether the control bar supports docking and the sides of its parent window to which the control bar can be docked, if supported. Can be one or more of the following flags:
CBRS_ALIGN_TOP Allows docking at the top of the client area.
CBRS_ALIGN_BOTTOM Allows docking at the bottom of the client area.
CBRS_ALIGN_LEFT Allows docking on the left side of the client area.
CBRS_ALIGN_RIGHT Allows docking on the right side of the client area.
CBRS_ALIGN_ANY Allows docking on any side of the client area.
CBRS_FLOAT_MULTI Allows multiple control bars to be floated in a single mini-frame window.
If zero, that is, indicating no flags, the control bar does not dock.
but now this if I got it right, should also be monitored with the MOUSE movement, if the mouse is in the middle left I can dock it with the style CBRS_ALIGN_LEFT, ect.
1. Is there a way to bypass mouse tracking to set the style of the toolbar, and rather set one of it's properties to make it dock by default to the closest side it is on?
2. When creating a toolbar, how can I dynamically add/remove extra buttons (but they should have the style of depressed buttons, and only one can be depressed at a time) in run-time ?
Thanx in advance ...
xIRC
-
September 25th, 2003, 02:07 PM
#2
Does anyone know ... ?
I have read most of the articles I found on code guru, nothing really explains to me, about docking ...
What I basically want is, to be able to dock a toolbar to the left, right, bottom, top sides, but I don't want the toolbar to be floatable ... (this is done in an MDI environment).. any help on this maybe please
Thanx in advance ...
xIRC
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|