Split32: How to Replace a View in a Splitter Window

ID: Q149257


The information in this article applies to:
  • The Microsoft Foundation Classes (MFC), used with:
    • Microsoft Visual C++, 32-bit Editions, version 4.0


SUMMARY

The SPLIT32 sample demonstrates the following Microsoft Foundation Class (MFC) programming concepts:

  1. A ReplaceView() function can be created which replaces a view in a CSplitterWnd pane with another. The function replaces a view but uses the same CDocument object. This function can be helpful if a programmer wants to keep the same frame window and document for a splitter pane, and only wants to delete a view in a pane and replace it with another.


  2. The CDocument variable m_bAutoDelete can be used to prevent the destruction of a CDocument object if all views of the document are destroyed.


  3. The CWnd::PreCreateWindow() function can be used to prevent the main application from having a thick frame, thus preventing the user from resizing the main application window.


  4. By trapping the WM_SETCURSOR, WM_MOUSEMOVE, and WM_LBUTTONDOWN messages of a CSplitterWnd, you can fix the splitter bars in a splitter window so that they can't be moved by the user.


  5. CSplitterWnd panes can contain regular CWnd objects and are not limited to the use of CViews. This sample places a dialog in the first pane.


  6. CWnd::CenterWindow() can be used to position windows at the center of the screen.


The following files are available for download from the Microsoft Download Center. Click the file names below to download the files:


Split32.exe

For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center.

NOTE: Use the -d option when running SPLIT32.EXE to decompress the file and recreate the proper directory structure.


MORE INFORMATION

NOTE: The following Microsoft Software Library samples, which also replace various views, are also available:

  • VWRPLC32 (MDI)


  • COLLECT (MDI)


  • ENROLL (SDI)


  • VSWAP32 (SDI)


To understand what the sample does, first execute the program. You will see a main application window with a splitter window (CSplitterWnd) in its client area. A selection dialog will be displayed in the first pane and a view will be displayed in the second pane.

Click on the View 1 and View 2 buttons. Notice that the view in the second pane will switch from one to the other. The view is changing, but after looking at the source you'll see that the document stays the same.

Additional query words: 4.00 split Q102827 softlib

Keywords : kbfile kbsample kbDocView kbMFC kbVC
Version : winnt:4.0
Platform : winnt
Issue type :


Last Reviewed: December 14, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.