Notification when GetClientAreaBounds changes?
-
2012年4月10日 下午 08:02I've got a CFrameWndEx window with a number of docked panes, and a child window placed in the GetDockingManager()->GetClientAreaBounds(rc) space. How can I get notified when a docked pane is resized (affecting the client area bounds)? I used to have a splitter window in there and it seemed to magically resize itself correctly...
所有回覆
-
2012年4月10日 下午 09:04Any time a window is resized it receives the WM_SIZE message, with the new size.
-
2012年4月10日 下午 09:16In this case the Frame window is not resized, just the docked pane within it is resized. I suppose I could add event handler on all the docked panes and have them notify the parent, but it seems unwieldy (and the splitter was able to handle it without that).
-
2012年4月10日 下午 09:57
Attempt this in each derived class for your dockable panes:
void CFileView::OnSize(UINT nType, int cx, int cy) { CDockablePane::OnSize(nType, cx, cy); AdjustLayout(); } void CFileView::AdjustLayout() { GetParent()->SetWindowPos(NULL, m_wndFV.r.left, m_wndFV.r.top, m_wndFV.r.Width(), m_wndFV.r.Height(), SWP_NOZORDER); }
If you want to see unwieldy, then check out the MSDN flagship sample app VisualStudioDemo.
PAC
- 已編輯 PACMAN_1 2012年4月10日 下午 09:59
-
2012年4月10日 下午 10:35Ugh - yeah I can do that (or the like), but I've got quite a number of panes and it seems frustrating that the splitter was able to do it without specialized code in the child panes...
-
2012年4月10日 下午 10:43
Did you take a look at VisualStudioDemo source code for ideas?
Here's the link http://msdn.microsoft.com/en-us/library/bb983983(v=VS.90).aspx .
- 已編輯 PACMAN_1 2012年4月10日 下午 10:47
-
2012年4月10日 下午 11:06Looking at it now: it seems they bypass the problem by making everything a pane (or a view).
- 已編輯 hunter144 2012年4月10日 下午 11:19
-
2012年4月10日 下午 11:48More discussion?
PAC
- 已編輯 PACMAN_1 2012年4月11日 上午 12:06
-
2012年4月12日 下午 04:25
So I'm stymied once again. I gave up on getting notified and instead had the pane notify the parent window when the pane is resized. However, when the parent calls GetDockingManager()->GetClientAreaBounds(rc); the results are not always correct - they're just a bit behind (time-wise), usually giving the rectangle for the previous client area rather than the current one. I've 'solved' this by injecting a timer which delays things by 20 or so milliseconds, which seems to correct it _most_ of the time. If I make the timer delay bigger it works more reliably, but starts to get noticeable to the user. Bah.
-
2012年4月12日 下午 04:46
So I fixed this last problem by changing this:
CRect rc;
GetDockingManager()->GetClientAreaBounds(rc);
to this:
CRect rc;
GetDockingManager()->RecalcLayout();
GetDockingManager()->GetClientAreaBounds(rc);
Still chafing at having to change every pane, but at least it looks like I can get it to work smoothly now.
- 已標示為解答 Jesse JiangMicrosoft Contingent Staff, Moderator 2012年4月20日 上午 07:49
-
2012年4月12日 下午 05:19
Take a look at CBasePane::ShowPane. It shows (or hides) a pane and notifies the docking manager. It has a delay parameter for recalculating the docking layout.
virtual void ShowPane( BOOL bShow, BOOL bDelay, BOOL bActivate );PAC

