Workaround: Open dialog in the menu of the view class and return the value of dialog to the view class
Solution:
Set dialog class to Judge,view class as Cvmfcview
1.judge.h defines a c****view* class variable: ccvmfcview* pmain;
2. Add function Onshowdialog (ccvmfcview* pview) in the Judge class instead of DoModal
void Cjudge::onshowdialog (ccvmfcview* pview)
{
pmain=pview;
DoModal ();
}
This will replace the Pmain with PView. So how do you pass the Cvmfcview object pointer to PView? See the next step.
The menu response function in 3.CVMFCView is written
void Ccvmfcview::onselectresult ()
{
Cjudge dlg;
Dlg. Onshowdialog (this);
}
Done.
The function of the view class in the dialog box Judge.cpp can be called directly using Pmain.
====================================================================
There's also a way to get the view class pointer, but sometimes it's not work, because the view class pointer might point to a null value if the fetch method is wrong
cmainframe* pframe= (cmainframe*) AfxGetMainWnd ();
clistctrlview* PView = (clistctrlview*) Pframe->getactiveview ();