C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 01-16-2009, 10:48 AM   #1
Registered User
 
Join Date: Mar 2005
Location: Juneda
Posts: 229
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
Niara is offline   Reply With Quote
Old 01-16-2009, 12:35 PM   #2
I have a hat!?
 
Join Date: Apr 2008
Posts: 178
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);
adeyblue is offline   Reply With Quote
Old 01-16-2009, 01:23 PM   #3
Registered User
 
Join Date: Mar 2005
Location: Juneda
Posts: 229
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
Niara is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 05:40 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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