![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Fast Track Visual C++ 6.0 Programming
Next, we replace the standard MDI child windows in the document template with our new splitter windows. BOOL CSplitterViewApp::InitInstance() { AfxEnableControlContainer(); . . . // Register the applications 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); . . .
Thats 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, were using splitter windowsour 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 applications 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); Whats AheadIn 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 menusincluding disabling menu items, checking menu items, and working with submenusto 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 makingas well as addingindicators to a status bar.
|
![]() |
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. |