Re: How to maintain splitter size
Hello Scott,
The OnSize() gets called when the splitter is created but before the view is
created and the application crashes.
m_bInit is set in OnCreateClient after the splitter and views are created
and are valid. Currently I am only establishing the size of the views when
the program initially starts.
If you minimize Visual Studio you will see that the width of the project
toolbar with filelist/resource tabs does not change when you change the size
of the applicatoin. You can still use the splitter to change the width of
the toolbar window but when you resize the app, it does not affect the width
of this view. This is what I am trying to do.
Somewhere in the code I have to move the splitter location when the
application is resized. I've been trying to do this in OnSize() with
m_wndSplitter.GetColumnInfo() and .SetColumnInfo() with some success but
have problems;Sometime I get unexpected/invalid values. I was hoping someone
may have done this before and could point me in the right direction. Maybe I
should be adjusting the position in the splitterwnd.
Thanks
"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in message
news:Ur-dnVbcyIhOB-XbnZ2dnUVZ_hudnZ2d@comcast.com...
mike wrote:
Can someone suggest how to maintain the splitter view size when the
program is sizeed or maximized or minimized? I am using nested splitter
with 2 rows; 2 columns on row 0. When the program starts (Minimized) I
set the initial size for row 0,column 1 to 200 less than max width. When
the program is Maximized, column 1 does not maintain the same width. I
do not want to block sizing the splitter; just maintain the same view
size for column 1 when the application is sized. Here is code I use to
set the initial size which works ok.
thanks
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
/************************************************************/
/* NOTE: m_bInit is set in OnCreateClient() after the views */
/* have been created. */
/************************************************************/
if ( m_bInit ) // only execute once so the splitter is not always the
same size
{
m_bInit = FALSE;
m_wndSplitter1.SetRowInfo( 0, cy/*-150*/, 0 ); // Hidden
m_wndSplitter1.RecalcLayout();
m_wndSplitter2.SetColumnInfo( 0, cx-200, 0 ); // make right column 200
less than max
m_wndSplitter2.RecalcLayout();
}
}
I don't understand the comment at "if (m_bInit)". If you take out that
line it seems you have what you want. You seem to be saying you want col
1 to be 200 wide, but you want it variable. (?)
--
Scott McPhillips [MVP VC++]