Docking toolbars side by side in an MDIChildFrame
I have an mdi application where the mdi child frame has two toolbars. I can get these to dock nicely, but they are on two rows rather than one.
I've read the following article but it doesn't work for mdichildframe, so now I'm stuck.
http://www.codeguru.com/Cpp/controls...icle.php/c2553
Thanks.
Re: Docking toolbars side by side in an MDIChildFrame
*What* does not work for "mdichildframe"?
Re: Docking toolbars side by side in an MDIChildFrame
The toolbars dock on two rows rather than side by side; the same code works fine when I put the toolbars on the main mdi frame, just not for the child frame.
Re: Docking toolbars side by side in an MDIChildFrame
Debug the code you are using for child frame toolbars and compare its behaviour with the one used for mainframe toolbars.
Note that by design toolbars consider to belong to the mainframe window!
Re: Docking toolbars side by side in an MDIChildFrame
I followed the code through but as far as I can tell they do the same thing. Obviously, that isn't the case, but I am having trouble finding it.
I've uploaded the file to http://privatepaste.com/a20QHmz7CG so perhaps you can take a look and give me a hint where to look. The link will be available for the next month.
I did notice that only the split window results in the docking code reaching the statement where it "adds to the current row"...but that comment is the opposite of what I'm seeing, so it may just be a red herring.
Re: Docking toolbars side by side in an MDIChildFrame
Quote:
Originally Posted by
rioch
And why don't you want to attach your ptoject to your post in this thread? :confused:
Pack it in zip archive (not including Debug/Release folders nor .ncb/.aps/.opt files) and attach! (have a look at the Manage Attachments button in Additional Options section (under the message window)
1 Attachment(s)
Re: Docking toolbars side by side in an MDIChildFrame
Sorry, I was using the quick post dialog so didn't see that you could attach here. I've attached it now with all the unrequired files deleted.
Re: Docking toolbars side by side in an MDIChildFrame
Quote:
Originally Posted by
rioch
I have an mdi application where the mdi child frame has two toolbars.
Well your application in NOT a *mdi* one! It is an SDI app with one of the "views" being derived from CFrameWnd rather than CView class.
And there is only one document is allowed (you are using CSingleDocTemplate).
Re: Docking toolbars side by side in an MDIChildFrame
Ok, that's a glaring mistake, but it shouldn't be the cause of the problem though, should it?
Re: Docking toolbars side by side in an MDIChildFrame
Your big mistake is using the same toolbar ID for your both bars:
Quote:
Code:
if (!m_wndToolBar1a.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY) ||
!m_wndToolBar1a.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
...
// TOOLBAR 1b
if (!m_wndToolBar1b.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY) ||
!m_wndToolBar1b.LoadToolBar(IDR_MAINFRAME))
// edit:
Sorry, the problem is not in LoadToolBar but in your CreateEx call where the default toolbar ID = AFX_IDW_TOOLBAR is used for both toolbars.
Re: Docking toolbars side by side in an MDIChildFrame
The same toolbar ID (AFX_IDW_TOOLBAR) is used in MainFrm and it works fine there. Plus, if I use unique ids in SplitFrame (AFX_IDW_TOOLBAR+n) I still get the same problem.
Re: Docking toolbars side by side in an MDIChildFrame
Quote:
Originally Posted by
rioch
The same toolbar ID (AFX_IDW_TOOLBAR) is used in MainFrm and it works fine there.
It is only a delusion that "it works fine". Try to use different toolbars with the same toolbar ID and you see the problems.
Re: Docking toolbars side by side in an MDIChildFrame
My point was, the toolbars still appear next to one another. Are you saying that if I use different toolbar resource ids and different AFX_IDW_TOOLBAR ids, it will work?
Re: Docking toolbars side by side in an MDIChildFrame
Quote:
Originally Posted by
rioch
... Are you saying that if I use different toolbar resource ids and different AFX_IDW_TOOLBAR ids, it will work?
No, I am not.
Your design is not a standard one, I never had such types of child windows (derived from CFrameWnd and having toolbars), so I don't know where the main problem is. But anyway, you must first fix all already obvious bugs in your implementation.