Help - Using Create to dynamiclly create a CFormView view 
Author Message
 Help - Using Create to dynamiclly create a CFormView view

Hi,

Assuming you created a CFormView derived class like this :

class CMyFormView : public CFormView
{
        CMyFormView();           // protected constructor used by dynamic creation
        DECLARE_DYNCREATE(CMyFormView)

public:
        //{{AFX_DATA(CMyFormView)
        enum { IDD = IDD_MYFORMVIEW };
                // NOTE: the ClassWizard will add data members here
        //}}AFX_DATA

        // ...

Quote:
};

You can dynamically create an instance of CMyFormView in the
OnCreateClient() method of your CFrameWnd :

BOOL CMyMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*)
{
        CCreateContext  ctx;
        ctx.m_pNewViewClass = RUNTIME_CLASS (CMyFormView);
        ctx.m_pCurrentDoc       = NULL;
        ctx.m_pNewDocTemplate = NULL;
        ctx.m_pLastView = NULL;
        ctx.m_pCurrentFrame = this;

        return CFrameWnd::OnCreateClient(lpcs, &ctx);

Quote:
}

Best regards,
Jean-Edouard.



Quote:
> I am trying to write an SDI application with multiple views. All the
> views are CFormViews. I followed the example SDI2VIEWS, but I am
> having a problem when I call Create

> I created the form using resource wizard and generated the class using
> class wizard. now I want to show it when the user selects it from the
> drop-down menu. I am doing this in a routine in MainFrame.

> CFormView *m_pWin1View;

> =================================================
> m_pWin1View = new CWin1View(NULL);
> m_pWin1View->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, rectDefault,
> this, NULL, NULL);
> pDoc->AddView(m_pWin1View);
> m_pPrevView->ShowWindow(SW_HIDE);
> m_pWin1View->ShowWindow(SW_SHOW);
> =================================================

> I get this error message:
> error C2248: 'Create' : cannot access protected member declared in
> class 'CFormView'

> Is calling Create for a View based on CFormView invalid? How do I do
> it? Any examples would be appreciated.

> Thanks
> Kenny



Mon, 01 Nov 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Create mutiple views of one document using different view classes

2. Create mutiple views of one document using different view classes

3. Creating edit boxes using create function gives wincore 628 error

4. Attributes not created when ConstructorInfo.Invoke used to create object

5. Creating new views w/o using DocTemplate

6. Adding controls to a view using Create ?

7. How to Assign the Work to Dynamically created Menus while using Doc View Arch

8. Creating new views w/o using DocTemplate

9. Creating new views w/o using DocTemplate

10. Using CFormView without using doc/view

11. Pleas help can't see a created view in Access

12. Help creating simple view swapping

 

 
Powered by phpBB® Forum Software