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

Thread: CDockablePane questions

  1. #1
    Join Date
    Aug 2006
    Posts
    80

    CDockablePane questions

    I'm rebuilding a MFC MDI application with the new extended classes (CMDIFrameWndEx, etc) in Visual Studio 2010. All OK except for some CDialogBars that I have some trouble regarging keeping same behaviour when using panes instead.

    1. How to disable or prevent resizing of a CDockablePane?

    I have tried various approaches without any luck...
    - Create with dwControlBarStyle excluding AFX_CBRS_RESIZE
    - Create with dwStyle including CBRS_SIZE_FIXED
    - SetResizeMode RESIZE_NO
    - Overriding OnSize

    2. How to enable docking of CMFCToolBars along the side of the pane?

    This was working with CDialogBar and CToolBar, but I couldn't find how to do it with the new pane classes and CMFCToolBar.

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,006

    Re: CDockablePane questions

    1. Did you try to handleWM_WINDOWPOSCHANGING message?
    Victor Nijegorodov

  3. #3
    Join Date
    Aug 2006
    Posts
    80

    Re: CDockablePane questions

    Thanks for the suggestion. I tried it now, but I couldn't prevent resizing of the window (though I noticed OnSize is no longer being called if I try to push the original size to CDockablePane::OnWindowPosChanging).

    Also, the best would be if the resize cursor didn't appear at all.

  4. #4
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,006

    Re: CDockablePane questions

    Quote Originally Posted by TubularX View Post
    Thanks for the suggestion. I tried it now, but I couldn't prevent resizing of the window (though I noticed OnSize is no longer being called if I try to push the original size to CDockablePane::OnWindowPosChanging).
    How have you implemented the OnWindowPosChanging handler? Could you show you code?

    Quote Originally Posted by TubularX View Post
    Also, the best would be if the resize cursor didn't appear at all.
    Then you should handle WM_NCHITTEST messsage...
    Victor Nijegorodov

  5. #5
    Join Date
    Aug 2006
    Posts
    80

    Re: CDockablePane questions

    OK, here is the relevant code trying to prevent changing the width:

    From class header file:
    Code:
    public:
    	afx_msg void OnWindowPosChanging(LPWINDOWPOS lpWndPos);
    From source file:
    Code:
    BEGIN_MESSAGE_MAP(CDialogBarEx, CDockablePane)
    	//{{AFX_MSG_MAP(CDialogBarEx)
                     .....
    	ON_WM_WINDOWPOSCHANGING()
    	//}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    
    void CDialogBarEx::OnWindowPosChanging(LPWINDOWPOS lpwp) 
    { 
        lpwp->cx = DIALOGBAR_WIDTH;
        CDockablePane::OnWindowPosChanging(lpwp); 
        
        if( m_pDialogBar )
            m_pDialogBar->SetWindowPos (NULL, 0, 0, lpwp->cx , lpwp->cy , SWP_NOACTIVATE | SWP_NOZORDER);
    }
    From CMainFrame::OnCreate
    Code:
    DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI | CBRS_SIZE_FIXED;
    DWORD dwControlBarStyle = AFX_CBRS_FLOAT | AFX_CBRS_CLOSE | AFX_CBRS_AUTOHIDE;  // excluding AFX_CBRS_RESIZE
    pDialogBar->Create(_T("Dialogbar test"), this, CRect(0,0,DIALOGBAR_WIDTH,400), TRUE, 0, dwStyle, AFX_CBRS_REGULAR_TABS, dwControlBarStyle)) 
    
    pDialogBar->EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
    pDialogBar->SetMinSize(CSize(DIALOGBAR_WIDTH, 400));
    pDialogBar->SetResizeMode(FALSE);
    DockPane(pDialogBar);
    pDialogBar->SetPaneStyle( pDialogBar->GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_BORDER_3D | CBRS_GRIPPER | CBRS_SIZE_FIXED);
    My class looks like the CmyPane in this example: http://social.msdn.microsoft.com/For...-5135085c6fa5/

  6. #6
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,006

    Re: CDockablePane questions

    Have a look at this post
    Victor Nijegorodov

  7. #7
    Join Date
    Aug 2006
    Posts
    80

    Re: CDockablePane questions

    OK, I see how it's supposed to work. I also read here: http://msdn.microsoft.com/en-us/magazine/cc301402.aspx, where it says "If the mouse is in the left or right border, the default proc returns HTLEFT or HTRIGHT, respectively. These codes tell Windows to begin its moving or sizing chores. You can prevent moving and sizing by overriding ON_NCHITTEST."

    However, it doesn't work as expected with CDockablePane. My code:

    Code:
    LRESULT CDialogBarEx::OnNcHitTest(CPoint point)
    {	
              LRESULT res = CDockablePane::OnNcHitTest(point);
              if( res == HTLEFT || res == HTRIGHT )
                   res = HTBORDER;
              return res;
    }
    If I set a breakpoint inside this method, it doesn't hit until the cursor is inside the pane borders, and the only result ever returned is HTCLIENT. So, when hovering over the border where the resize cursor appears, the NCHITTEST message is handled somewhere else?
    Last edited by TubularX; August 10th, 2011 at 04:24 AM.

  8. #8
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,006

    Re: CDockablePane questions

    Try to TRACE the value that OnNcHitTest returns rather than setting the break point.
    Victor Nijegorodov

  9. #9
    Join Date
    Aug 2006
    Posts
    80

    Re: CDockablePane questions

    Well, same result...

    CString strRes;
    strRes.Format(_T("%d\n"), res);
    TRACE(strRes);

    It only outputs many rows with "1" when mouse is inside the pane. When hovering mouse over the border or when I click and drag to resize the pane there is no output written.

  10. #10
    Join Date
    Aug 2006
    Posts
    80

    Re: CDockablePane questions

    I now created a new MFC project with VS2010 and added just my CDockablePane class. See attached file. You can now see trace for yourself. Please advise.
    Attached Files Attached Files

  11. #11
    Join Date
    Aug 2006
    Posts
    80

    Re: CDockablePane questions

    I now also tried overriding CDockablePane::IsResizable and return false. Well, it didn't help.

    Please, anyone? Is it really impossible to prevent resizing?? :-/

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