The information in this article applies to:
SUMMARY
VSWAP demonstrates methods of switching between multiple views on a single
document in a single-document interface (SDI) application. VSWAP displays
two form views and a normal view that displays the list of data collected
in the two form views. http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. After downloading the file, use the following command to extract the sample and build the appropriate directory structure:
MORE INFORMATIONThe most important implementations of this are in:
The standard InitInstance code creates an initial frame, document, and
view during the call to OnFileNew. The code added to the end of the
InitInstance in this sample creates the view objects for the extra views
used in this application and stores their pointers in a CVswapApp member
array. It then cycles through a loop which creates the windows for the
view objects. Each view window is created with a unique child window ID
and a CCreateContext object that associates each view with the same
CDocument object, which was created by OnFileNew. Finally, the sample code
triggers the OnInitialUpdate for the extra views.The SwitchView function created in this sample swaps the current view with a previously hidden view. It accomplishes this by first switching their child window IDs. This is necessary because MFC relies on the standard view pane having the child window ID of AFX_IDW_PANE_FIRST. The rest of the code hides the current view and tells MFC to repaint and begin using the new view. The SaveActiveViewsData is used to save the information from the active view to the document object. It is called by SwitchView whenever a view is switched. SaveActiveViewsData subsequently calls the view's SetToDoc, which actually updates the data from the form view to the document by calling UpdateData with an argument of TRUE. This function uses the DDX/DDV functions specified in the view's DoDataExchange. Sample Code
REFERENCESFor examples of other applications that switch views, please refer to the following SAMPLES:
For more information on DDX and DDV routines, please see Technical Note
26: DDX and DDV Routines in the Microsoft Development Library.For additional information, please see the following article(s) in the Microsoft Knowledge Base: Q99562 Switching Views in a Single Document Interface Program © Microsoft Corporation 1999, All Rights Reserved. Additional query words: VSWAP VSWAP32
Keywords : kbcode kbfile kbsample kbDocView kbMFC kbVC |
Last Reviewed: December 15, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |