单文档程序,有多个视图,轮流切换,
但是有种情况需要两个视图在一个窗口中同时显示出来,是不是无法做到,必须得用多文档?VC

解决方案 »

  1.   

    在单文档用CSplitterWnd成两个窗口就可以,其他情况将一个窗口的宽度设为0
      

  2.   

    单文档一个视图时 不用 CSplitterWnd, 2个视图时 CSplitterWnd 成两个窗口。
      

  3.   

    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.
      

  4.   

    这个要求 动态创建和销毁CSplitterWnd 下载我的“YaChangeSplit.zip”
    http://download.csdn.net/detail/schlafenhamster/3463284“另一个(Yet another)窗口动态分割的演示程序。 只有一个CSplitterWnd m_wndSplitter实例,不嵌套 使用CreateStatic动态改变窗口分割数0,2,4, 6 使用CEditView”
      

  5.   

    你的方法精华我已读完了,
    一个MAINVIEW,当不分割时显示这个视图,删除SPLITTER
    当切换到要分割框架里,就把MAINVIEW隐藏,把SPLITTER的信息清空,再重新分割框架,显示分割后的视图,
    我把你里面用到的汇编代码,改成继承CSPLITTERWND,在里面写了一个实现初始化的函数方法已经很接近我的要求了,也用的是单文档的思路,再找找看有没有更简便和简洁的正规点的方法,比如使用多个框架,一个带分割,一个不带分割,或者用一个窗口,里面嵌套多个视图等,谢谢!
      

  6.   

    还是用MDI吧。
    我这边就做过类似的项目。
      

  7.   

    “比如使用多个框架” 那就是 childframe 了,
    一个 childframe 是 分割的, 另一个是 不分割的。
      

  8.   

    最大化最小化和关闭按钮不是重点,你先把功能都做出来,然后想办法修改view的外观。
    MDI也没有比SDI更复杂,就是你要多弄几个view类出来,每一个子窗口对应一个view类。
      

  9.   

    你就做类似这个的工作void CXXXViewApp::InitDocTemplates()
    {
        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;
        ..........
    }
      

  10.   

    跟这个人的问题一模一样,http://bbs.csdn.net/topics/60151690程序中不会用到多类文档,所以还是想用SDI,但是要分割的的话,MDI那边比较合适,,,,
      

  11.   

    自已重写一个视,在SDI上搞!
      

  12.   

    推荐另外一个方法  在vs2008sp1里 除了主view外 其他的用cdockablepane来显示  我就是这样做的 3个pane 想关就关 可以遮住view 还可以dock
      

  13.   

    “MDI那边比较合适”
    MDI 不是 分割 !!!!
      

  14.   

    研究了一天,在MSDN上看到一个标准例子,也是MDI做的,SDI研究来研究去限制太多,MDI去菜单我也会了,
    另外:我就是要把框架分割,不是把视图分割,CSPLITTERWND我查过了,只支持分割框架,其它一概不认所以还是MDI最强大!在MDI上搞
      

  15.   

    老向!
    我继承了一个CStatusBar的子类,也重载了里面的DrawItem函数,但是运行的时候没有调用到DrawItem函数里去,怎么回事,构造函数是进去了的,我前面的设置也没有报错,知道是怎么回事不
      

  16.   

    "但是运行的时候没有调用到DrawItem函数里去"
    没有自绘 属性。
      

  17.   

    这个自绘属性在哪里加?
    我是在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
      

  18.   

    即 CStatusBar 的子类