Brief Full Advanced Search Search Tips
|  |  | To access the contents, click the chapter and section titles. Fast Track Visual C++ 6.0 Programming (Publisher: John Wiley & Sons, Inc.) Author(s): Steve Holzner ISBN: 0471312908 Publication Date: 09/01/98 Search this book:
Previous | Table of Contents | Next
Next, we replace the standard MDI child windows in the document template with our new splitter windows.
    BOOL CSplitterViewApp::InitInstance()
    {
        AfxEnableControlContainer();
            .
            .
            .
        // Register the application’s document templates.  Document templates
        //  serve as the connection between documents, frame windows and views.

        CMultiDocTemplate* pDocTemplate;

        pDocTemplate = new CMultiDocTemplate(

            IDR_SPLITTTYPE,
            RUNTIME_CLASS(CSplitterViewDoc),
            //RUNTIME_CLASS(CChildFrame), // custom MDI child frame
            RUNTIME_CLASS(CSplit), // Splitter windows!                 ⇐
            RUNTIME_CLASS(CSplitterViewView));
        AddDocTemplate(pDocTemplate);
            .
            .
            .
Figure 3.11 Using splitter windows. That’s all it takes. Run the program now, then use the splitter handles to split the view window, as also shown in Figure 3.11, and type something into the view. As you can see, we’re using splitter windows—our new example is a success. The code for this example, SplitterView.h and SplitterView.cpp, appears in Listing 3.3. Listing 3.3 SplitterView.h and SplitterView.cpp
    // SplitterView.h : main header file for the SPLITTERVIEW application
    //

    #if
    !defined(AFX_SPLITTERVIEW_H__093DE002_9FB2_11D1_887F_D42B07C10710__INCLUDED_)
    #define AFX_SPLITTERVIEW_H__093DE002_9FB2_11D1_887F_D42B07C10710__INCLUDED_

    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000

    #ifndef __AFXWIN_H__

       #error include ‘stdafx.h’ before including this file for PCH
    #endif

    #include “resource.h”       // main symbols

    /////////////////////////////////////////////////////////////////////////////
    // CSplitterViewApp:
    // See SplitterView.cpp for the implementation of this class
    //

    class CSplitterViewApp : public CWinApp
    {
    public:
        CSplitterViewApp();

    // Overrides
        // ClassWizard generated virtual function overrides
        //{{AFX_VIRTUAL(CSplitterViewApp)
        public:
        virtual BOOL InitInstance();
        //}}AFX_VIRTUAL

    // Implementation

        //{{AFX_MSG(CSplitterViewApp)
        afx_msg void OnAppAbout();
            // NOTE - the ClassWizard will add and remove member functions here.
            //    DO NOT EDIT what you see in these blocks of generated code !
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
    };

    /////////////////////////////////////////////////////////////////////////////

    //{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately
    before the previous line.

    #endif // !defined(AFX_SPLITTERVIEW_H__093DE002_9FB2_11D1_887F_D42B07C10710__INCLUDED_)

    BOOL CSplitterViewApp::InitInstance()
    {
        AfxEnableControlContainer();

        // Standard initialization
        // If you are not using these features and wish to reduce the size
        //  of your final executable, you should remove from the following
        //  the specific initialization routines you do not need.

    #ifdef _AFXDLL
        Enable3dControls();            // Call this when using MFC in a shared DLL
    #else
        Enable3dControlsStatic();    // Call this when linking to MFC statically
    #endif

        // Change the registry key under which our settings are stored.
        // You should modify this string to be something appropriate
        // such as the name of your company or organization.
        SetRegistryKey(_T(“Local AppWizard-Generated Applications”));

        LoadStdProfileSettings();  // Load standard INI file options (including MRU)

        // Register the application’s document templates.  Document templates
        //  serve as the connection between documents, frame windows and views.

        CMultiDocTemplate* pDocTemplate;
        pDocTemplate = new CMultiDocTemplate(
            IDR_SPLITTTYPE,
            RUNTIME_CLASS(CSplitterViewDoc),
            //RUNTIME_CLASS(CChildFrame), // custom MDI child frame
            RUNTIME_CLASS(CSplit), // Splitter windows!
            RUNTIME_CLASS(CSplitterViewView));
        AddDocTemplate(pDocTemplate);
### What’s Ahead In the next chapter, we begin working with Visual C++ menus, toolbars, and status bars. We cover a great deal in Chapter 4, from using all the standard approaches to menus—including disabling menu items, checking menu items, and working with submenus—to installing popup menus that can appear anywhere in a window, modifying menus at run time, and using bitmap menu items. We also see how to work with toolbars, adding new buttons to toolbars, adding a dropdown combo box to a toolbar (even though this is not supported by any of the standard Visual C++ design tools), supporting status bar prompts, and making—as well as adding—indicators to a status bar.
Previous | Table of Contents | Next

| Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.