SDI Interface with Multi-Views and Multi-Splitters
Overview
For a true SDI application, it is oft necessary to have more than one view. In most cases, it is also necessary to have splitter windows containing other views. This sample can be used to implement multi-views in SDI application with or without splitter. Menu and accelerator table can be changed between views, help ID too.About this sample
This sample implement 7 views. A standalone CEditView as first view, a splitter window containing a CTreeView and a CListView, an other splitter window containing a CView and a CScrollView, a standalone CRichEditView and a standalone CFormView. The CRichEditView has a new menu with find, next and replace as sample for view context menu.Problem creating multi-views and multi-splitters
The framework implement functions to create new views CFrameWnd::CreateView() and CSplitterWnd::CreateView(). CFrameWnd, uses the AFX_IDW_PANE_FIRST as default dialog ID for the new view. This ID is used in the RecalcLayout() and if the view is a standalone view, there is not problem because there is only one view active with this ID at a time. CSplitterWnd implement a function IdFromRowCol() to calculate a dialog ID started with AFX_IDW_PANE_FIRST until AFX_IDW_PANE_LAST. Because there is only 256 possible values for this ID, the splitter limits the view on a 16x16 matrix. If we want to create a second splitter with other views, CSplitterWnd::CreateView() fail because the dialog ID exists in the first splitter.Solution to create multi-splitters
The simple solution for the splitter dialog ID problem is to change the dialog id of the new created views to zero after creation of all panes so we preserve the ASSERT message if the programmer try to create an other view at the same row/column position. To make consistency, we do the same for standalone Views.Solution to display multi-views and multi-splitters
The framework implements a function to activate views CFrameWnd::SetActiveView() but not to show or hide other views or splitters. If we want to activate a new view, we must first hide the actual splitter and views. To preserve the dialog ID architecture, we must set the dialog ID of hidden splitters and views to zero and the dialog ID of the active splitter and views to the correct ID i.e. IdFromRowCol() for views in splitter and AFX_IDW_PANE_FIRST for standalone view.Implementation
To create new views, it is only necessary to add doc template to the application, but the resource string must be cleared i.e. containing only the window title "ViewTitle\n\n\n\n\n\n". To implement this architecture automatically, I use a new CSDIDocTemplate class derived from CSingleDocTemplate containing splitter information (splitter #, row, column). The default constructor set the splitter # to -1 so to implement a standalone view, we do exactly the same as for a CSingleDocTemplate. For splitter views, we must give a splitter # different of -1, the row and column. The new CSDIFrameWnd class derived from CFrameWnd creates the splitters and views in his CSDIFrameWnd::OnCreateClient() member automatically and store a view pointer in the doc template for later use. To do this, it uses a new CSDIWinApp class derived from CWinApp that implement three new little functions to access these doc templates with view runtime class or view pointer. The CSDIFrameWnd class has only two user functions. ActivateView(CRuntimeClass* pViewClass) switch between views and IsViewActive(CRuntimeClass* pViewClass) to update the user interface.Menu, Accelerator and Help ID
If you give new menu and accelerator table for the resource IDs in SDIDocTemplate menu and accelerator table will be changed. The help ID for the view will be changed according to the resource ID.Limitation
The number of views or splitters is only limited by memory. Because the two user functions in CSDIFrameWnd use runtime class, it is not possible to have more than one view of the same class but normally, it is not a problem. With little change, you can implement a view ID in the CSDIDocTemplate and use it to switch between views.Step by Step
To create an SDI application with multiple views and splitters, do this.- Create the SDI application with ClassWizard.
- Add SDIApp.* and SDIFrame.* to your project.
- Change the base class CWinApp to CSDIWinApp.
- Change the base class CFrameWin to CSDIFrameWnd.
- Use CSDIDocTemplate instead of CSingleDocTemplate.
- Create new views with ClassWizard.
- Create new resource ID string with new window title, but you can use the same for all new views.
- Create new menu with this resource ID if necessary.
- Add new CSDIDocTemplate in InitInstance() with resource ID, view and splitter number and position.
- In the CMainFrame, add message command to switch between views.
Download demo application - 17 KB
Date Last Updated: February 14, 1999

Comments
The thing everyone else actually does in the area of nike and consequently the thing you are looking to handle different.
Posted by icoppyapedcap on 04/23/2013 05:10amUfgChmJdlLwg[url=http://www.guccisayihujp.biz/]ã°ãã 財å¸[/url]DyyEhzKsxWfm [url=http://www.guccisayihujp.biz/ãã°ãããã¬ãã£ã¼ã¹è²¡å¸-c-5.html]ã°ããããã¼ã±ã¼ã¹[/url]LjfCjtLxyInj [url=http://www.guccisayihujp.biz/ãã°ãããã¬ãã£ã¼ã¹é·è²¡å¸-c-6.html]gucci é·è²¡å¸[/url]UweAexCkmQsi [url=http://www.guccisayihujp.biz/ãã°ãããã·ã§ã«ãã¼ããã°-c-2.html]ã°ãã ã¢ã¦ãã¬ãã[/url]MuiBbuUswKlx FvsVpfNqrBin [url=http://www.adidasgekiyasu.biz/]ã¢ãã£ãã¹[/url]QznRyySpyFib [url=http://www.nikegekiyasu.biz/]ãã¤ãã¹ãã¼ã«ã¼[/url]LkgRphStyDhv QdwQcyJavZcz [url=http://www.chanelsayihujp.biz/]ã·ã£ã㫠財å¸[/url] BweSldBipSkz [url=http://www.chanelsayihujp.biz/ã·ã£ãã«è²¡å¸-c-9.html]ã·ã£ãã« ãã§ã¼ã³ã¦ã©ã¬ãã[/url]AbkYcsMnnDqc [url=http://www.chanelsayihujp.biz/ã·ã£ãã«-ã·ã§ã«ãã¼ããã°-c-1.html]chanel bag[/url]KmyLeaNpnImj CotNrdJqzEdc [url=http://www.chloesayihujp.biz/]ã¯ã㨠ããã°[/url] BjpHzsKjpPih [url=http://www.chloesayihujp.biz/ã¯ãã¨-é·è²¡å¸-c-3.html]ã¯ã㨠é·è²¡å¸[/url] FpnRbmLiwTsl [url=http://www.chloesayihujp.biz/ã¯ãã¨-ãã³ãããã°-c-2.html]ã¯ã㨠ããã°[/url] LtqMafWgeKrr
ReplyHi......Nice Work!
Posted by bhushan1980 on 08/09/2006 11:33pmI have learned a new approach to alter Doc/View architecture from your application. I just realized that how the so called template classes can customize our application to the very best. But when I tried to add GetDocument() support to the view classes, other than the main view class, I am getting errors like base class undeclared, GetDocument() base class unidentified, insert ; before * in the line C3View* GetDocument(). I don't know why is it so. Also when I try to save some text it gives me an assertion failure message. Please can anyone shed light on this...... Thank you once again Mr. Invincible.
ReplyProblem when screen saver starts
Posted by fornin on 04/13/2006 08:27amProblem on resizing the task bar
Posted by basteo on 02/02/2006 05:44amSwapping between views
Posted by Legacy on 09/16/2003 12:00amOriginally posted by: Murli
The application what i have developed is MDI having 2 views in single document. my intention is to swap between these 2 views. For example if there are 2 views A and B. and these options must be placed on menubar. While running i must open both the views. if i select optioon A from menubar, then A view must highlighted, and similarly with the case of option B. There should not be any hiding in the views, both the views must be either cascaded or tiled.
Replyhow to add a new view
Posted by Legacy on 06/09/2003 12:00amOriginally posted by: mathew
i want to add a new form view to this project.
but it is not working properly..
while trying to load the new forview, entire menu
become inactive..
pl.. send ur suggestions..
thanks in advance
ReplyHow can I can do this with one document?
Posted by Legacy on 04/10/2003 12:00amOriginally posted by: Dafna Zamir
I would like to implement this switch of views but only with one document, so when data is changed all other doument will be updated also.
I don't like to use the splitter window.
ReplyHow to update a specific view?
Posted by Legacy on 03/03/2003 12:00amOriginally posted by: swad
hi, ive got a splitter window with 2 views which are created dynamically.
Replymy question is : how do i update a specific view?(ive tried using Invalidate()but doesn't work)
Problem ... Problem...Problem
Posted by Legacy on 01/29/2003 12:00amOriginally posted by: Rock
Problem?
exception error!!
windows bottom bar resize
Switched view does not repaint properly when the main frame window is resized
ReplyUgly dialog did not disappear :(
Posted by Legacy on 08/07/2002 12:00amOriginally posted by: AndreiIsakov
Hello! How did you eliminate the ugly dialog to choose a template from the list? What is the dialog ID and where to set it to zero?
Thanks in advance,
ReplyAndrei
Loading, Please Wait ...