MFC Application mit ATL??



  • Hi!

    Ich versuche bei einer MFC Anwendung ATL Support einzubinden.
    In dem Helpfile steht folgender Text als Beispiel:

    MFC application with ATL support

    A similar example can be found in the SDK\Src\S_Client_VC folder on the Correction SDK CD.

    Create your MFC EXE application with the AppWizard.

    Add an #import statement in one of your header files (preferred: stdafx.h).

    #import "SmXAudio.tlb" raw_interfaces_only named_guids

    #import "SmXCorr.tlb" raw_interfaces_only named_guids

    Make sure the #import statement of the SmCorrection and SmAudio type libraries specifies named_guids and raw_interfaces_only as part of the parameters. This will ensure the availability of macros and GUID variables that will be used later in the code.

    You need to instantiate a ATL COM object that supports the interfaces. The VC++ 6.0 AppWizard can add supporting ATL code (CExeModule, registration, and ATL initialization) as well as an object supporting an interface with the required IDL file.

    In the ClassView pane, right-click on the MFC application. Select "New ATL Object." A dialog box will appear asking you whether you want to "Add ATL support to your MFC project." Select "Yes". You will probably see another dialog box that reports an "Error generating project" (VC6 with Service Pack < 4). Cancel this dialog box and ignore this error. If you get no error message, click "Cancel" in the ATL Object Selection Dialog and delete the newly added object files (idl, rgs). You do not need them. The wizard adds all of the supporting ATL code required (InitATL(),CExeModule).

    Add ATL events sinks:

    Copy the following files from the VC Sample in the SDK to your project directory:

    CorrectionEventSink.cpp and CorrectionEventSink.h for the ISmCorrection events;

    AudioEventSink.cpp and AudioEventSink.h for the ISmAudio events.

    Add these files to your project.

    Create and initialize the Controls:

    // pointer to correction interface

    CComPtr<ISmCorrection> m_pISmCorrection;

    // pointer to audio interface

    CComPtr<ISmAudio> m_pISmAudio;

    // correction event sink

    CSmCorrectionEventSink *m_pEventSink;

    // create instances of the COM controls

    m_pISmCorrection.CoCreateInstance(__uuidof(SmCorrection));

    m_pISmAudio.CoCreateInstance(__uuidof(SmAudio));

    // create correction event sink

    m_pEventSink = new CSmCorrectionEventSink(this);

    // establish a connection with the event source:

    m_pEventSink->DispEventAdvise(m_pISmCorrection);

    // initialize the audio control

    m_pISmAudio ->Initialize();

    // set correction interface pointer in audio

    m_pISmAudio ->put_ISmCorrection(m_pISmCorrection);

    Nur leider bekomme ich folgende Fehler:

    --------------------Konfiguration: CorrectionSDK - Win32 Release--------------------
    Ressourcen werden kompiliert...
    Kompilierung läuft...
    StdAfx.cpp
    Kompilierung läuft...
    AudioEventSink.cpp
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : error C2065: 'ISmCorrection' : nichtdeklarierter Bezeichner
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : error C2955: 'CComPtr' : Fuer die Verwendung einer Vorlagenklasse ist eine Vorlagen-Argumentliste erforderlich
    D:\Programme\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlbase.h(563) : Siehe Deklaration von 'CComPtr'
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : fatal error C1903: Weiterverarbeitung nach vorhergehendem Fehler nicht moeglich; Kompilierung wird abgebrochen.
    CntrItem.cpp
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : error C2065: 'ISmCorrection' : nichtdeklarierter Bezeichner
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : error C2955: 'CComPtr' : Fuer die Verwendung einer Vorlagenklasse ist eine Vorlagen-Argumentliste erforderlich
    D:\Programme\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlbase.h(563) : Siehe Deklaration von 'CComPtr'
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : fatal error C1903: Weiterverarbeitung nach vorhergehendem Fehler nicht moeglich; Kompilierung wird abgebrochen.
    CorrectionEventSink.cpp
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : error C2065: 'ISmCorrection' : nichtdeklarierter Bezeichner
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : error C2955: 'CComPtr' : Fuer die Verwendung einer Vorlagenklasse ist eine Vorlagen-Argumentliste erforderlich
    D:\Programme\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlbase.h(563) : Siehe Deklaration von 'CComPtr'
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : fatal error C1903: Weiterverarbeitung nach vorhergehendem Fehler nicht moeglich; Kompilierung wird abgebrochen.
    CorrectionSDK.cpp
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : error C2065: 'ISmCorrection' : nichtdeklarierter Bezeichner
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : error C2955: 'CComPtr' : Fuer die Verwendung einer Vorlagenklasse ist eine Vorlagen-Argumentliste erforderlich
    D:\Programme\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlbase.h(563) : Siehe Deklaration von 'CComPtr'
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : fatal error C1903: Weiterverarbeitung nach vorhergehendem Fehler nicht moeglich; Kompilierung wird abgebrochen.
    CorrectionSDKDoc.cpp
    CorrectionSDKView.cpp
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : error C2065: 'ISmCorrection' : nichtdeklarierter Bezeichner
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : error C2955: 'CComPtr' : Fuer die Verwendung einer Vorlagenklasse ist eine Vorlagen-Argumentliste erforderlich
    D:\Programme\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlbase.h(563) : Siehe Deklaration von 'CComPtr'
    d:\MYPROJECTS\__KIS\_CORRECTION SDK\CorrectionSDK\CorrectionSDKView.h(38) : fatal error C1903: Weiterverarbeitung nach vorhergehendem Fehler nicht moeglich; Kompilierung wird abgebrochen.
    MainFrm.cpp
    Generieren von Code...
    Fehler beim Ausführen von cl.exe.

    CorrectionSDK.exe - 15 Fehler, 0 Warnung(en)

    Leider finde ich keinen Fehler.

    Sollte jemand mit Ahnung noch Code brauchen, dann bitte posten, da ich nun nicht weiß was ich hier an Code posten soll.

    Vielen Dank schonmal im voraus.



  • Ein bißchen weiter bin ich schon gekommen:

    Nach einigem Blättern in der MSDN stieß ich auf:

    #include <atlctl.h>
    

    Das habe ich eingefügt und damit die Fehler dezimiert auf:

    Temporäre Dateien und Ausgabedateien für "Corr2 - Win32 Release" werden gelöscht.
    --------------------Konfiguration: Corr2 - Win32 Release--------------------
    Typbibliothek wird erstellt...
    Processing d:\MYPROJECTS\__KIS\_CORRECTION SDK\Corr2\Corr2.odl
    Corr2.odl
    Processing D:\Programme\Microsoft Visual Studio\VC98\INCLUDE\oaidl.idl
    oaidl.idl
    Processing D:\Programme\Microsoft Visual Studio\VC98\INCLUDE\objidl.idl
    objidl.idl
    Processing D:\Programme\Microsoft Visual Studio\VC98\INCLUDE\unknwn.idl
    unknwn.idl
    Processing D:\Programme\Microsoft Visual Studio\VC98\INCLUDE\wtypes.idl
    wtypes.idl
    Ressourcen werden kompiliert...
    Kompilierung läuft...
    StdAfx.cpp
    D:\Programme\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlwin.h(19) : fatal error C1189: #Fehler : atlwin.h requires atlbase.h to be included first
    Fehler beim Ausführen von cl.exe.

    Corr2.exe - 1 Fehler, 0 Warnung(en)

    Allerdings includiere ich die atlbase.h vor der atlctl.h aus der die atlwin.h aufgerufen wird.

    Kann mir wer helfen?



  • *schiebt den Thread ganz uncharmant nach oben*

    Kennt vielleicht jemand ein gutes Buch über COM/ATL?

    Ich komme leider überhaupt nicht weiter. 😞


Anmelden zum Antworten