嵌套分割视图

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);
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值