Hi all,

I have a Dialog project and I am loading a form view inside a frame:

Code:
int CMyDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    m_pFrame = (CFrameWnd*)RUNTIME_CLASS(CFrameWnd)->CreateObject();  
    m_pFrame->CreateEx(0, NULL, NULL, WS_CHILD, rc, this, AFX_IDW_PANE_FIRST, NULL); 

    CCreateContext ccc;
    ccc.m_pNewViewClass   = RUNTIME_CLASS(CHtmlView);
    ccc.m_pCurrentDoc     = NULL;
    ccc.m_pNewDocTemplate = NULL;
    ccc.m_pLastView       = NULL;
    ccc.m_pCurrentFrame   = NULL;
			
    m_pMyFirstView = (CMyFirstView*)m_pFrame->CreateView(&ccc);
Everything works fine and I can load the view with no problems.

Now I want to toggle between two different views when a buttons is clicked.
So I've extended the code to:

Code:
int CMyDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    m_pFrame = (CFrameWnd*)RUNTIME_CLASS(CFrameWnd)->CreateObject();  
    m_pFrame->CreateEx(0, NULL, NULL, WS_CHILD, rc, this, AFX_IDW_PANE_FIRST, NULL); 

    CCreateContext ccc;
    ccc.m_pNewViewClass   = RUNTIME_CLASS(CHtmlView);
    ccc.m_pCurrentDoc     = NULL;
    ccc.m_pNewDocTemplate = NULL;
    ccc.m_pLastView       = NULL;
    ccc.m_pCurrentFrame   = NULL;
			
    m_pMyFirstView = (CMyFirstView*)m_pFrame->CreateView(&ccc);

    ccc.m_pNewViewClass   = RUNTIME_CLASS(CNoEmailViewForm);
    ccc.m_pCurrentDoc     = NULL;
    ccc.m_pNewDocTemplate = NULL;
    ccc.m_pLastView       = NULL;
    ccc.m_pCurrentFrame   = NULL;
			
    m_pMySecondView = (CMySecondView*)m_pFrame->CreateView(&ccc);
}

void CMyDlg::OnBnClickedButton()
{
    if (m_bFirst)
    {
        m_pMySecondView->ShowWindow(SW_SHOW);
        m_pMyFirstView ->ShowWindow(SW_HIDE);
        m_bFirst = FALSE;
    }
    else
    {
        m_pMySecondView->ShowWindow(SW_HIDE);
        m_pMyFirstView ->ShowWindow(SW_SHOW);
        m_bFirst = TRUE;
    }
}
This again works BUT I'm not sure if this is the correct way to do it.
I have a feeling that I need to do something with m_pLastView (CCreateContext).

Any advice?

Thank you

This again