Click to See Complete Forum and Search --> : please please Give me ur suggestion regarding a global function declaration


May 20th, 1999, 05:56 AM
Hai ,
I have created an MFC appwizard.exe project , it has all collection of files
my problem i need to call a single function from any where in all the programs , like from viewfile , doc file or all the related files to this project , i need to call a function writetodisk(), WHERE WILL I DECLARE AND DEFINE THIS FUNCTION
I KNOW I HAVE TO DEFINE GLOBALLY BUT WHERE I DON'T KNOW
please help me !!

olivier
May 20th, 1999, 06:14 AM
you can put as a static method of your application.

CMyApp.h
=============================
class CMyApp : public CWinApp
{
............
public :
static void writetodisk();
}


CMyApp.cpp
========================
void CMyApp::writetodisk()
{
......
}

now you can use anywhere :
to call it : CMyApp::writetodisk()

May 20th, 1999, 06:35 AM
Thanx a lot , but inside static function i can use only static variables is it?
but my writedisk(cstring,cstring,int) takes 3 input parameter and sending one output parameter like cstring writedisk(cstring,csring,int)
what will i do in this case
sorry i could have mentioned that this function takes 3 parameter

olivier
May 20th, 1999, 06:42 AM
you can put the method no static, but still plublic.
and a anyttime you can call like :
CString sResult = ((CMyApp*)AfxGetApp())->writedisk ("string1", "string2" 1);

May 20th, 1999, 07:24 AM
Wow , it is working fine ,thanx a lot
Asha

Franky Braem
May 20th, 1999, 08:46 AM
Consider to make a class that handles your file. In that class you can make a method WriteToDisk.