the MainFram & FormView in MDI
-
Dear VC-master, Thank you for your attention, In my MDI project, the based view is CFormView. named CMyView. the problem is, in CMainFrame class, SetValue()was defined. in CMyView class, public function SetEdit(true)was defined. in myview.cpp, if I use below, it is ok. void CMyView::OnSendValue() { CMainFrame *pMainfram = (CMainFrame *)AfxGetMainWnd(); pMainfram->SetValue(0x55); } but if In MainFrm.cpp void CMainFrame ::OnSendValue() { CMyView *pMyView= (CMyView *)GetActiveView(); pMyView->SetEdit(true); } it can build successfully, but failed execute. how to call the function/variable in active view?
-
Dear VC-master, Thank you for your attention, In my MDI project, the based view is CFormView. named CMyView. the problem is, in CMainFrame class, SetValue()was defined. in CMyView class, public function SetEdit(true)was defined. in myview.cpp, if I use below, it is ok. void CMyView::OnSendValue() { CMainFrame *pMainfram = (CMainFrame *)AfxGetMainWnd(); pMainfram->SetValue(0x55); } but if In MainFrm.cpp void CMainFrame ::OnSendValue() { CMyView *pMyView= (CMyView *)GetActiveView(); pMyView->SetEdit(true); } it can build successfully, but failed execute. how to call the function/variable in active view?
My first question is have you verified that the CMainFrame::OnSendValue() function is even getting called? Run this in Debug mode... void CMainFrame::OnSendValue() { TRACE("CMainFrame::OnSendValue() called\n"); CMyView* pMyView=(CMyView*)GetActiveView(); pMyView->SetEdit(true); } Do you see the output from the TRACE in the output window? -- modified at 2:38 Wednesday 28th June, 2006