Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WindowProc Problem

Status
Not open for further replies.

ltsi

Programmer
Joined
Jul 10, 2003
Messages
7
Location
FR
I am developping with Visual C++.

I have created two view classes inside a two panes split window. I'd like tp make a switch between those 2 views by doubleclicking via WindowProc.

To do this, I have created the following function within MainFrame :

BOOL 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 = GetActiveView();
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();



return TRUE;

}

I call this function within WindowProc which is in one of my 2 view classes :

CMonocanalView * pView=(CMonocanalView *) ((CMainFrame *) AfxGetMainWnd())->ReplaceView(0,1,RUNTIME_CLASS(CMonocanalView),CSize(900,600));

Once executed and after doubleclicking for switching, I have an error message redirecting me in :

LRESULT CWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// OnWndMsg does most of the work, except for DefWindowProc call
LRESULT lResult = 0;
if (!OnWndMsg(message, wParam, lParam, &lResult))
lResult = DefWindowProc(message, wParam, lParam);
return lResult;
}

If someone can help me, that would be very nice.
Thanks

LTSI.
 
Maybe this will help: thread116-513254

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top