SDI中的窗口切分

一、主要函数
(1)CSplitterWnd::CreateStatic

To create a static splitter window, call the CreateStaticmember function.

Copy Code
virtual BOOL CreateStatic(   CWnd* pParentWnd,   int nRows,   int nCols,   DWORD dwStyle = WS_CHILD | WS_VISIBLE,   UINT nID = AFX_IDW_PANE_FIRST );
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 beAFX_IDW_PANE_FIRST unless the splitter window is nestedinside another splitter window.

(2)CSplitterWnd::CreateView

Creates the panes for a static splitter window.

Copy Code
virtual BOOL CreateView(   int row,   int col,   CRuntimeClass* pViewClass,   SIZE sizeInit,   CCreateContext* pContext );
Parameters
row

Specifies the splitter window row in which to place the newview.

col

Specifies the splitter window column in which to place the newview.

pViewClass

Specifies the CRuntimeClassof the new view.

sizeInit

Specifies the initial size of the new view.

pContext

A pointer to a creation context used to create the view (usuallythe pContext passed into the parentframe's overridden CFrameWnd::OnCreateClientmember function in which the splitter window is being created).

Return ValueReturnValue

Nonzero if successful; otherwise 0.

RemarksRemarks

All panes of a static splitter window must be created before theframework displays the splitter.

The framework also calls this member function to create newpanes when the user of a dynamic splitter window splits a pane,row, or column.

ExampleExample
Copy Code
 
二、(1)OnCreateClient绘制与文档对象和边框窗口对象相联系的视区。
(2)在单个视类的切分窗口中,各个视区的内容是完全一致的,只要一个视类对象
(3)切分窗口为多视类则,不同的切分窗口可以显示不同的内容,因此要创建多个视类对象。
三、代码:
(1)声明切分窗口(可能要)
CChildFrame类中加入 CSpliterWnd m_wndSplitter
(2)在OnCreateClient加入代码
// this function creates the panes for a static splitter windowBOOL CChildFrame::OnCreateClient( LPCREATESTRUCT lpcs,    CCreateContext* pContext){   BOOL bCreateSpltr = m_wndSplitter.CreateStatic( this, 2, 1);   // COneView and CAnotherView are user-defined views derived from CMDIView   m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(COneView), CSize(0,0),       pContext);   m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CAnotherView), CSize(0,0),       pContext);   return (bCreateSpltr);}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值