Resizing splitter panes in SDI CMainFrame::OnSize()
Paul Pettigrew -- chilli@iinet.net.au
Sunday, June 02, 1996
WinNT 3.51/Win95
MSVC++ 4.1
SDI AppWizard MFC
I am unable to resize 3 horizontal static splitter windows, in the OnSize handler.
I wish to have the topmost pane 50% of the SDI main frame client area, below it the second row 25%, and the bottom row the remaining 25%.
The code below produces random resizing of the rows, that in no way correspond to the % amounts.
Often only the top pane will be visible, with the other two "below the status bar" and not visible.
What is wrong with CSplitterWnd::SetRowInfo()?
This should work, if I have read the documentation correctly.
Has anybody successfully set the layout of static splitter panes programatically at runtime?
...............................................................
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
// NB: This function is called TWICE by the framework when
// the application is first started.
// On the first run, there are no splitters yet! Thanks to the constructor
// setting m_bResizePanes = FALSE, the first run will never attempt to
// move the windows. The user setting will be loaded prior to the second run.
CFrameWnd::OnSize(nType, cx, cy);
// The 3 splitter panes are resized to maintain their relative vertical coverage.
// This attribute can be turned off.
if (m_bResizePanes)
{
// Lookup table for desired % ratios
const int PanePct[] = {50, 25, 25};
for (int nRow = 0; nRow < 3; nRow++)
{
m_wndSplitter.SetRowInfo(
nRow, // row
(PanePct[nRow] * cy) / 100, // cyIdeal
0); // cyMin
}
}
}
--
Paul Pettigrew
chilli@iinet.net.au || pmpet2@mugc.cc.monash.edu.au
http://www.iinet.net.au/~chilli/
Greg D. Tighe -- gdt@eng.aisinc.com
Tuesday, June 04, 1996
> What is wrong with CSplitterWnd::SetRowInfo()?
> This should work, if I have read the documentation correctly.
>
...
> for (int nRow = 0; nRow < 3; nRow++)
> {
> m_wndSplitter.SetRowInfo(
> nRow, // row
> (PanePct[nRow] * cy) / 100, // cyIdeal
> 0); // cyMin
> }
>
After you've finished with all your calls to SetRowInfo() you'll need
to call m_wndSplitter.RecalcLayout( ) to correctly redisplay your
splitter window.
-Greg Tighe
Applied Intelligent Systems, Inc.
Ann Arbor, MI
gdt@aisinc.com
| Вернуться в корень Архива
|