The CSplitterWnd class provides the functionality of a splitter window, which is a window that contains multiple panes. A pane is usually an application-specific object derived from CView, but it can be any CWnd object that has the appropriate child window ID.A CSplitterWnd object is usually embedded in a parent CFrameWnd or CMDIChildWnd object. Create a CSplitterWnd object using the following steps: Embed a CSplitterWnd member variable in the parent frame. Override the parent frame’s CFrameWnd::OnCreateClient member function. From within the overridden OnCreateClient, call the Create or CreateStatic member function of CSplitterWnd. Call the Create member function to create a dynamic splitter window. A dynamic splitter window typically is used to create and scroll a number of individual panes, or views, of the same document. The framework automatically creates an initial pane for the splitter; then the framework creates, resizes, and disposes of additional panes as the user operates the splitter window’s controls.When you call Create, you specify a minimum row height and column width that determine when the panes are too small to be fully displayed. After you call Create, you can adjust these minimums by calling the SetColumnInfo and SetRowInfo member functions.Also use the SetColumnInfo and SetRowInfo member functions to set an “ideal” width for a column and “ideal” height for a row. When the framework displays a splitter window, it first displays the parent frame, then the splitter window. The framework then lays out the panes in columns and rows according to their ideal dimensions, working from the upper-left to the lower-right corner of the splitter window’s client area.All panes in a dynamic splitter window must be of the same class. Familiar applications that support dynamic splitter windows include Microsoft Word and Microsoft Excel. Use the CreateStatic member function to create a static splitter window. The user can change only the size of the panes in a static splitter window, not their number or order. You must specifically create all the static splitter’s panes when you create the static splitter. Make sure you create all the panes before the parent frame’s OnCreateClient member function returns, or the framework will not display the window correctly.The CreateStatic member function automatically initializes a static splitter with a minimum row height and column width of 0. After you call Create, adjust these minimums by calling the SetColumnInfo and SetRowInfo member functions. Also use SetColumnInfo and SetRowInfo after you call CreateStatic to indicate desired ideal pane dimensions.The individual panes of a static splitter often belong to different classes. For examples of static splitter windows, see the graphics editor and the Windows File Manager. A splitter window supports special scroll bars (apart from the scroll bars that panes may have). These scroll bars are children of the CSplitterWnd object and are shared with the panes.You create these special scroll bars when you create the splitter window. For example, a CSplitterWnd that has one row, two columns, and the WS_VSCROLL style will display a vertical scroll bar that is shared by the two panes. When the user moves the scroll bar, WM_VSCROLL messages are sent to both panes. When the panes set the scroll-bar position, the shared scroll bar is set.For further information on splitter windows, see Technical Note 29. For more information on how to create dynamic splitter windows, see Adding Splitter Windows to Scribble inEnhancing Views in Visual C++ Tutorials, and the MFC General sampleVIEWEX.
Override the parent frame’s CFrameWnd::OnCreateClient member function.
From within the overridden OnCreateClient, call the Create or CreateStatic member function of CSplitterWnd.
Call the Create member function to create a dynamic splitter window. A dynamic splitter window typically is used to create and scroll a number of individual panes, or views, of the same document. The framework automatically creates an initial pane for the splitter; then the framework creates, resizes, and disposes of additional panes as the user operates the splitter window’s controls.When you call Create, you specify a minimum row height and column width that determine when the panes are too small to be fully displayed. After you call Create, you can adjust these minimums by calling the SetColumnInfo and SetRowInfo member functions.Also use the SetColumnInfo and SetRowInfo member functions to set an “ideal” width for a column and “ideal” height for a row. When the framework displays a splitter window, it first displays the parent frame, then the splitter window. The framework then lays out the panes in columns and rows according to their ideal dimensions, working from the upper-left to the lower-right corner of the splitter window’s client area.All panes in a dynamic splitter window must be of the same class. Familiar applications that support dynamic splitter windows include Microsoft Word and Microsoft Excel. Use the CreateStatic member function to create a static splitter window. The user can change only the size of the panes in a static splitter window, not their number or order. You must specifically create all the static splitter’s panes when you create the static splitter. Make sure you create all the panes before the parent frame’s OnCreateClient member function returns, or the framework will not display the window correctly.The CreateStatic member function automatically initializes a static splitter with a minimum row height and column width of 0. After you call Create, adjust these minimums by calling the SetColumnInfo and SetRowInfo member functions. Also use SetColumnInfo and SetRowInfo after you call CreateStatic to indicate desired ideal pane dimensions.The individual panes of a static splitter often belong to different classes. For examples of static splitter windows, see the graphics editor and the Windows File Manager. A splitter window supports special scroll bars (apart from the scroll bars that panes may have). These scroll bars are children of the CSplitterWnd object and are shared with the panes.You create these special scroll bars when you create the splitter window. For example, a CSplitterWnd that has one row, two columns, and the WS_VSCROLL style will display a vertical scroll bar that is shared by the two panes. When the user moves the scroll bar, WM_VSCROLL messages are sent to both panes. When the panes set the scroll-bar position, the shared scroll bar is set.For further information on splitter windows, see Technical Note 29. For more information on how to create dynamic splitter windows, see Adding Splitter Windows to Scribble inEnhancing Views in Visual C++ Tutorials, and the MFC General sampleVIEWEX.
http://download.csdn.net/detail/schlafenhamster/3463284“另一个(Yet another)窗口动态分割的演示程序。 只有一个CSplitterWnd m_wndSplitter实例,不嵌套 使用CreateStatic动态改变窗口分割数0,2,4, 6 使用CEditView”
一个MAINVIEW,当不分割时显示这个视图,删除SPLITTER
当切换到要分割框架里,就把MAINVIEW隐藏,把SPLITTER的信息清空,再重新分割框架,显示分割后的视图,
我把你里面用到的汇编代码,改成继承CSPLITTERWND,在里面写了一个实现初始化的函数方法已经很接近我的要求了,也用的是单文档的思路,再找找看有没有更简便和简洁的正规点的方法,比如使用多个框架,一个带分割,一个不带分割,或者用一个窗口,里面嵌套多个视图等,谢谢!
我这边就做过类似的项目。
一个 childframe 是 分割的, 另一个是 不分割的。
MDI也没有比SDI更复杂,就是你要多弄几个view类出来,每一个子窗口对应一个view类。
{
CMultiDocTemplate* pDocTempl;
//数据库配置
pDocTempl= new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CDataBsDoc),
RUNTIME_CLASS(CDataBsFrame), // custom MDI child frame
RUNTIME_CLASS(CDataBsTreeView));
AddDocTemplate(pDocTempl);
m_pDocTempl[DBSTWnd] =pDocTempl;
//标识、以太网、GPS、日志
pDocTempl= new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CEnvirnmtDoc),
RUNTIME_CLASS(CEnvirnmtFrame), // custom MDI child frame
RUNTIME_CLASS(CEnvirnmtTreeView));
AddDocTemplate(pDocTempl);
m_pDocTempl[ENVMTWnd] =pDocTempl;
//模板数据库
pDocTempl= new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CDvcBsDoc),
RUNTIME_CLASS(CDvcBsFrame), // custom MDI child frame
RUNTIME_CLASS(CDvcTreeView));
AddDocTemplate(pDocTempl);
m_pDocTempl[DVCWnd] =pDocTempl;
//通讯监视
pDocTempl= new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMonitorDoc),
RUNTIME_CLASS(CMDIChildWnd), // custom MDI child frame
RUNTIME_CLASS(CMonitorFormView));
AddDocTemplate(pDocTempl);
m_pDocTempl[MONITORWnd] =pDocTempl;
//合并遥信库
pDocTempl= new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CUniteDiBsDoc),
RUNTIME_CLASS(CUniteDiBsFrame), // custom MDI child frame
RUNTIME_CLASS(CUniteDiBsTreeView));
AddDocTemplate(pDocTempl);
m_pDocTempl[UNTDIWnd] =pDocTempl;
//数据库配置
pDocTempl= new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CRmtBsDoc),
RUNTIME_CLASS(CRmtBsFrame), // custom MDI child frame
RUNTIME_CLASS(CRmtBsTreeView));
AddDocTemplate(pDocTempl);
m_pDocTempl[RMTBSWnd] =pDocTempl;
//液晶面板监控数据库配置
pDocTempl= new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CPanelDoc),
RUNTIME_CLASS(CPanelFrame), // custom MDI child frame
RUNTIME_CLASS(CPanelTreeView));
AddDocTemplate(pDocTempl);
m_pDocTempl[PANELWnd] =pDocTempl;
..........
}
MDI 不是 分割 !!!!
另外:我就是要把框架分割,不是把视图分割,CSPLITTERWND我查过了,只支持分割框架,其它一概不认所以还是MDI最强大!在MDI上搞
我继承了一个CStatusBar的子类,也重载了里面的DrawItem函数,但是运行的时候没有调用到DrawItem函数里去,怎么回事,构造函数是进去了的,我前面的设置也没有报错,知道是怎么回事不
没有自绘 属性。
我是在Create函数里加的一句,但仍没有效果,还是没被调用
virtual BOOL Create(CWnd* pParentWnd, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_BOTTOM, UINT nID = AFX_IDW_STATUS_BAR);改成这样:仍不行
dwStyle = WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | SBT_OWNERDRAW