<< Return to Main Index

< Return to Class Index

class CGXTabWndMgr : public CObject

The CGXTabWndMgr class is the primary class that manages the multiple document persistence mechanism.

The CGXTabWndMgr class manages all the tab instances that are associated with a frame window. This class interacts with an abstract CGXTabWndAdapter. Through the interface specified by CGXTabWndAdapter the CGXTabWndMgr manipulates the tab window. There will be a concrete implementation of CGXTabWndAdapter for each tab window that CGXTabWndMgr works with. By default with the Objective Grid class library, we provide an implementation of CGXTabWndAdapter for CGXTabWnd (CGXGridTabWndAdapter)

Steps for adding tab window persistence to your application

a) Derive your document class from CGXDocument instead of CDocument.

b) Change the Serialize function in your document to WorkBookSerialize. (in both the header and .cpp files). Serialize is implemented in a generic manner by the base CGXDocument class which will delegate to your WorkBookSerialize in the correct context.

Change the GRID_DECLARE_DYNCREATE macro in the document header to GXGRID_DECLARE_DYNCREATE. Also, change the IMPLEMENT_DYNCREATE macro in the implementation file to GXIMPLEMENT_DYNCREATE.

c) Change the base class for your child frame from CMDIChildWnd to CGXWChildFrame. To the constructor add a default view and document class that pertains to this project as shown below

   CChildFrame::CChildFrame()
   {
      SetDocRuntimeClass(RUNTIME_CLASS(COg70Doc));
      SetViewRuntimeClass(RUNTIME_CLASS(COg70View));
   }

These will be the defaults used for creation by the grid framework in the absence of explicit runtime classes for the view and document.

d) Change the GRID_DECLARE_DYNAMIC and IMPLEMENT_DYNCREATE to GXGRID_DECLARE_DYNAMIC and GXIMPLEMENT_DYNCREATE

e) Implement a derive class that is a concrete implementation of CGXAppAdapter.

The only function that you need to implement is

virtual CDocTemplate* GetDocTemplate(CRuntimeClass* pViewClass, CRuntimeClass* pDocClass) = 0;

This is typically implemented as shown below. You should return a DocTemplate that is appropriate for the classes that are passed in.

      if (m_pDocTemplate != NULL)
         return m_pDocTemplate;

      m_pDocTemplate = new CMultiDocTemplate(
         IDR_OG70TYPE,
         RUNTIME_CLASS(COg70Doc),
         RUNTIME_CLASS(CChildFrame), // custom MDI child frame
         RUNTIME_CLASS(COg70View));

      return m_pDocTemplate;

where m_pDocTemplate is CMultiDocTemplate member.

f) Derive your application object from the concrete implementation as explained above.

g) The implementation of workbook serialization uses C++ RTTI. Please make sure that RTTI is enabled (/GR). If RTTI is not enabled then the compiled executable that uses tab persistence will fail at runtime.

h) Please look at CGXFrameAdapter for an idea of how this can be customized

to provide specific creation information.

i) In you application, InitInstance, instantiate CGXMultiDocTemplate instead of CMultiDocTemplate.

   pDocTemplate = new CGXMultiDocTemplate(
         IDR_OG70TYPE,

The steps for an SDI application are as above except that CGXWFrame will be used instead of CGXWChildFrame and CGXSingleDocTemplate will be used instead of CGXMultiDocTemplate.

#include <gxtbmgr.h>

See Also

CGXTabWndAdapter

CGXTabWndMgr

Class Members