CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14
  1. #1
    Join Date
    Dec 2008
    Posts
    29

    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.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Docking toolbars side by side in an MDIChildFrame

    *What* does not work for "mdichildframe"?
    Victor Nijegorodov

  3. #3
    Join Date
    Dec 2008
    Posts
    29

    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.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    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!
    Victor Nijegorodov

  5. #5
    Join Date
    Dec 2008
    Posts
    29

    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.

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Docking toolbars side by side in an MDIChildFrame

    Quote Originally Posted by rioch View Post
    II've uploaded the file to http://privatepaste.com/a20QHmz7CG
    And why don't you want to attach your ptoject to your post in this thread?
    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)
    Victor Nijegorodov

  7. #7
    Join Date
    Dec 2008
    Posts
    29

    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.
    Attached Files Attached Files

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Docking toolbars side by side in an MDIChildFrame

    Quote Originally Posted by rioch View Post
    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).
    Victor Nijegorodov

  9. #9
    Join Date
    Dec 2008
    Posts
    29

    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?

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Docking toolbars side by side in an MDIChildFrame

    Your big mistake is using the same toolbar ID for your both bars:
    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.
    Last edited by VictorN; June 23rd, 2009 at 05:21 AM.
    Victor Nijegorodov

  11. #11
    Join Date
    Dec 2008
    Posts
    29

    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.

  12. #12
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Docking toolbars side by side in an MDIChildFrame

    Quote Originally Posted by rioch View Post
    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.
    Victor Nijegorodov

  13. #13
    Join Date
    Dec 2008
    Posts
    29

    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?

  14. #14
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Docking toolbars side by side in an MDIChildFrame

    Quote Originally Posted by rioch View Post
    ... 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.
    Victor Nijegorodov

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