scroll view, splitter windows.
2025-12-01
Written by: xiaobin
You need to add implementation code to OnCreateClient() in MainFrm.
MyExplorer




CDetailView:


Parameter settings when not nested panes:
// | List View (CMyExplorerView)
// Tree View (CLeftView) |-----------------------------
// | Scroll View (CDetailView)
// Tree View (CLeftView) | List View (CMyExplorerView)
// ------------------------ |-----------------------------
// Edit View (CEditView) | Scroll View (CDetailView)
When CSIZE cannot control the width or height of the pane:
Resets the value of column 0 or row 0.
m_wndSplitter.SetColumnInfo(0, 100, 50);
m_wndSplitter2.SetRowInfo(0, 360, 100);
// Attributes
protected:
CSplitterWnd m_wndSplitter;
CSplitterWnd m_wndSplitter1; // The splitter variable in the first column
CSplitterWnd m_wndSplitter2; // The splitter variable in the second column
declare In MainFrm.h
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
/* //// Code generated by MFC App Wizard
// create splitter window
if (!m_wndSplitter.CreateStatic(this, 1, 2))
return FALSE;
if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100, 100), pContext) ||
!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CMyExplorerView), CSize(100, 100), pContext))
{
m_wndSplitter.DestroyWindow();
return FALSE;
}
*/
// create a splitter with 1 row, 2 columns
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
m_wndSplitter.SetColumnInfo(0, 100, 50);
// add the first splitter pane - which is a nested splitter with 2 rows
if (!m_wndSplitter1.CreateStatic(
&m_wndSplitter, // our parent window is the first splitter
2, 1, // the new splitter is 2 rows, 1 column
WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed
m_wndSplitter.IdFromRowCol(0, 0)
// new splitter is in the first row, 2nd column of first splitter
))
{
TRACE0("Failed to create nested splitter - Left\n");
return FALSE;
}
if (!m_wndSplitter1.CreateView(0, 0,
RUNTIME_CLASS(CLeftView), CSize(0, 170), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
}
if (!m_wndSplitter1.CreateView(1, 0,
RUNTIME_CLASS(CTextView), CSize(0, 70), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
// add the second splitter pane - which is a nested splitter with 2 rows
if (!m_wndSplitter2.CreateStatic(
&m_wndSplitter, // our parent window is the first splitter
2, 1, // the new splitter is 2 rows, 1 column
WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed
m_wndSplitter.IdFromRowCol(0, 1)
// new splitter is in the first row, 2nd column of first splitter
))
{
TRACE0("Failed to create nested splitter\n");
return FALSE;
}
// now create the two views inside the nested splitter
CRect rect;
GetClientRect(&rect);
int cyText = rect.Size().cy - 70; // height of text pane - SDI
//int cyText = max(lpcs->cy - 70, 20); // height of text pane - MDI
if (!m_wndSplitter2.CreateView(0, 0,
RUNTIME_CLASS(CMyExplorerView), CSize(0, cyText), pContext))
{
TRACE0("Failed to create third pane\n");
return FALSE;
}
if (!m_wndSplitter2.CreateView(1, 0,
RUNTIME_CLASS(CDetailView), CSize(0, 70), pContext))
{
TRACE0("Failed to create fourth pane\n");
return FALSE;
}
m_wndSplitter2.SetRowInfo(0, 360, 100);
return TRUE;
}