Calling IRichEditOle interface methods

This is a discussion on Calling IRichEditOle interface methods within the C Programming forums, part of the General Programming Boards category; Hello, I'm not able to figure out how to call a method from IRichEditOle interface. I posted in C board ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    287

    Calling IRichEditOle interface methods

    Hello, I'm not able to figure out how to call a method from IRichEditOle interface. I posted in C board instead of Windows board because I think that's a C synthax problem, but feel free to move it if necessary.

    I'm totaly lost and confused, that's the case: the IRichEditOle interface is defined as follows

    Code:
    #define INTERFACE IRichEditOle
    DECLARE_INTERFACE_(IRichEditOle, IUnknown)
    {
    	STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE;
    	STDMETHOD_(ULONG,AddRef)(THIS) PURE;
    	STDMETHOD_(ULONG,Release)(THIS) PURE;
    	STDMETHOD(GetClientSite)(THIS_ LPOLECLIENTSITE*) PURE;
    	STDMETHOD_(LONG,GetObjectCount)(THIS) PURE;
    	STDMETHOD_(LONG,GetLinkCount)(THIS) PURE;
    	STDMETHOD(GetObject)(THIS_ LONG, REOBJECT*,DWORD) PURE;
    	STDMETHOD(InsertObject)(THIS_ REOBJECT*) PURE;
    	STDMETHOD(ConvertObject)(THIS_ LONG,REFCLSID,LPCSTR) PURE;
    	STDMETHOD(ActivateAs)(THIS_ REFCLSID,REFCLSID) PURE;
    	STDMETHOD(SetHostNames)(THIS_ LPCSTR,LPCSTR) PURE;
    	STDMETHOD(SetLinkAvailable)(THIS_ LONG,BOOL) PURE;
    	STDMETHOD(SetDvaspect)(THIS_ LONG,DWORD) PURE;
    	STDMETHOD(HandsOffStorage)(THIS_ LONG) PURE;
    	STDMETHOD(SaveCompleted)(THIS_ LONG,LPSTORAGE) PURE;
    	STDMETHOD(InPlaceDeactivate)(THIS) PURE;
    	STDMETHOD(ContextSensitiveHelp)(THIS_ BOOL) PURE;
    	STDMETHOD(GetClipboardData)(THIS_ CHARRANGE*,DWORD,LPDATAOBJECT*) PURE;
    	STDMETHOD(ImportDataObject)(THIS_ LPDATAOBJECT,CLIPFORMAT,HGLOBAL) PURE;
    };
    typedef IRichEditOle *LPRICHEDITOLE;
    In some code samples I've found over the net, they say that's possible to access to every interface methods as it was a struct member. In that case I get a handle to the IRichEditOle of a richedit control with:

    Code:
    LPRICHEDITOLE lp_richedit;
    SendMessage(rich_edit_handle,EM_GETOLEINTERFACE,0,(LPARAM)&lp_richedit)
    At this point I should be able to call whatever method using:

    Code:
    lp_richedit->method(arguments);
    //to realease the interface handle I should use Release(), so:
    lp_richedit->Release();
    But the compiler ends with the next error:
    Code:
    structure has no member named 'Release'
    I have linked all the libraries for the header files used in it, but I suspect that the problem is in the call synthax. How should I do that?

    I'm using DevCpp with MingW, and the code is C compiled as C.

    Thank's in advance
    Niara

  2. #2
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    612
    You have to call them through the vtable and pass the object as the this pointer manually. Like this

    Code:
    IRichEditOle* ole = whatever;
    ole->lpVtbl->GetObjectCount(ole);

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Juneda
    Posts
    287
    Hi adeyblue, thank's for your time and help.

    That works as you said.

    I'm not sure about that, but I can remember (a little flash) that I have read here in cboard (or in a link from here) something about creating virtual functions (virtual function table) in plain C to work like C++ classes; I assume that is a sample of that. I'll have a deeper look at it.

    Thank's for the help
    Niara

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get RSSI value, send to sensor, sensor receive package, repackage it?
    By techissue2008 in forum Networking/Device Communication
    Replies: 1
    Last Post: 03-04-2009, 10:13 AM
  2. Calling other objects methods inside a constructor
    By mynickmynick in forum C++ Programming
    Replies: 5
    Last Post: 09-17-2008, 07:31 AM
  3. Calling parent methods
    By Tonto in forum C++ Programming
    Replies: 2
    Last Post: 10-24-2006, 08:00 PM
  4. calling OpenGL methods from outside the main class
    By Hector in forum Game Programming
    Replies: 2
    Last Post: 06-22-2006, 08:23 AM
  5. calling methods
    By alcoholic in forum C++ Programming
    Replies: 1
    Last Post: 01-25-2002, 11:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21