Call a function from another class
-
I have 2 classes. Class A:
void CDbModReactor::objectModified(const AcDbDatabase* pDb,
const AcDbObject* pDbObj)
{
AcAxDocLock docLock(pDbObj->ownerId(), AcAxDocLock::kNormal);if(docLock.lockStatus() != Acad::eOk) return; else gpDlg->OnCopy2Excell("modified", pDbObj);
}
Class B:
void CSampDialog::function1()
{FILE \* pFile; pFile = fopen ("C:myfile.csv","a"); if (pFile!=NULL) { CString x2 = Cent\_X+","+Cent\_Y+"\\n"; fwrite(x2, x2.GetLength(), 1, pFile); fclose (pFile); }
}
Now i have to call the function void CDbModReactor::objectModified(const AcDbDatabase* pDb, const AcDbObject* pDbObj) from void CSampDialog::function1() How can i call... Please help me...
G.Paulraj
-
I have 2 classes. Class A:
void CDbModReactor::objectModified(const AcDbDatabase* pDb,
const AcDbObject* pDbObj)
{
AcAxDocLock docLock(pDbObj->ownerId(), AcAxDocLock::kNormal);if(docLock.lockStatus() != Acad::eOk) return; else gpDlg->OnCopy2Excell("modified", pDbObj);
}
Class B:
void CSampDialog::function1()
{FILE \* pFile; pFile = fopen ("C:myfile.csv","a"); if (pFile!=NULL) { CString x2 = Cent\_X+","+Cent\_Y+"\\n"; fwrite(x2, x2.GetLength(), 1, pFile); fclose (pFile); }
}
Now i have to call the function void CDbModReactor::objectModified(const AcDbDatabase* pDb, const AcDbObject* pDbObj) from void CSampDialog::function1() How can i call... Please help me...
G.Paulraj
-
Paulraj G wrote:
How can i call..
Create an instance of the
CDbModReactor
class and call the function as required. This is basic C++, and if you do not understand how to do it you may need to go back to your learning materials.Hi... Thanks for your reply. This is the basic thing that i know. but i don't have variable to pass from here. if i call the function like
CDbModReactor cdbmod;
cdbmod.objectModified();that shows error. also i have tried like
CDbModReactor cdbmod;
cdbmod.objectModified(pDb, pDbObj);i don't have variables. that is the problem. with out variables how can i call the function?
G.Paulraj
-
Hi... Thanks for your reply. This is the basic thing that i know. but i don't have variable to pass from here. if i call the function like
CDbModReactor cdbmod;
cdbmod.objectModified();that shows error. also i have tried like
CDbModReactor cdbmod;
cdbmod.objectModified(pDb, pDbObj);i don't have variables. that is the problem. with out variables how can i call the function?
G.Paulraj
-
Hi... Thanks for your reply. This is the basic thing that i know. but i don't have variable to pass from here. if i call the function like
CDbModReactor cdbmod;
cdbmod.objectModified();that shows error. also i have tried like
CDbModReactor cdbmod;
cdbmod.objectModified(pDb, pDbObj);i don't have variables. that is the problem. with out variables how can i call the function?
G.Paulraj
-
I have 2 classes. Class A:
void CDbModReactor::objectModified(const AcDbDatabase* pDb,
const AcDbObject* pDbObj)
{
AcAxDocLock docLock(pDbObj->ownerId(), AcAxDocLock::kNormal);if(docLock.lockStatus() != Acad::eOk) return; else gpDlg->OnCopy2Excell("modified", pDbObj);
}
Class B:
void CSampDialog::function1()
{FILE \* pFile; pFile = fopen ("C:myfile.csv","a"); if (pFile!=NULL) { CString x2 = Cent\_X+","+Cent\_Y+"\\n"; fwrite(x2, x2.GetLength(), 1, pFile); fclose (pFile); }
}
Now i have to call the function void CDbModReactor::objectModified(const AcDbDatabase* pDb, const AcDbObject* pDbObj) from void CSampDialog::function1() How can i call... Please help me...
G.Paulraj
In your own code...
gpDlg->OnCopy2Excell("modified", pDbObj);
That seems to me as a external call from your class "CDBModReactor" to the class pointed by "gpDlg" containing the function "OnCopy2Excell", so... if this is like that... you have answered your question by yourself. (Supposing you have written the code)
Regards. -------- 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 Rating helpfull answers is nice, but saying thanks can be even nicer.