Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Attaching a CTreeView derived class to a CExtTabPageContainerFlatWnd Collapse All
Subject Author Date
Martin Ashton Nov 30, 2008 - 8:12 PM

Hi,


I am converting the windows interface of a VS2005 MFC project using the Prof-UIS library.


I have a CTreeView derived class called CdNetTree. I would like to insert two instances of this class into a CExtTabPageContainerFlatWnd (so that I have two tabs each containing a tree view).


The problem I have is with the protected constructors of the derived TreeView class - I cannot create an instance of the view and then pass a HWND or pWnd to the CExtTabPageContainerFlatWnd.


Is it possible to attach a CTreeView derived class to a CExtTabPageContainerFlatWnd? If so, the procedure would be most appreciated.


Regards,


Martin Ashton

Martin Ashton Dec 1, 2008 - 8:01 PM

Many thanks!

Technical Support Dec 1, 2008 - 10:26 AM

There are two solutions:

1) Make constructor of your tree view class public. Please note, MFC view and frame classes are designed for dynamic instantiation only and automatically delete themselves in the PostNcDestroy() virtual method.

2) Create your tree view dynamically via its runtime class information. This requires your view to have DECLARE_DYNCREATE/IMPLEMENT_DYNCREATE or DECLARE_SERIAL/IMPLEMENT_SERIAL features in its class declaration. Here is how to create your view window.

CExtTabPageContainerFlatWnd * pWndTPC = . . .
CRuntimeClass * pRTC = RUNTIME_CLASS( CYourViewClassNameHere );
CCreateContext context;
            context.m_pCurrentFrame = pMainFrameWindow; // or NULL
            context.m_pCurrentDoc = NULL;
            context.m_pLastView = NULL;
CYourViewClassNameHere *pYourView = (CExtPPVW_HostWnd*) pPreviewViewClass->CreateObject();
                        if( ! pYourView->Create(
                                                NULL,
                                                NULL,
                                                AFX_WS_DEFAULT_VIEW&(~(WS_BORDER))|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
                                                CRect(0,0,0,0),
                                                pWndTPC,
                                                AFX_IDW_PANE_FIRST,
                                                &context
                                                )
                                    )
            {
                        ASSERT( FALSE );
                        return . . .
            }
            pWndTPC->PageInsert( . . . pYourView . . . );