Announcement

Collapse
No announcement yet.

Undefined Type when returning an object from an Interface Method

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Thomas Tierney
    replied
    Hey Steven,

    Problem is, in order for the TypeLib to have the correct information in it I must set the Interface inheritance to IDISPATCH and the return value to IDISPATCH. If the Interface is IUNKNOWN then even with the return Value is IDISPATCH it will only return IUNKNOWN.

    And I have yet to find a TypeLib Def with

    interface IITEST : IUnknown {
    IUnknown _stdcall Save();
    };

    Leave a comment:


  • Steven Pringels 3
    replied
    Thomas,

    You can always return either IUnknown or IDispatch regardless of the
    class' heritage.

    It depends on what you're instantiating in the class itself. F.i. if you have a
    instance variable defined as IUnknown and obtain a reference from that,
    the Save method could return the IUnknown pointer to the instantiated
    variable. Same for IDispatch.

    Cheers
    Last edited by Steven Pringels 3; 4 Sep 2008, 02:43 AM.

    Leave a comment:


  • Thomas Tierney
    replied
    I Tried with IDISPATCH and it allowed me to compile but the typelib created

    interface IITEST : IUnknown {
    IUnknown _stdcall Save();
    };

    which isnt IDISPATCH. when I switch to IDISPATCH for both Inherit and the method result I get

    interface IITEST : IDispatch {
    [id(0x00000101)]
    HRESULT Save([out, retval] IDispatch** );
    };

    which is correct. So I must inherit IDISPATCH in the Interface in Order to return a dispatch object?

    Code:
    INTERFACE IITEST GUID$("{6D7C6252-F8AE-4DCD-90A9-EA97A0C0ACC6}")
            INHERIT IDISPATCH
            METHOD SAVESETTINGS ALIAS "Save"() AS IDISPATCH
            END METHOD
        END INTERFACE

    Leave a comment:


  • jcfuller
    replied
    I'm not quite sure what you are trying to do but:
    AS ITEST


    METHOD = OBJPTR(ME)

    James

    Leave a comment:


  • Steven Pringels 3
    replied
    Thomas,

    What about ... As IDispatch ?

    Cheers

    Steven

    Leave a comment:


  • Undefined Type when returning an object from an Interface Method

    Hey all,

    I am trying to return an object from a method call and cant figure out how to do it.

    If I add the statment to my class
    Code:
       INTERFACE ITEST GUID$("{6D7C6252-F8AE-4DCD-90A9-EA97A0C0ACC6}")
            INHERIT IUNKNOWN
            METHOD SAVESETTINGS ALIAS "Save"() AS OBJECT
            END METHOD
        END INTERFACE

    I get an error that OBJECT is an undefined Type. I would much prefer to do a
    AS MYNEWCLASSITEM but apparently that isnt supported.

    Any help would be appreciated.
    Thanks
Working...
X