Problem : Change view

Hi all,

I am creating an application which is splitted into 2 view. (0,0) pane I am using to show a TreeView derived from CTreeView whereas (0,1) pane is used to represent the details fo that tree.

I am using the following function to change the view.

BOOL CSplitter::ReplaceView(int row, int col,CRuntimeClass * pViewClass,SIZE size)
{
CCreateContext context;
BOOL bSetActive;


if ((GetPane(row,col)->IsKindOf(pViewClass))==TRUE)
return FALSE;


CDocument * pDoc= ((CView *)GetPane(row,col))->GetDocument();
CView * pActiveView=GetParentFrame()->GetActiveView();
if (pActiveView==NULL || pActiveView==GetPane(row,col))
bSetActive=TRUE;
else
bSetActive=FALSE;

pDoc->m_bAutoDelete=FALSE;
((CView *) GetPane(row,col))->DestroyWindow();
pDoc->m_bAutoDelete=TRUE;


context.m_pNewViewClass=pViewClass;
context.m_pCurrentDoc=pDoc;
context.m_pNewDocTemplate=NULL;
context.m_pLastView=NULL;
context.m_pCurrentFrame=NULL;

CreateView(row,col,pViewClass,size, &context);

CView * pNewView= (CView *)GetPane(row,col);

if (bSetActive==TRUE)
GetParentFrame()->SetActiveView(pNewView);

RecalcLayout();
GetPane(row,col)->SendMessage(WM_PAINT);

return TRUE;
}

problem is that I am able to change the view but not able to access any member variable (CStatic m_str, CEdit m_myedit) of the new view




Answer this question

Problem : Change view

  • Joel McCormick

    A view is a view of the document. If both views need to show similar data it should be stored in the document, you should't need data from one view to display another.

  • Problem : Change view