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

    How can I determine where my CControlBar is now docked?

    I want to know on which side my CControlBar is docked.
    Please help!

    Mike

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

    Re: How can I determine where my CControlBar is now docked?

    Try CFrameWnd::GetDockState
    Victor Nijegorodov

  3. #3
    Join Date
    Oct 2000
    Posts
    44

    Re: How can I determine where my CControlBar is now docked?

    CFrameWnd::GetDockState saves the status in the registry, but I want to save it at a different place!

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

    Re: How can I determine where my CControlBar is now docked?

    No! It is CFrameWnd::SaveBarState that "saves the status in the registry".
    And CFrameWnd::GetDockState stores state information about the frame window's control bars in a CDockState object you are passing in it!
    Victor Nijegorodov

  5. #5
    Join Date
    Oct 2000
    Posts
    44

    Re: How can I determine where my CControlBar is now docked?

    Ok, but what can I do with CDockState? There is only LoadState(), SaveState() and GetVersion() as memberfunctions.

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

    Re: How can I determine where my CControlBar is now docked?

    And would you like?
    Your OP sounds:
    Quote Originally Posted by mike_mc1
    I want to know on which side my CControlBar is docked
    So the CFrameWnd::GetDockState gives you the CDockState object, CDockState::m_arrBarInfo contains pointers to the stored control bar information (CControlBarInfo) for each control bar and the CRect CControlBarInfo::m_rectMRUDockPos is the "most recent docked position" of the toolbar.

    But if you only want to save toolbar data at a different place than the CFrameWnd::SaveBarState does then your task is more simple! You could either use CDockState methods or develop your own ones + CFrameWnd::GetDockState/SetDockState to get/set the dock state data.
    Victor Nijegorodov

  7. #7
    Join Date
    Oct 2000
    Posts
    44

    Re: How can I determine where my CControlBar is now docked?

    I have no documentation found in the msdn for CControlBarInfo. So I really don't know how to access to the interesting data for me and to write my own CFrameWnd::GetDockState/SetDockState.
    Last edited by mike_mc1; March 19th, 2008 at 11:37 AM.

  8. #8
    Join Date
    Nov 2001
    Posts
    251

    Re: How can I determine where my CControlBar is now docked?

    Try this:

    Code:
     CDockState state;
     GetDockState(state);
    
     for (INT i=0; i < state.m_arrBarInfo.GetSize(); i++) {
    
        CControlBarInfo* pInfo = (CControlBarInfo*)state.m_arrBarInfo[i];
    
        for (INT j=0; j < pInfo->m_arrBarID.GetSize(); j++) {
    
           if(pInfo->m_arrBarID[j] == MY_BAR_ID) {
    
              switch(pInfo->m_nBarID) {
                 case AFX_IDW_DOCKBAR_LEFT: break;		// docked on left side
                 case AFX_IDW_DOCKBAR_RIGHT: break;		// docked on right side
                 case AFX_IDW_DOCKBAR_TOP: break;		// docked on top side
                 case AFX_IDW_DOCKBAR_BOTTOM: break;	// docked on bottom side	
              }
           }
        }
     }

  9. #9
    Join Date
    Oct 2000
    Posts
    44

    Re: How can I determine where my CControlBar is now docked?

    OK thx! But with this code i know only the docking side, but not the exactly last position of the CControlBar.

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

    Re: How can I determine where my CControlBar is now docked?

    I already pointed out that the last bar position (the "most recent docked position") is saved in CControlBarInfo::m_rectMRUDockPos member.
    Victor Nijegorodov

  11. #11
    Join Date
    Oct 2000
    Posts
    44

    Re: How can I determine where my CControlBar is now docked?

    Thx again!

    But I am using CSizingControlBar http://www.codeproject.com/KB/toolbars/sizecbar.aspx

    When the user dock the CSizingControlBar I can use 'm_rectMRUDockPos', but after the user is changing the size, this values are not usefull.

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

    Re: How can I determine where my CControlBar is now docked?

    Well, in yor OP you asked about CControlBar ...
    Now you ask about some other ("black box" for the most of us) class
    Why don't you ask the author of this article?
    Victor Nijegorodov

  13. #13
    Join Date
    Jul 2001
    Posts
    306

    Re: How can I determine where my CControlBar is now docked?

    Quote Originally Posted by VictorN View Post
    I already pointed out that the last bar position (the "most recent docked position") is saved in CControlBarInfo::m_rectMRUDockPos member.
    my code say always m_rectMRUDockPos==CRect(0,0,0.0) for all my toolbars?
    Andy ideas, why?

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

    Re: How can I determine where my CControlBar is now docked?

    How did you find out that
    Quote Originally Posted by Ralf Schneider
    code say always m_rectMRUDockPos==CRect(0,0,0.0) for all my toolbars
    How does your code look like?
    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