Problems to call a function of another class 
Author Message
 Problems to call a function of another class

Hello,

Ive a problem. Ive the two files below. The first one
ist a win32-application and Ive taken out one dialog.
From this Dialog I want to call a funktion Main from
another class, which is written in managed c++. First
Ive put this class into the win32-projekt and have
changed the projekt properties to compile the whole
with /clr.

But when I compile the projekt I  recieve the following
errors:

error C2065: 'Main' : undeclared identifier
error C2653: 'Exportfilter' : is not a class or namespace
name

Why do I recieve the errors and what do I have to do to
get it work?

if I go with the cursor on Exportfilter he displays :  
_gc class Export::Exportfilter
if I go with the cursor on Main he displays void
Export::Exportfilter::Main(void)

Win32- Application:

LRESULT CALLBACK Einlesen(HWND hDlg, UINT message, WPARAM
wParam, LPARAM lParam)
{
   switch (message)
   {
   case WM_INITDIALOG:
        return TRUE;
   case WM_COMMAND:
        if (LOWORD(wParam) == IDOK)  
        {
           Exportfilter::Main();
           MessageBox(hDlg, TEXT("GSD-Datei wurde
erzeugt"), TEXT("Meldung"), MB_OK);
           EndDialog(hDlg, LOWORD(wParam));
                        return TRUE;
        }
        if (LOWORD(wParam) == IDCANCEL)
        {
           EndDialog(hDlg, LOWORD(wParam));
           return TRUE;
        }
        break;
   }
   return FALSE;

Quote:
}

managed C++-class (txt_datei_erzeugen.cpp)

#using <mscorlib.dll>
#using <System.Xml.Dll>
#using <System.Windows.Forms.dll>
#include <stdio.h>
using namespace System;
using namespace System::Globalization;
using namespace System::IO;
using namespace System::Xml;
using namespace System::Xml::Xsl;
using namespace System::Xml::XPath;
using namespace System::Windows::Forms;

namespace Export
{
   __gc public class Exportfilter
   {
   protected:
      static String *style = S"c:/exportfilter_final.xsl";
      static String *xml = S"c:/exportXML.xml";
      static String *string = S"c:/string.xml";
      static String *original =S"c:/WAGOB754.GSD";
   public:
        static String *datei=S"c:/mist.gsd";

        void Main()
        {
        Exportfilter* myExportfilter = new Exportfilter();
        myExportfilter->Run_GSD_Datei_erzeugen();    
        }

        void Run_GSD_Datei_erzeugen()
        {
           ReadTransformWrite();
        }

        void ReadTransformWrite()
        {
           try
           {
                XPathDocument* myXPathDocument = new
XPathDocument (xml);
                XslTransform* myXslTransform= new
XslTransform();
                XmlTextWriter* writer = new XmlTextWriter
(datei,0);
                myXslTransform->Load(style);
                myXslTransform->Transform
(myXPathDocument,0, writer);
                writer->Close();
                Console::WriteLine("success");
           }
           catch (Exception* e)
           {
                String* Fehler = e->ToString();
                String* Meldung =S"Fehler - in Modul
ReadTransformWrite";
                MessageBox::Show (Fehler, Meldung);
           }
        }

  };

Quote:
}



Sat, 18 Dec 2004 16:50:54 GMT  
 Problems to call a function of another class
Hi Susanne,

It seems that you forgot to include the header file for Exportfilter class (txt_datei_erzeugen.h).  Also, since the Exportfilter::Main() is not a static funtion, it cannot be called
directly using "Exportfilter::Main()".  Add a "static" keyword to the declaration of the Main() function or call it on a Exportfilter instance.

In addition, you may need to add "using namespace Export" in the front of the Win32-Application file; otherwise, you have to qualify the use of a type in that namespace.

Hope this helps.

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

Quote:
>Content-Class: urn:content-classes:message


>Subject: Problems to call a function of another class
>Date: Tue, 2 Jul 2002 01:50:54 -0700
>Lines: 124

>MIME-Version: 1.0
>Content-Type: text/plain;
>    charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>X-Newsreader: Microsoft CDO for Windows 2000
>Thread-Index: AcIhpZNg8SxKmF/9QFCGVYcAcMS3oQ==
>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>Newsgroups: microsoft.public.dotnet.languages.vc
>NNTP-Posting-Host: TKMSFTNGXA01 10.201.232.160
>Path: cpmsftngxa08!cpmsftngxa07
>Xref: cpmsftngxa08 microsoft.public.dotnet.languages.vc:11562
>X-Tomcat-NG: microsoft.public.dotnet.languages.vc

>Hello,
>Ive a problem. Ive the two files below. The first one
>ist a win32-application and Ive taken out one dialog.
>From this Dialog I want to call a funktion Main from
>another class, which is written in managed c++. First
>Ive put this class into the win32-projekt and have
>changed the projekt properties to compile the whole
>with /clr.
>But when I compile the projekt I  recieve the following
>errors:
>error C2065: 'Main' : undeclared identifier
>error C2653: 'Exportfilter' : is not a class or namespace
>name
>Why do I recieve the errors and what do I have to do to
>get it work?
>if I go with the cursor on Exportfilter he displays :  
>_gc class Export::Exportfilter
>if I go with the cursor on Main he displays void
>Export::Exportfilter::Main(void)
>Win32- Application:
>LRESULT CALLBACK Einlesen(HWND hDlg, UINT message, WPARAM
>wParam, LPARAM lParam)
>{
>   switch (message)
>   {
>   case WM_INITDIALOG:
>    return TRUE;
>   case WM_COMMAND:
>    if (LOWORD(wParam) == IDOK)  
>    {
>       Exportfilter::Main();
>       MessageBox(hDlg, TEXT("GSD-Datei wurde
>erzeugt"), TEXT("Meldung"), MB_OK);
>       EndDialog(hDlg, LOWORD(wParam));
>                    return TRUE;
>    }
>    if (LOWORD(wParam) == IDCANCEL)
>    {
>       EndDialog(hDlg, LOWORD(wParam));
>       return TRUE;
>    }
>    break;
>   }
>   return FALSE;
>}
>managed C++-class (txt_datei_erzeugen.cpp)
>#using <mscorlib.dll>
>#using <System.Xml.Dll>
>#using <System.Windows.Forms.dll>
>#include <stdio.h>
>using namespace System;
>using namespace System::Globalization;
>using namespace System::IO;
>using namespace System::Xml;
>using namespace System::Xml::Xsl;
>using namespace System::Xml::XPath;
>using namespace System::Windows::Forms;
>namespace Export
>{
>   __gc public class Exportfilter
>   {
>   protected:
>      static String *style = S"c:/exportfilter_final.xsl";
>      static String *xml = S"c:/exportXML.xml";
>      static String *string = S"c:/string.xml";
>      static String *original =S"c:/WAGOB754.GSD";
>   public:
>    static String *datei=S"c:/mist.gsd";

>    void Main()
>    {
>    Exportfilter* myExportfilter = new Exportfilter();
>    myExportfilter->Run_GSD_Datei_erzeugen();    
>        }

>    void Run_GSD_Datei_erzeugen()
>    {
>       ReadTransformWrite();
>    }
>    void ReadTransformWrite()
>    {
>       try
>       {
>            XPathDocument* myXPathDocument = new
>XPathDocument (xml);
>            XslTransform* myXslTransform= new
>XslTransform();
>            XmlTextWriter* writer = new XmlTextWriter
>(datei,0);
>            myXslTransform->Load(style);
>            myXslTransform->Transform
>(myXPathDocument,0, writer);
>            writer->Close();
>            Console::WriteLine("success");
>       }
>       catch (Exception* e)
>       {
>            String* Fehler = e->ToString();
>            String* Meldung =S"Fehler - in Modul
>ReadTransformWrite";
>            MessageBox::Show (Fehler, Meldung);
>       }
>    }
>  };
>}



Sun, 19 Dec 2004 20:53:15 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. destructor is called before copy-constructor on temporary class (allocated on stack during function call)

2. newbie One class calling functions in another class

3. Inherited class function calls from a pointer assigned to the base class

4. CMap call within function call problem

5. One Problem in Calling Static function from Non static function

6. DLL function calling problems (explicit - only knowing function name at runtime)

7. Condition breakpoints and function calls and function calls in Immediate window

8. Calling function in Class from button1_click ?

9. How To: Managed C++ class calling/wrapping C functions and structs

10. Compiler error on call to base class function

11. Calling a base class virtual function

12. ?calling function through pointer in a class

 

 
Powered by phpBB® Forum Software