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.
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.
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?
Originally Posted by TubularX
Also, the best would be if the resize cursor didn't appear at all.
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.
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.
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.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.