Discussion:
Cant use GetDocument() from CDockablePane
(too old to reply)
Teddy
2009-12-14 23:08:01 UTC
Permalink
Hi, Pls hlp me with this one:

In CPropertiesWnd (comming from CDockablePane, infact the same one from MFC
features pack), i can do CTestDoc* pDoc (Test is my app name)...
...but cant do CTestDoc* pDoc = GetDocument()

What can I do instead?
Scott McPhillips [MVP]
2009-12-14 23:17:58 UTC
Permalink
The CWinApp class maintains a list of CDocuments. So you can get the
document(s) by calling

AfxGetApp()->GetFirstDocTemplatePosition

...and then

CDocTemplate::GetFirstDocPosition and GetNextDoc
Post by Teddy
In CPropertiesWnd (comming from CDockablePane, infact the same one from MFC
features pack), i can do CTestDoc* pDoc (Test is my app name)...
...but cant do CTestDoc* pDoc = GetDocument()
What can I do instead?
--
Scott McPhillips [VC++ MVP]
Teddy
2009-12-15 00:53:01 UTC
Permalink
Great thanks, Scott! - Works like a charm :)

Exact code used (in case some nabs like me have same difficulties. "Test" is
my prj name):
CTestDoc* pDoc;
CDocTemplate* pDocTemplate;
POSITION pos;
pos = AfxGetApp()->GetFirstDocTemplatePosition();
pDocTemplate = AfxGetApp()->GetNextDocTemplate(pos);
pos = pDocTemplate->GetFirstDocPosition();
pDoc = (CTestDoc*) pDocTemplate->GetNextDoc(pos);
Post by Scott McPhillips [MVP]
The CWinApp class maintains a list of CDocuments. So you can get the
document(s) by calling
AfxGetApp()->GetFirstDocTemplatePosition
....and then
CDocTemplate::GetFirstDocPosition and GetNextDoc
Post by Teddy
In CPropertiesWnd (comming from CDockablePane, infact the same one from MFC
features pack), i can do CTestDoc* pDoc (Test is my app name)...
...but cant do CTestDoc* pDoc = GetDocument()
What can I do instead?
--
Scott McPhillips [VC++ MVP]
.
Loading...