Re: CDockablePane questions
1. Did you try to handleWM_WINDOWPOSCHANGING message?
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.
Re: CDockablePane questions
Quote:
Originally Posted by
TubularX
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
Also, the best would be if the resize cursor didn't appear at all.
Then you should handle WM_NCHITTEST messsage...
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/
Re: CDockablePane questions
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?
Re: CDockablePane questions
Try to TRACE the value that OnNcHitTest returns rather than setting the break point.
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.
1 Attachment(s)
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.
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?? :-/