Pointer to Doc class of SDI
-
I have an SDI and want to get a pointer to class
SDIDoc
. If I was creating a new class instance from withinSDIDoc
, I would do the following:SomeClass* pSC = new SomeClass;
Then I would have a pointerpSC
to the new instance ofSomeClass
. But, sinceSDIDoc
already exists, and I am withinSDIDoc
, how do I get a pointer toSDIDoc
? InSDIDoc.h
I have the following:SDIDoc* pSDIDoc;
InSDIDoc.cpp
, I am looking for the following:pSDIDOC = ???????
Thanks -
I have an SDI and want to get a pointer to class
SDIDoc
. If I was creating a new class instance from withinSDIDoc
, I would do the following:SomeClass* pSC = new SomeClass;
Then I would have a pointerpSC
to the new instance ofSomeClass
. But, sinceSDIDoc
already exists, and I am withinSDIDoc
, how do I get a pointer toSDIDoc
? InSDIDoc.h
I have the following:SDIDoc* pSDIDoc;
InSDIDoc.cpp
, I am looking for the following:pSDIDOC = ???????
Thanks -
I have an SDI and want to get a pointer to class
SDIDoc
. If I was creating a new class instance from withinSDIDoc
, I would do the following:SomeClass* pSC = new SomeClass;
Then I would have a pointerpSC
to the new instance ofSomeClass
. But, sinceSDIDoc
already exists, and I am withinSDIDoc
, how do I get a pointer toSDIDoc
? InSDIDoc.h
I have the following:SDIDoc* pSDIDoc;
InSDIDoc.cpp
, I am looking for the following:pSDIDOC = ???????
ThanksFrom MSDN, All nonstatic member functions can use the this keyword, which is a const (nonmodifiable) pointer to the object for which the function was called. ... Occasionally, the this pointer is used directly — for example, to manipulate self-referential data structures, where the address of the current object is required.
-
I have an SDI and want to get a pointer to class
SDIDoc
. If I was creating a new class instance from withinSDIDoc
, I would do the following:SomeClass* pSC = new SomeClass;
Then I would have a pointerpSC
to the new instance ofSomeClass
. But, sinceSDIDoc
already exists, and I am withinSDIDoc
, how do I get a pointer toSDIDoc
? InSDIDoc.h
I have the following:SDIDoc* pSDIDoc;
InSDIDoc.cpp
, I am looking for the following:pSDIDOC = ???????
ThanksHi, I did it within the
stdafx.cpp
, the #include MyDocument.h should be in stdafx to do thisCMyDoc* pMyDoc;
In your
CMyView::OnInitialUpdate ()
just makeextern CMyDoc* pMyDoc;
pMyDoc = GetDocument ();
ASSERT (pMyDoc);if it is made correctly, you have Doc access from every class using it. I.E.
class CMyObject : public CObject
{
public:
void MyMethode ();
}void CMyObject::MyMethode ()
{
extern CMyDoc* pMyDoc;any_local_variable = pMyDoc->a_document_variable;
return;
}Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson ;)