Hi.
I have a document in which there is a CView and CFormView within a split window. I am using the following function to make a switch between the 2 CViews and the 2 CFormViews simultaneously:
void CMainFrame::ReplaceView(int row, int col, CRuntimeClass *pViewClass, SIZE size)
{
BOOL bSetActive=TRUE;
//if ((m_wndSplitter.GetPane(row,col)->IsKindOf(pViewClass))==TRUE)
//return FALSE;
// Get pointer to CDocument object so that it can be used in the creation
// process of the new view
CDocument * pDoc= ((CView *)((CMainFrame*)AfxGetMainWnd())->m_wndSplitter.GetPane(row,col))->GetDocument();
CView * pActiveView = (CView*)((CMainFrame*)AfxGetMainWnd())->m_wndSplitter.GetPane(row,col)->GetActiveWindow();
if (pActiveView==NULL || pActiveView==m_wndSplitter.GetPane(row,col))
bSetActive=TRUE;
else
bSetActive=FALSE;
// set flag so that document will not be deleted when view is destroyed
pDoc->m_bAutoDelete=FALSE;
// Delete existing view
((CView *)((CMainFrame*)AfxGetMainWnd())->m_wndSplitter.GetPane(row,col))->DestroyWindow();
// set flag back to default
pDoc->m_bAutoDelete=TRUE;
// Create new view
CCreateContext context;
context.m_pNewViewClass=pViewClass;
context.m_pCurrentDoc=pDoc;
context.m_pNewDocTemplate=NULL;
context.m_pLastView=NULL;
context.m_pCurrentFrame=NULL;
CView * pNewView= (CView *)((CMainFrame*)AfxGetMainWnd())-> m_wndSplitter.CreateView(row,col,pViewClass,size, &context);
//CView * pNewView= (CView *)((CMainFrame*)AfxGetMainWnd())->m_wndSplitter.GetPane(row,col);
RecalcLayout();
RedrawWindow();
}
It works perfectly.
But when making the switch between the CViews and the CFormViews, the two split windows are not active right now. I have to make a increase of the window in order to get access to the functions of the CFormView.
How can I do?
If somebody can help me, I would be very happy.
Thanks.
LTSI.
I have a document in which there is a CView and CFormView within a split window. I am using the following function to make a switch between the 2 CViews and the 2 CFormViews simultaneously:
void CMainFrame::ReplaceView(int row, int col, CRuntimeClass *pViewClass, SIZE size)
{
BOOL bSetActive=TRUE;
//if ((m_wndSplitter.GetPane(row,col)->IsKindOf(pViewClass))==TRUE)
//return FALSE;
// Get pointer to CDocument object so that it can be used in the creation
// process of the new view
CDocument * pDoc= ((CView *)((CMainFrame*)AfxGetMainWnd())->m_wndSplitter.GetPane(row,col))->GetDocument();
CView * pActiveView = (CView*)((CMainFrame*)AfxGetMainWnd())->m_wndSplitter.GetPane(row,col)->GetActiveWindow();
if (pActiveView==NULL || pActiveView==m_wndSplitter.GetPane(row,col))
bSetActive=TRUE;
else
bSetActive=FALSE;
// set flag so that document will not be deleted when view is destroyed
pDoc->m_bAutoDelete=FALSE;
// Delete existing view
((CView *)((CMainFrame*)AfxGetMainWnd())->m_wndSplitter.GetPane(row,col))->DestroyWindow();
// set flag back to default
pDoc->m_bAutoDelete=TRUE;
// Create new view
CCreateContext context;
context.m_pNewViewClass=pViewClass;
context.m_pCurrentDoc=pDoc;
context.m_pNewDocTemplate=NULL;
context.m_pLastView=NULL;
context.m_pCurrentFrame=NULL;
CView * pNewView= (CView *)((CMainFrame*)AfxGetMainWnd())-> m_wndSplitter.CreateView(row,col,pViewClass,size, &context);
//CView * pNewView= (CView *)((CMainFrame*)AfxGetMainWnd())->m_wndSplitter.GetPane(row,col);
RecalcLayout();
RedrawWindow();
}
It works perfectly.
But when making the switch between the CViews and the CFormViews, the two split windows are not active right now. I have to make a increase of the window in order to get access to the functions of the CFormView.
How can I do?
If somebody can help me, I would be very happy.
Thanks.
LTSI.