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

Thread: Restrict CDockablePane to CBRS_ALIGN_LEFT or CBRS_ALIGN_RIGHT

  1. #1
    Join Date
    Jan 2009
    Posts
    335

    Restrict CDockablePane to CBRS_ALIGN_LEFT or CBRS_ALIGN_RIGHT

    I need to restrict a panel, derived from CDockablePane to be float only on the left or right side. But seem that it can be float anywhere, top and bottom as well. And this CDockablePane is part of a CChildFrame, not a CMainFrame.

    Here is the code:
    Code:
    protected:
    	CPropertiesWnd1 m_wndPane1;
    and
    Code:
    int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
    {
    	if(CMDIChildWndEx::OnCreate(lpCreateStruct) == -1)
    		return -1;
    
    	// TODO: Add your specialized creation code here
    
    	SetIcon(theApp.LoadIcon(IDR_MAINFRAME), FALSE);
    
    	// enable Visual Studio 2005 style docking window behavior
    	CDockingManager::SetDockingMode(DT_SMART);
    	// enable Visual Studio 2005 style docking window auto-hide behavior
    	EnableAutoHidePanes(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
    
    	CMDIChildWndEx::m_bEnableFloatingBars = TRUE;
    
    	// Create filter window
    	if(! m_wndPane1.Create(_T("Properties 1"), this, CRect(0, 0, 250, 500), TRUE, TRM_PANE1ID, 
    		WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI, 
    		AFX_CBRS_REGULAR_TABS, AFX_CBRS_FLOAT | AFX_CBRS_RESIZE | AFX_CBRS_AUTOHIDE))
    	{
    		TRACE(_T("Failed to create Filter window\n"));
    		return FALSE; // failed to create
    	}
    
    	SetDockingWindowIcons(theApp.m_bHiColorIcons);
    
    	AddPane(&m_wndPane1);
    	m_wndPane1.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
    	DockPane(&m_wndPane1);
    
    	return 0;
    }
    But when I try to drag the pane, I can drag it anywhere, left, right, up, down: https://postimg.cc/w7tDRsVL
    which is not normal. I should can drag the panel only in left or right side.

    I attached here a sample project: TestPane.zip
    Last edited by mesajflaviu; March 29th, 2020 at 04:04 AM.

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

    Re: Restrict CDockablePane to CBRS_ALIGN_LEFT or CBRS_ALIGN_RIGHT

    Not sure it will work, however you could try to handle the WM_WINDOWPOSCHANGING message and depending on the current position allow or not the position changing.
    Victor Nijegorodov

  3. #3
    Join Date
    Jan 2009
    Posts
    335

    Re: Restrict CDockablePane to CBRS_ALIGN_LEFT or CBRS_ALIGN_RIGHT

    Quote Originally Posted by VictorN View Post
    Not sure it will work, however you could try to handle the WM_WINDOWPOSCHANGING message and depending on the current position allow or not the position changing.
    I see, but then what is the point with those settings ? EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT)

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

    Re: Restrict CDockablePane to CBRS_ALIGN_LEFT or CBRS_ALIGN_RIGHT

    IMHO you mix "docking" and "floating". Don't you?
    Victor Nijegorodov

  5. #5
    Join Date
    Jan 2009
    Posts
    335

    Re: Restrict CDockablePane to CBRS_ALIGN_LEFT or CBRS_ALIGN_RIGHT

    As long while I am in dragging state (floating) and I see the arrows for top and bottom direction, I can (and I succeed) to dock the panel in top or bottom position.

  6. #6
    Join Date
    Jan 2009
    Posts
    335

    Re: Restrict CDockablePane to CBRS_ALIGN_LEFT or CBRS_ALIGN_RIGHT

    For those who have the same problem, I overridden DockPane method in order to solve my issue. Thank you for your support and your time.

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,722

    Re: Restrict CDockablePane to CBRS_ALIGN_LEFT or CBRS_ALIGN_RIGHT

    Thank you for sharing the solution!
    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)