(this is the recommended method) in CSDN in single document View of programming, a lot of data transfer between multiple views, here to write one of the most simple, only write in any View: XXXDoc * pDoc=(XXXDoc *) GetDocument (); To get Doc class pointer, since in any one of the View class can access to the Doc in the class member variable, you can use Doc class as the data transfer of a middle class! For example, have A class A, B, C, the B class for the Doc, A and C for the View class, assume that A data in the data in A to C C, to create A public variable in the B, B, and then in, must carry on the data transmission in the class A place to write: BDoc * pDoc=(BDoc *) GetDocument (); PDoc - & gt; B=a; To write in class C: BDoc * pDoc=(BDoc *) GetDocument (); C=pDoc - & gt; b; This time, a it has successfully to c!
Inspection for a moment, I am FirstView ontouch () function call * * * in the Doc variable, use the pDoc - & gt; Enable prompt Doc * * * defined in the middle of the variables, and software compilation that's right, but the operation error, error as shown,
I know it's c=pDoc - & gt; B, because I to pDoc - & gt; B=c assignment statement, wrong to turn into a "memory not to write",
A great god, please help, thank you very much!

CodePudding user response:
CWinApp * pApp=AfxGetApp ();
The POSITION PosDocTemplate=pApp - & gt; GetFirstDocTemplatePosition ();
While (PosDocTemplate)
{
CDocTemplate * pDocTemplate=pApp - & gt; GetNextDocTemplate (PosDocTemplate);
The POSITION PosDoc=pDocTemplate - & gt; GetFirstDocPosition ();
While (PosDoc)
{
CDocument * pDoc=pDocTemplate - & gt; GetNextDoc (PosDoc);
The POSITION PosView=pDoc - & gt; GetFirstViewPosition ();
While (PosView)
{
The CView * pView=pDoc - & gt; GetNextView (PosView);
}
}
}
CodePudding user response:
Not a single document?CodePudding user response:
Such as:Void CFileView: : OnActivateView (BOOL bActivate, CView * pActivateView, CView * pDeactiveView)
{
The CView: : OnActivateView (bActivate pActivateView, pDeactiveView);
If (GetDocument () - & gt; IsKindOf (RUNTIME_CLASS (CPViewDoc)))
TheApp. SetStatusBarText (((CPViewDoc *) GetDocument ()) - & gt; SzStatusMessage);
The else
TheApp. SetStatusBarText (((CViewfileDoc *) GetDocument ()) - & gt; SzStatusMessage);
}
CodePudding user response: