I've imported a type library into Delphi XE2 that has many dispinterfaces. Most of them have had an autocreated coclass and corresponding delphi T interface automatically created.
However, some of the dispinterfaces that I need to work with have no classid; I've tried every example that I could find on the net to utilize the dispinterface(s) in question. Here's what the interface looks like:
DIID_ITableListener: TGUID = '{83D42EA5-2C18-46EB-823B-262D62DF8CF1}';
...
ITableListener = dispinterface;
...
// *********************************************************************//
// DispIntf: ITableListener
// Flags: (4096) Dispatchable
// GUID: {83D42EA5-2C18-46EB-823B-262D62DF8CF1}
// *********************************************************************//
ITableListener = dispinterface
['{83D42EA5-2C18-46EB-823B-262D62DF8CF1}']
procedure Added(const rowID: WideString; const rowDataObj: IRow); dispid 1610743809;
procedure Changed(const rowID: WideString; const rowDataObj: IRow); dispid 1610743810;
procedure Deleted(const rowID: WideString; const rowDataObj: IRow); dispid 1610743811;
procedure StatusChanged(status: TableStatus); dispid 1610743812;
end;
Here's an example from another interface in the type library wrapper that uses this dispinterface:
procedure subscribeUpdate(updateType: TableUpdateType; const listenerObj: ITableListener);
Here's a VB.NET example that is provided that explains how the dispinterface is supposed to be used:
' If you want to use methods of the ITableListener interface, you must create a
' class that+ implements the interface. For example,
public class TableListener implements ITableListener { }
' In your application you must create an instance of the class that implements
' the interface. For example,
TableListener tableListener = new TableListener();
With no ClassID how do I implement this in Delphi? How do I do an instantiation? I thought it would have something to do with implementing an IDispatch interface descendant, but again without a ClassID I couldn't find a way to make this work.
Help!
Thanks.
ITableListener
is an event sink interface, as evident by the fact that it is declared as aDIID
. You are supposed to write a class in your own code that implements that interface (you do not need a ClassID for that) and then instantiate that class and pass it to another COM object via itssubscribeUpdate()
method. That allows the COM object to then use yourITableListener
to send events to you when it needed to. - Remy Lebeau