|
Question : CScrollView in a static CSplitterWnd pane
|
|
I am trying to put a CScrollView-derived view in the lower right pane of a CSplitterWnd with 4 static panes, using MSVC 4.0. The other three panes are derived from CView.
This worked fine in my last 16-bit app (MSVC 1.52) but with MSVC 4.0, calling ResizeParentToFit() from the OnSize() method of CScrollView only works properly if both dimensions of the pane are smaller than the logical view size (and both the horiz and vert scrollbars appear). If only one dimension is smaller, then 1 scrollbar should appear, but it doesn't.
Stepping through the OnSize() code, the scrollbar actually does appear, but disappears shortly thereafter (I believe that it disappears when the View background is erased). The scrollbar disappears sometime after all OnSize() methods have been processed by the four views, the CSplitterWnd, and the enclosing CFrameWnd. It is gone by the time CScrollView::OnDraw() is called. I don't know what else to trap to narrow down the problem.
|
|
Answer : CScrollView in a static CSplitterWnd pane
|
|
(submitted for pschimpf)
OK, I have an answer:
Do NOT call ResizeParentToFit() from inside OnSize(). Instead, use PostMessage() to post a user-defined message. Create a handler for that user-defined message that calls ResizeParentToFit().
This works, although I have no satisfactory explanation for why calling ResizeParentToFit() from OnSize() directly doesn't, and neither does Microsoft Tech support, although they have aknowledged the problem and suggested this fix.
They also suggested creating my own ResizeToFit at the frame window level. At this level though, you have to account for the width of scrollbars and splitter bars, etc. Any easy way to do that might be to start by maximizing everything by calling ResizeParentToFit(FALSE) in the OnInitialUpdate() method of the CScrollView-derived class, then recording the size of the frame window client area, and then not allow the frame window area to be stretched beyond that size in the OnSizing() method of the frame window. Of course, if you have zoom levels (like I do), it gets a little more complicated...
|
|
|
|