cspiltterwnd 类的createstatic, createview函数
BOOL CreateStatic( CWnd* pParentWnd, int nRows, int nCols, DWORD dwStyle = WS_CHILD | WS_VISIBLE, UINT nID = AFX_IDW_PANE_FIRST );
Return Value
Nonzero if successful; otherwise 0.
Parameters
pParentWnd
The parent frame window of the splitter window.
nRows
The number of rows. This value must not exceed 16.
nCols
The number of columns. This value must not exceed 16.
dwStyle
Specifies the window style.
nID
The child window ID of the window. The ID can be AFX_IDW_PANE_FIRST unless the splitter window is nested inside another splitter window.
nId用 IdFromRowCol创建id,不能够随便指定
以下是一个嵌套的分割视图
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: 在此添加专用代码和/或调用基类
if(!m_splitterWnd.CreateStatic(this,1,2))
{
TRACE("Failed to Create m_wndSplitter");
return false;
}
if(!m_splitterWnd2.CreateStatic(&m_splitterWnd,2,1,WS_CHILD|WS_VISIBLE,m_splitterWnd.IdFromRowCol(0,1)))
{
TRACE("Failed to Create COperatorTabCtrl!");
return false;
}
if(!m_splitterWnd.CreateView(0,0,RUNTIME_CLASS(CSpiltterWndView),CSize(350,150),pContext))
{
TRACE("Failed to Create CSpiltterWndView!");
return false;
}
if(!m_splitterWnd2.CreateView(0,0,RUNTIME_CLASS(CMyFormView),CSize(350,450),pContext))
{
TRACE("Failed to Create CMyFormView!");
return false;
}
if(!m_splitterWnd2.CreateView(1,0,RUNTIME_CLASS(CMyScrollView),CSize(150,150),pContext))
{
TRACE("Failed to Create CMyScrollView!");
return false;
}
return CFrameWnd::OnCreateClient(lpcs, pContext);
}
/////////////////////////////////////////////////////////////////////////////////////////
2012.12.3新增
有时候程序运行后,视图看不到,需要用setrowinfo函数
以下是一个例子:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: 在此添加专用代码和/或调用基类
CRect rect;
GetClientRect(&rect);
if(!m_splitterWnd.CreateStatic(this,2,1))
{
TRACE("Failed to Create m_wndSplitter");
return false;
}
if(!m_splitterWnd2.CreateStatic(&m_splitterWnd,1,2,WS_CHILD|WS_VISIBLE,m_splitterWnd.IdFromRowCol(0,0)))
{
TRACE("Failed to Create COperatorTabCtrl!");
return false;
}
if(!m_splitterWnd2.CreateView(0,0,RUNTIME_CLASS(CMyFormView),CSize(rect.Width()*2/5,rect.Height()*2/5),pContext))
{
TRACE("Failed to Create CMyFormView!");
return false;
}
if(!m_splitterWnd2.CreateView(0,1,RUNTIME_CLASS(CMyScrollView),CSize(rect.Width()*3/5,rect.Height()*2/5),pContext))
{
TRACE("Failed to Create CMyScrollView!");
return false;
}
if(!m_splitterWnd.CreateView(1,0,RUNTIME_CLASS(CSpiltterWndView),CSize(rect.Width(),rect.Height()*3/5),pContext))
{
TRACE("Failed to Create CSpiltterWndView!");
return false;
}
m_splitterWnd.SetRowInfo(0,rect.Height()*2/5,100);
m_splitterWnd2.SetRowInfo(0,rect.Height()*3/5,100);
/*m_splitterWnd.SetRowInfo(0,rect.Height()/2,100);
m_splitterWnd2.SetRowInfo(0,rect.Height()/2,100);*/
return CFrameWnd::OnCreateClient(lpcs, pContext);
}