CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Guest

    please please Give me ur suggestion regarding a global function declaration

    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 !!



  2. #2
    Join Date
    May 1999
    Location
    Paris, France
    Posts
    216

    Re: please please Give me ur suggestion regarding a global function declaration

    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()


  3. #3
    Guest

    Re: please please Give me ur suggestion regarding a global function declaration

    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


  4. #4
    Join Date
    May 1999
    Location
    Paris, France
    Posts
    216

    Re: please please Give me ur suggestion regarding a global function declaration

    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);


  5. #5
    Guest

    Re: please please Give me ur suggestion regarding a global function declaration

    Wow , it is working fine ,thanx a lot
    Asha


  6. #6
    Join Date
    May 1999
    Location
    Antwerp, Belgium
    Posts
    136

    Re: please please Give me ur suggestion regarding a global function declaration

    Consider to make a class that handles your file. In that class you can make a method WriteToDisk.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured