Home > Software engineering >  Get the document pointer in the application class?
Get the document pointer in the application class?

Time:10-01

Application class wrote a piece of code in
 CAutoPositioningSystemDoc * pDoc=(CAutoPositioningSystemDoc *) (((CFrameWnd *) AfxGetApp () - & gt; M_pMainWnd) - & gt; GetActiveDocument ()); 

Compile links are not error, but run to there is an error,

CodePudding user response:

 POSITION pos=theApp. GetFirstDocTemplatePosition (); 
While (pos!=NULL)
{
CDocTemplate * p=theApp GetNextDocTemplate (pos);
The POSITION posdoc=p - & gt; GetFirstDocPosition ();
While (posdoc!=NULL)
{
CDocument * pDoc=p - & gt; GetNextDoc (posdoc);
If (pDoc!=NULL)
{
The POSITION posview=pDoc - & gt; GetFirstViewPosition ();
If (posview!=NULL)
{
The CView * pV=pDoc - & gt; GetNextView (posview);
}
}
}
}

CodePudding user response:

Need to add every step of the pointer, the middle of the likely failed to get the object step by step
  • Related