how to get cview or cdocment object pointer?
-
in MFC, I know doc and view is created in ProcessShellCommand with CSingleDocTemplate. but I wanna get current view pointer so that I can hide it by ShowWindow(getView(), SW_HIDE);
First, pos = AfxGetApp()->GetFirstDocTemplatePosition(); ASSERT(pos); pTemplate=AfxGetApp()->GetNextDocTemplate(pos); POSITION docpos=pTemplate->GetFirstDocPosition( ); get the first DocTemplate. Then you can enumerate your views. CDocument *pDocument=NULL; while (docpos) { pDocument = pTemplate->GetNextDoc(docpos); ASSERT(pDocument); POSITION viewpos = pDocument->GetFirstViewPosition(); while (viewpos != NULL) { ... } } Hope this helps, Hardy.
-
First, pos = AfxGetApp()->GetFirstDocTemplatePosition(); ASSERT(pos); pTemplate=AfxGetApp()->GetNextDocTemplate(pos); POSITION docpos=pTemplate->GetFirstDocPosition( ); get the first DocTemplate. Then you can enumerate your views. CDocument *pDocument=NULL; while (docpos) { pDocument = pTemplate->GetNextDoc(docpos); ASSERT(pDocument); POSITION viewpos = pDocument->GetFirstViewPosition(); while (viewpos != NULL) { ... } } Hope this helps, Hardy.