• Welcome to Theos PowerBasic Museum 2017.

Problem with Jose Roca Includes Inc (COM)

Started by Ralph Steinkönig, May 06, 2009, 05:23:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ralph Steinkönig

Hi

i have a Problem with implementation a IOleObject-Interface with Jose's INC-Files.

I have this implemantation in my Class:

'IOleObject
    INTERFACE IOleObjectImpl $IID_IOleObject AS HIDDEN
        INHERIT IUNKNOWN
        METHOD SetClientSite (BYREF pIOCs AS IOleClientSite) AS LONG
        END METHOD
        METHOD GetClientSite (BYREF pIOCs AS IOleClientSite) AS LONG
        END METHOD
        METHOD SetHostNames (BYVAL szConainterapp AS LONG, BYVAL szContainerObj AS LONG) AS LONG
        END METHOD
        METHOD CLOSE (BYVAL wSaveOption AS LONG) AS LONG
        END METHOD
        METHOD SetMoniker (BYVAL dwWhichMoniker AS LONG, BYREF pmk AS LONG) AS LONG
        END METHOD
        METHOD GetMoniker (BYVAL dwAssign AS LONG, BYVAL dwWhichMoniker AS LONG, BYREF pmk AS LONG) AS LONG
        END METHOD
        METHOD InitFromData (pDataObject AS IDataObject, BYVAL fCreation AS LONG, OPTIONAL dwReserved AS VARIANT) AS LONG
        END METHOD
        METHOD GetClipboardData (BYVAL wReserved AS LONG, BYREF ppDataObject AS IDataObject) AS LONG
        END METHOD
        METHOD DoVerb (BYVAL iVerb AS LONG, BYREF lpmsg AS tagMsg, BYREF pActiveSite AS IOleClientSite, BYVAL lindex AS LONG, BYVAL hwndParent  AS LONG, BYREF lprcPosRect AS RECT) AS LONG
        END METHOD
        METHOD EnumVerbs (BYREF ppEnumOleVerb AS IEnumOleVerb) AS LONG
        END METHOD
        METHOD Update () AS LONG
        END METHOD
        METHOD IsUpToDate () AS LONG
        END METHOD
        METHOD GetUserClassID (BYREF pClsid AS GUID) AS LONG
        END METHOD
        METHOD GetUserType (BYVAL dwFormOfType AS LONG, BYREF pszUserType AS LONG) AS LONG
        END METHOD
        METHOD SetExtent (BYVAL dwDrawAspec AS LONG, BYREF psizel AS SIZEL) AS LONG
        END METHOD
        METHOD GetExtent (BYVAL dwDrawAspect  AS LONG, BYREF psizel AS SIZEL) AS LONG
        END METHOD
        METHOD Advise (BYREF pAdvSink AS IAdviseSink, BYREF pdwConnection AS LONG) AS LONG
        END METHOD
        METHOD Unadvise (BYVAL dwConnection AS LONG) AS LONG
        END METHOD
        METHOD EnumAdvise (BYREF ppenumAdvise AS IEnumSTATDATA) AS LONG
        END METHOD
        METHOD GetMiscStatus (BYVAL dwAspect AS LONG, BYREF pdwStatus AS LONG) AS LONG
        END METHOD
    END INTERFACE


The Compiler post an error named: Type Library creation error.

And now:


INTERFACE IOleObjectImpl $IID_IOleObject AS HIDDEN
        INHERIT IUNKNOWN
        METHOD SetClientSite (BYREF pIOCs AS IOleClientSite) AS LONG
        END METHOD
        METHOD GetClientSite (BYREF pIOCs AS IOleClientSite) AS LONG
        END METHOD
        METHOD SetHostNames (BYVAL szConainterapp AS LONG, BYVAL szContainerObj AS LONG) AS LONG
        END METHOD
        METHOD CLOSE (BYVAL wSaveOption AS LONG) AS LONG
        END METHOD
        METHOD SetMoniker (BYVAL dwWhichMoniker AS LONG, BYREF pmk AS LONG) AS LONG
        END METHOD
        METHOD GetMoniker (BYVAL dwAssign AS LONG, BYVAL dwWhichMoniker AS LONG, BYREF pmk AS LONG) AS LONG
        END METHOD
        METHOD InitFromData (pDataObject AS IDataObject, BYVAL fCreation AS LONG, OPTIONAL dwReserved AS VARIANT) AS LONG
        END METHOD
        METHOD GetClipboardData (BYVAL wReserved AS LONG, BYREF ppDataObject AS IDataObject) AS LONG
        END METHOD
        METHOD DoVerb (BYVAL iVerb AS LONG, BYREF lpmsg AS tagMsg, BYREF pActiveSite AS IOleClientSite, BYVAL lindex AS LONG, BYVAL hwndParent  AS LONG, BYREF lprcPosRect AS RECT) AS LONG
        END METHOD
        METHOD EnumVerbs (BYREF ppEnumOleVerb AS IEnumOleVerb) AS LONG
        END METHOD
        METHOD Update () AS LONG
        END METHOD
        METHOD IsUpToDate () AS LONG
        END METHOD
        METHOD GetUserClassID (BYREF pClsid AS GUID) AS LONG
        END METHOD
        METHOD GetUserType (BYVAL dwFormOfType AS LONG, BYREF pszUserType AS LONG) AS LONG
        END METHOD
        METHOD SetExtent (BYVAL dwDrawAspec AS LONG, BYREF psizel AS SIZEL) AS LONG
        END METHOD
        METHOD GetExtent (BYVAL dwDrawAspect  AS LONG, BYREF psizel AS SIZEL) AS LONG
        END METHOD
        '------------------>METHOD Advise (BYREF pAdvSink AS IAdviseSink, BYREF pdwConnection AS LONG) AS LONG
        '------------------>END METHOD
        METHOD Advise (BYREF pAdvSink AS DWORD, BYREF pdwConnection AS LONG) AS LONG
        END METHOD
        METHOD Unadvise (BYVAL dwConnection AS LONG) AS LONG
        END METHOD
        METHOD EnumAdvise (BYREF ppenumAdvise AS IEnumSTATDATA) AS LONG
        END METHOD
        METHOD GetMiscStatus (BYVAL dwAspect AS LONG, BYREF pdwStatus AS LONG) AS LONG
        END METHOD
    END INTERFACE


I hope the candidate was IAdviseSink. I replace it with dword. And then the Compiler means: Hidden interfaces referenced with COM  ???

what's wrong?                   

and now in german language (better ;) )

Ich habe ein Problem mit den Include-Files von Jose Roca. Ich schreibe gerade eine Klasse, die IOleObject implementieren muss. Bei der Übersetzung des Interfaces gibt es ein Problem mit dem Typelib-Creator von PB: Es kann keine Typelib erzeugt werden. Ich bin darauf gekommen, dass der Ausdruck mit: IAdviseSink den Fehler auslöst. Ändere ich de Ausdruck, erhalte ich aber einen anderen Fehler. Die beiden Fehler sind oben angemerkt. Was ist bloß falsch, wieso hängt der Typelib-Creater ab?

José Roca

 
The problem must be in the code that you are not showing.

Quote
Error 602 - Hidden interface referenced by COM
Hidden interface referenced by COM - The compiler was not able to create a Type Library.  The most likely cause is the use of a Hidden Interface as a parameter or return value in a METHOD or PROPERTY published AS COM.

You are declaring the interface as HIDDEN, yet you apparently are using it as a parameter or return value in a METHOD or PROPERTY published AS COM.

Ralph Steinkönig

#2
Hi Jose,

the interface IAdviseSink is missing in your OCIdl.inc. Only IAdviseSinkEx is found there.
As Hidden as Attribut for this interface is not the error (i must this interface hidden ;) ).

German:

Als As Hidden muss ich das Interface deklarieren - und das ist auch üblich in COM. IAdviseSink gehört zur OCIDL.h, aber in Deiner OCIDL.inc ist dieses Interface nicht deklariert, sondern nur IAdviseSinkEx. IAdviseSink ist normalerweise kein typisches COM-Interface. Seltsam ist, dass der Compiler das fehlen von IAdviseSink nicht anzeigt.

José Roca

Quote
the interface IAdviseSink is missing in your OCIdl.inc. Only IAdviseSinkEx is found there.

It is in objidl.inc, where it belongs.

Quote
As Hidden as Attribut for this interface is not the error (i must this interface hidden

But if it is hidden then you can't use it as a parameter or return value in another interface declared AS COM.

Ralph Steinkönig

Hi Jose,

have you an idea? how we can skipping this problem?
I'm working over this problem since a lot of hours.

José Roca

 
Remove AS HIDDEN.

BTW there are some errors in the declarations of the parameters (some are declared as BYREF instead of BYVAL) and the SetColorScheme method is missing.

Should be:


INTERFACE IOleObjectImpl $IID_IOleObject

   INHERIT IUnknown

   ' =====================================================================================
   METHOD SetClientSite ( _                             ' VTable offset = 12
     BYVAL pClientSite AS IOleClientSite _              ' __in IOleClientSite *pClientSite
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetClientSite ( _                             ' VTable offset = 16
     BYREF ppClientSite AS IOleClientSite _             ' __out IOleClientSite **ppClientSite
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD SetHostNames ( _                              ' VTable offset = 20
     BYVAL szContainerApp AS DWORD _                    ' __in LPCOLESTR szContainerApp
   , BYVAL szContainerObj AS DWORD _                    ' __in LPCOLESTR szContainerObj
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD Close ( _                                     ' VTable offset = 24
     BYVAL dwSaveOption AS DWORD _                      ' __in DWORD dwSaveOption
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD SetMoniker ( _                                ' VTable offset = 28
     BYVAL dwWhichMoniker AS DWORD _                    ' __in DWORD dwWhichMoniker
   , BYVAL pmk AS DWORD _                               ' __in IMoniker *pmk
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetMoniker ( _                                ' VTable offset = 32
     BYVAL dwAssign AS DWORD _                          ' __in DWORD dwAssign
   , BYVAL dwWhichMoniker AS DWORD _                    ' __in DWORD dwWhichMoniker
   , BYREF pmk AS IMoniker _                            ' __out IMoniker **pmk
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD InitFromData ( _                              ' VTable offset = 36
     BYVAL pDataObject AS IDataObject _                 ' __in IDataObject *pDataObject
   , BYVAL fCreation AS LONG _                          ' __in BOOL fCreation
   , BYVAL dwReserved AS DWORD _                        ' __in DWORD dwReserved
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetClipboardData ( _                          ' VTable offset = 40
     BYVAL dwReserved AS DWORD _                        ' __in DWORD dwReserved
   , BYREF ppDataObject AS IDataObject _                ' __out IDataObject **ppDataObject
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD DoVerb ( _                                    ' VTable offset = 44
     BYVAL iVerb AS LONG _                              ' __in LONG iVerb
   , BYREF lpmsg AS tagMsg _                            ' __in LPMSG lpmsg
   , BYVAL pActiveSite AS IOleClientSite _              ' __in IOleClientSite *pActiveSite
   , BYVAL lindex AS LONG _                             ' __in LONG lindex
   , BYVAL hwndParent AS DWORD _                        ' __in HWND hwndParent
   , BYREF lprcPosRect AS RECT _                        ' __in LPCRECT lprcPosRect
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD EnumVerbs ( _                                 ' VTable offset = 48
     BYREF ppEnumOleVerb AS IEnumOleVerb _              ' __out IEnumOleVerb **ppEnumOleVerb
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD Update ( _                                    ' VTable offset = 52
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD IsUpToDate ( _                                ' VTable offset = 56
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetUserClassID ( _                            ' VTable offset = 60
     BYREF pClsid AS GUID _ _                           ' __in CLSID *pClsid
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetUserType ( _                               ' VTable offset = 64
     BYVAL dwFormOfType AS DWORD _                      ' __in DWORD dwFormOfType
   , BYREF pszUserType AS DWORD _                       ' __out LPOLESTR *pszUserType
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD SetExtent ( _                                 ' VTable offset = 68
     BYVAL dwDrawAspect AS DWORD _                      ' __in DWORD dwDrawAspect
   , BYREF psizel AS SIZEL _                            ' __in SIZEL *psizel
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetExtent ( _                                 ' VTable offset = 72
     BYVAL dwDrawAspect AS DWORD _                      ' __in DWORD dwDrawAspect
   , BYREF psizel AS SIZEL _                            ' __out SIZEL *psizel
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD Advise ( _                                    ' VTable offset = 76
     BYVAL pAdvSink AS IAdviseSink _                    ' __in IAdviseSink *pAdvSink
   , BYREF pdwConnection AS DWORD _                     ' __out DWORD *pdwConnection
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD Unadvise ( _                                  ' VTable offset = 80
     BYVAL dwConnection AS DWORD _                      ' __in DWORD dwConnection
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD EnumAdvise ( _                                ' VTable offset = 84
     BYREF ppenumAdvise AS IEnumSTATDATA _              ' __out IEnumSTATDATA **ppenumAdvise
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetMiscStatus ( _                             ' VTable offset = 88
     BYVAL dwAspect AS DWORD _                          ' __in DWORD dwAspect
   , BYREF pdwStatus AS DWORD _                         ' __out DWORD *pdwStatus
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD SetColorScheme ( _                            ' VTable offset = 92
     BYREF pLogpal AS LOGPALETTE _                      ' __in LOGPALETTE *pLogpal
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================

END INTERFACE


Also, instead of including "objidl.inc", "ocidl.inc", etc., individually, you can just include "ole2.inc".

Ralph Steinkönig

#6
Hi Jose,

thank you for your time. I had done, what you say.
Error: 581 -> Type Library Creation Error, that's the newest result :(

and this ist the komplette Code:

there is no an "As Hidden" attribute


#COMPILE DLL
#DIM ALL

#COM DOC "This is my first COM-Control!"
#COM NAME "MyCOMCtrl", 1.0
#COM GUID GUID$("{FFDDA249-9EBB-440F-AA70-3AB433B600B0}")
#COM TLIB ON

#INCLUDE "Win32Api.Inc"
#INCLUDE "Objbase.Inc"
#INCLUDE "ole2.inc"
#INCLUDE "ocidl.inc"
#RESOURCE "myctl"

$CLSID_CMyCtrl = GUID$("{7B81C9BE-2C36-4427-9A8C-DEEF769C14A6}")
$IID_IMyCtrl = GUID$("{CE9112AB-AFE7-4C75-B6A1-24ED864FF3B8}")

CLASS CMyCtrl $CLSID_CMyCtrl AS COM
'private:
    INSTANCE cInfo AS ControlInfo

    CLASS METHOD CREATE
        cInfo.cb = SIZEOF(cInfo)
        cInfo.dwFlags = %CTRLINFO_EATS_RETURN
    END METHOD


'public:
    INTERFACE IMyCtrl $IID_IMyCtrl
        INHERIT IAUTOMATION
        METHOD CallMethod()
            MSGBOX "Control here!",,"MyCtrl"
        END METHOD
    END INTERFACE

    'IOleControl
    INTERFACE IOleControlImpl $IID_IOleControl
        INHERIT IUNKNOWN
        METHOD GetControlInfo (BYREF ci AS CONTROLINFO) AS LONG
           IF IsBadWritePtr(BYVAL VARPTR(ci), SIZEOF(ci)) THEN
               METHOD = %E_POINTER
               EXIT METHOD
           END IF
           TYPE SET ci = cInfo
           METHOD = %S_OK
        END METHOD
        METHOD OnMnemonic (BYREF mes AS tagMSG) AS LONG
           METHOD = %E_UNEXPECTED
        END METHOD
        METHOD OnAmbientPropertyChange (BYVAL pDisp AS LONG) AS LONG
           METHOD = %S_OK
        END METHOD
        METHOD FreezeEvents (BYVAL bFreeze AS LONG) AS LONG
           METHOD = %S_OK
        END METHOD
    END INTERFACE

    INTERFACE IOleObjectImpl $IID_IOleObject

   INHERIT IUNKNOWN

   ' =====================================================================================
   METHOD SetClientSite ( _                             ' VTable offset = 12
     BYVAL pClientSite AS IOleClientSite _              ' __in IOleClientSite *pClientSite
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetClientSite ( _                             ' VTable offset = 16
     BYREF ppClientSite AS IOleClientSite _             ' __out IOleClientSite **ppClientSite
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD SetHostNames ( _                              ' VTable offset = 20
     BYVAL szContainerApp AS DWORD _                    ' __in LPCOLESTR szContainerApp
   , BYVAL szContainerObj AS DWORD _                    ' __in LPCOLESTR szContainerObj
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD CLOSE ( _                                     ' VTable offset = 24
     BYVAL dwSaveOption AS DWORD _                      ' __in DWORD dwSaveOption
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD SetMoniker ( _                                ' VTable offset = 28
     BYVAL dwWhichMoniker AS DWORD _                    ' __in DWORD dwWhichMoniker
   , BYVAL pmk AS DWORD _                               ' __in IMoniker *pmk
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetMoniker ( _                                ' VTable offset = 32
     BYVAL dwAssign AS DWORD _                          ' __in DWORD dwAssign
   , BYVAL dwWhichMoniker AS DWORD _                    ' __in DWORD dwWhichMoniker
   , BYREF pmk AS IMoniker _                            ' __out IMoniker **pmk
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD InitFromData ( _                              ' VTable offset = 36
     BYVAL pDataObject AS IDataObject _                 ' __in IDataObject *pDataObject
   , BYVAL fCreation AS LONG _                          ' __in BOOL fCreation
   , BYVAL dwReserved AS DWORD _                        ' __in DWORD dwReserved
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetClipboardData ( _                          ' VTable offset = 40
     BYVAL dwReserved AS DWORD _                        ' __in DWORD dwReserved
   , BYREF ppDataObject AS IDataObject _                ' __out IDataObject **ppDataObject
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD DoVerb ( _                                    ' VTable offset = 44
     BYVAL iVerb AS LONG _                              ' __in LONG iVerb
   , BYREF lpmsg AS tagMsg _                            ' __in LPMSG lpmsg
   , BYVAL pActiveSite AS IOleClientSite _              ' __in IOleClientSite *pActiveSite
   , BYVAL lindex AS LONG _                             ' __in LONG lindex
   , BYVAL hwndParent AS DWORD _                        ' __in HWND hwndParent
   , BYREF lprcPosRect AS RECT _                        ' __in LPCRECT lprcPosRect
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD EnumVerbs ( _                                 ' VTable offset = 48
     BYREF ppEnumOleVerb AS IEnumOleVerb _              ' __out IEnumOleVerb **ppEnumOleVerb
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD Update ( _                                    ' VTable offset = 52
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD IsUpToDate ( _                                ' VTable offset = 56
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetUserClassID ( _                            ' VTable offset = 60
     BYREF pClsid AS GUID _ _                           ' __in CLSID *pClsid
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetUserType ( _                               ' VTable offset = 64
     BYVAL dwFormOfType AS DWORD _                      ' __in DWORD dwFormOfType
   , BYREF pszUserType AS DWORD _                       ' __out LPOLESTR *pszUserType
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD SetExtent ( _                                 ' VTable offset = 68
     BYVAL dwDrawAspect AS DWORD _                      ' __in DWORD dwDrawAspect
   , BYREF psizel AS SIZEL _                            ' __in SIZEL *psizel
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetExtent ( _                                 ' VTable offset = 72
     BYVAL dwDrawAspect AS DWORD _                      ' __in DWORD dwDrawAspect
   , BYREF psizel AS SIZEL _                            ' __out SIZEL *psizel
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD Advise ( _                                    ' VTable offset = 76
     BYVAL pAdvSink AS IAdviseSink _                    ' __in IAdviseSink *pAdvSink
   , BYREF pdwConnection AS DWORD _                     ' __out DWORD *pdwConnection
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD Unadvise ( _                                  ' VTable offset = 80
     BYVAL dwConnection AS DWORD _                      ' __in DWORD dwConnection
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD EnumAdvise ( _                                ' VTable offset = 84
     BYREF ppenumAdvise AS IEnumSTATDATA _              ' __out IEnumSTATDATA **ppenumAdvise
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetMiscStatus ( _                             ' VTable offset = 88
     BYVAL dwAspect AS DWORD _                          ' __in DWORD dwAspect
   , BYREF pdwStatus AS DWORD _                         ' __out DWORD *pdwStatus
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD SetColorScheme ( _                            ' VTable offset = 92
     BYREF pLogpal AS LOGPALETTE _                      ' __in LOGPALETTE *pLogpal
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================

END INTERFACE

END CLASS

FUNCTION DLLMAIN( BYVAL hInstance AS DWORD, BYVAL lReason AS LONG, BYVAL lReserved AS LONG ) AS LONG
   IF lReason = %DLL_PROCESS_ATTACH THEN FUNCTION = 1
END FUNCTION


since i had implemented the IOleObject Interface, i had these errors. With the IOleControl - Interface, there was no problems. This Program is an example for learning by doing.

German:

Die Fehler traten erst dann auf, als ich versuchte das IOleObject Interface zu implementieren. Vorher traten diese Fehler, selbst bei dem IOleControl - Interface nicht auf. Ich habe alle as "As Hidden" Attribute entfernt - der Fehler liegt immer noch vor. Beachte: Das auch die IOleControl eine Struktur namens: ControlInfo über Parameter veröffentlicht, was auch als As Hidden funktioniert. Und, wir wissen alle: Eine Struktur, oder Type, ist eine Klasse mit den Attributen, dass deren Member stets öffentlich sind.
                                                        

José Roca

 
Thanks for posting the code. It is the only way I can see what you are doing and find the problem and solution.

The problem is that if we use the name of an interface, such IOleClientSite, for which we have an interface definition but not an implementation, apparently PB can't create a type library. A workaround is to use the IUnknown keyword.

The following code compiles, even declaring the IOleObjectImpl interface as hidden.


#COMPILE DLL
#DIM ALL

#COM DOC "This is my first COM-Control!"
#COM NAME "MyCOMCtrl", 1.0
#COM GUID GUID$("{FFDDA249-9EBB-440F-AA70-3AB433B600B0}")
#COM TLIB ON

#INCLUDE "Win32Api.Inc"
#INCLUDE "Objbase.Inc"
#INCLUDE "ole2.inc"
#INCLUDE "ocidl.inc"
'#RESOURCE "myctl"

$CLSID_CMyCtrl = GUID$("{7B81C9BE-2C36-4427-9A8C-DEEF769C14A6}")
$IID_IMyCtrl = GUID$("{CE9112AB-AFE7-4C75-B6A1-24ED864FF3B8}")

CLASS CMyCtrl $CLSID_CMyCtrl AS COM
'private:
    INSTANCE cInfo AS ControlInfo

    CLASS METHOD CREATE
        cInfo.cb = SIZEOF(cInfo)
        cInfo.dwFlags = %CTRLINFO_EATS_RETURN
    END METHOD


'public:
    INTERFACE IMyCtrl $IID_IMyCtrl
        INHERIT IAUTOMATION
        METHOD CallMethod()
            MSGBOX "Control here!",,"MyCtrl"
        END METHOD
    END INTERFACE

    'IOleControl
    INTERFACE IOleControlImpl $IID_IOleControl
        INHERIT IUNKNOWN
        METHOD GetControlInfo (BYREF ci AS CONTROLINFO) AS LONG
           IF IsBadWritePtr(BYVAL VARPTR(ci), SIZEOF(ci)) THEN
               METHOD = %E_POINTER
               EXIT METHOD
           END IF
           TYPE SET ci = cInfo
           METHOD = %S_OK
        END METHOD
        METHOD OnMnemonic (BYREF mes AS tagMSG) AS LONG
           METHOD = %E_UNEXPECTED
        END METHOD
        METHOD OnAmbientPropertyChange (BYVAL pDisp AS LONG) AS LONG
           METHOD = %S_OK
        END METHOD
        METHOD FreezeEvents (BYVAL bFreeze AS LONG) AS LONG
           METHOD = %S_OK
        END METHOD
    END INTERFACE

   INTERFACE IOleObjectImpl $IID_IOleObject AS HIDDEN

   INHERIT IUNKNOWN

   ' =====================================================================================
   METHOD SetClientSite ( _                             ' VTable offset = 12
     BYVAL pClientSite AS IUnknown _                    ' __in IOleClientSite *pClientSite
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetClientSite ( _                             ' VTable offset = 16
     BYREF ppClientSite AS IUnknown _                   ' __out IOleClientSite **ppClientSite
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD SetHostNames ( _                              ' VTable offset = 20
     BYVAL szContainerApp AS DWORD _                    ' __in LPCOLESTR szContainerApp
   , BYVAL szContainerObj AS DWORD _                    ' __in LPCOLESTR szContainerObj
   ) AS LONG                                            ' HRESULT
   END METHOD
'   ' =====================================================================================
   METHOD CLOSE ( _                                     ' VTable offset = 24
     BYVAL dwSaveOption AS DWORD _                      ' __in DWORD dwSaveOption
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD SetMoniker ( _                                ' VTable offset = 28
     BYVAL dwWhichMoniker AS DWORD _                    ' __in DWORD dwWhichMoniker
   , BYVAL pmk AS DWORD _                               ' __in IMoniker *pmk
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetMoniker ( _                                ' VTable offset = 32
     BYVAL dwAssign AS DWORD _                          ' __in DWORD dwAssign
   , BYVAL dwWhichMoniker AS DWORD _                    ' __in DWORD dwWhichMoniker
   , BYREF pmk AS IUnknown _                            ' __out IMoniker **pmk
   ) AS LONG                                            ' HRESULT
   END METHOD
'   ' =====================================================================================
   METHOD InitFromData ( _                              ' VTable offset = 36
     BYVAL pDataObject AS IUnknown _                    ' __in IDataObject *pDataObject
   , BYVAL fCreation AS LONG _                          ' __in BOOL fCreation
   , BYVAL dwReserved AS DWORD _                        ' __in DWORD dwReserved
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetClipboardData ( _                          ' VTable offset = 40
     BYVAL dwReserved AS DWORD _                        ' __in DWORD dwReserved
   , BYREF ppDataObject AS IUnknown _                   ' __out IDataObject **ppDataObject
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD DoVerb ( _                                    ' VTable offset = 44
     BYVAL iVerb AS LONG _                              ' __in LONG iVerb
   , BYREF lpmsg AS tagMsg _                            ' __in LPMSG lpmsg
   , BYVAL pActiveSite AS IUnknown _                    ' __in IOleClientSite *pActiveSite
   , BYVAL lindex AS LONG _                             ' __in LONG lindex
   , BYVAL hwndParent AS DWORD _                        ' __in HWND hwndParent
   , BYREF lprcPosRect AS RECT _                        ' __in LPCRECT lprcPosRect
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD EnumVerbs ( _                                 ' VTable offset = 48
     BYREF ppEnumOleVerb AS IUnknown _                  ' __out IEnumOleVerb **ppEnumOleVerb
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD Update ( _                                    ' VTable offset = 52
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD IsUpToDate ( _                                ' VTable offset = 56
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetUserClassID ( _                            ' VTable offset = 60
     BYREF pClsid AS GUID _ _                           ' __in CLSID *pClsid
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetUserType ( _                               ' VTable offset = 64
     BYVAL dwFormOfType AS DWORD _                      ' __in DWORD dwFormOfType
   , BYREF pszUserType AS DWORD _                       ' __out LPOLESTR *pszUserType
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD SetExtent ( _                                 ' VTable offset = 68
     BYVAL dwDrawAspect AS DWORD _                      ' __in DWORD dwDrawAspect
   , BYREF psizel AS SIZEL _                            ' __in SIZEL *psizel
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetExtent ( _                                 ' VTable offset = 72
     BYVAL dwDrawAspect AS DWORD _                      ' __in DWORD dwDrawAspect
   , BYREF psizel AS SIZEL _                            ' __out SIZEL *psizel
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD Advise ( _                                    ' VTable offset = 76
     BYVAL pAdvSink AS IUnknown _                       ' __in IAdviseSink *pAdvSink
   , BYREF pdwConnection AS DWORD _                     ' __out DWORD *pdwConnection
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD Unadvise ( _                                  ' VTable offset = 80
     BYVAL dwConnection AS DWORD _                      ' __in DWORD dwConnection
   ) AS LONG                                            ' HRESULT
   END METHOD
'   ' =====================================================================================
   METHOD EnumAdvise ( _                                ' VTable offset = 84
     BYREF ppenumAdvise AS IUnknown _                   ' __out IEnumSTATDATA **ppenumAdvise
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD GetMiscStatus ( _                             ' VTable offset = 88
     BYVAL dwAspect AS DWORD _                          ' __in DWORD dwAspect
   , BYREF pdwStatus AS DWORD _                         ' __out DWORD *pdwStatus
   ) AS LONG                                            ' HRESULT
   END METHOD
   ' =====================================================================================
   METHOD SetColorScheme ( _                            ' VTable offset = 92
     BYREF pLogpal AS LOGPALETTE _                      ' __in LOGPALETTE *pLogpal
   ) AS LONG                                            ' HRESULT
   END METHOD
'   ' =====================================================================================

END INTERFACE

END CLASS

FUNCTION DLLMAIN( BYVAL hInstance AS DWORD, BYVAL lReason AS LONG, BYVAL lReserved AS LONG ) AS LONG
   IF lReason = %DLL_PROCESS_ATTACH THEN FUNCTION = 1
END FUNCTION


Ralph Steinkönig

#8
Jose,

that ist the solution anywhere.
Well done :)

We are working with PB not C++.
Anythinks is not equal.

IUnknown *snip* ;))) genial.
All Interfaces inherit from IUnknown - all! early all!! ... ha.

It works fein now.

thank you very much. :)