Make undockable
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: Make undockable

  1. #1
    Join Date
    Mar 2012
    Posts
    7

    Make undockable

    I want to dock CDialogBar to the top of window in the code, and after that how can I make it impossible to dock-undock it with the mouse when app is running?

    When I write

    DlgBar->EnableDocking(CBRS_ALIGN_TOP);
    MainFrame->DockControlBar(DlgBar, AFX_IDW_DOCKBAR_TOP);
    DlgBar->EnableDocking(0);

    It is placed at the top, as I wanted, but I can undock it with the mouse, and after that it can't dock to any side. How can I prevent it from being undocked?

  2. #2
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,021

    Re: Make undockable

    Just create it using CBRS_TOP style.
    Code:
       DWORD dwStyle =  WS_CHILD | WS_VISIBLE | CBRS_TOP;
       VERIFY(m_dialogBar.Create(this, IDD_DIALOGBAR, dwStyle, AFX_IDW_DIALOGBAR));
    No further other call.
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

  3. #3
    Join Date
    Mar 2012
    Posts
    7

    Re: Make undockable

    Quote Originally Posted by ovidiucucu View Post
    Just create it using CBRS_TOP style.
    Code:
       DWORD dwStyle =  WS_CHILD | WS_VISIBLE | CBRS_TOP;
       VERIFY(m_dialogBar.Create(this, IDD_DIALOGBAR, dwStyle, AFX_IDW_DIALOGBAR));
    No further other call.
    thanks
    Last edited by Oleksii; March 16th, 2012 at 12:15 PM.

  4. #4
    Join Date
    Mar 2012
    Posts
    7

    Re: Make undockable

    Quote Originally Posted by ovidiucucu View Post
    Just create it using CBRS_TOP style.
    Code:
       DWORD dwStyle =  WS_CHILD | WS_VISIBLE | CBRS_TOP;
       VERIFY(m_dialogBar.Create(this, IDD_DIALOGBAR, dwStyle, AFX_IDW_DIALOGBAR));
    No further other call.
    And if I want to have several CControlBars in my Frame, and other ones I docked to the top, if I create DialogBar this way, it is always below docked one, how can I make it to be on the very top?

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,373

    Re: Make undockable

    Did you try CFrameWnd::DockControlBar?
    Victor Nijegorodov

  6. #6
    Join Date
    Mar 2012
    Posts
    7

    Re: Make undockable

    Quote Originally Posted by VictorN View Post
    Did you try CFrameWnd::DockControlBar?
    Yes, it is shown in the first post.

    I describe the problem again:
    I have several CControlBars. All of them must bu on the top of my frame. And first from the top must be CDialogBar, but that CDialogBar must be undockable. The other CControlBars I dock to the window with DockControlBar, and if I use DockControlBar to my CDialogBar control, it can be undocked with mouse, So the question is still the same - how can it be prevented to be undocked

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,373

    Re: Make undockable

    Quote Originally Posted by Oleksii View Post
    Quote Originally Posted by VictorN View Post
    Did you try CFrameWnd::DockControlBar?
    Yes, it is shown in the first post.
    I meant, did you try to use the third parameter of DockControlBar?
    Victor Nijegorodov

  8. #8
    Join Date
    Mar 2012
    Posts
    7

    Re: Make undockable

    Quote Originally Posted by VictorN View Post
    I meant, did you try to use the third parameter of DockControlBar?
    When I do DockControlBar to CDialogBar, it can be undocked, when just create it, adding third parameter when I create other controls doesn't help - CDialogBaris still under all other controls

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,373

    Re: Make undockable

    Could you show your code?
    Victor Nijegorodov

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,373

    Re: Make undockable

    Quote Originally Posted by Oleksii View Post
    ... So the question is still the same - how can it be prevented to be undocked
    Have a look at Locking Rebars and Toolbars article.
    Victor Nijegorodov

  11. #11
    Join Date
    Mar 2012
    Posts
    7

    Re: Make undockable

    Quote Originally Posted by VictorN View Post
    Have a look at Locking Rebars and Toolbars article.
    I founded that one, with CDialogBar it's not that simple )

    So finally I decided this way - I dock every control, but after that I just handle mouse events for my CDialogBar to prevent it from being undocked.

    Thanks everyone for attention and help.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center