interface callback class


2008-07-18 06:31:16 AM
cppbuilder20
I am trying to create a class to implement callback event handlers.
From the Help file:
"...you will receive "pushed" callbacks to these methods"
From the imported type library:
//
*********************************************************************//
// Interface: IMbtQuotesNotify
// Flags: (256) OleAutomation
// GUID: {C8323838-B094-4E3C-B9BE-D08B5C06E6BE}
//
*********************************************************************//
interface IMbtQuotesNotify : public IUnknown
{
public:
// [-1] Direct event called when level one data has arrived for a
symbol.
virtual HRESULT STDMETHODCALLTYPE OnQuoteData( QUOTERECORD* pRec) =
0;
// [-1] Direct event called when level two data has arrived for a
symbol.
virtual HRESULT STDMETHODCALLTYPE OnLevel2Data( LEVEL2RECORD* pRec)
= 0;
// [-1] Direct event called when time and sales data has arrived for
a symbol.
virtual HRESULT STDMETHODCALLTYPE OnTSData( TSRECORD* pRec) = 0;
// [-1] Direct event called when options data has arrived for a
symbol.
virtual HRESULT STDMETHODCALLTYPE OnOptionsData( OPTIONSRECORD*
pRec) = 0;
};
//My attempted implementation:
//BCB5 doesn't allow
//class TMbtQuoteNotify : public TInterfacedObject , IMbtQuotesNotify
class TMbtQuoteNotify : public IMbtQuotesNotify
{
public:
HRESULT __stdcall QueryInterface(const GUID& IID, void **Obj);
ULONG __stdcall AddRef();
ULONG __stdcall Release();
HRESULT STDMETHODCALLTYPE OnQuoteData( QUOTERECORD* pRec );
HRESULT STDMETHODCALLTYPE OnLevel2Data( LEVEL2RECORD* pRec );
HRESULT STDMETHODCALLTYPE OnTSData( TSRECORD* pRec );
HRESULT STDMETHODCALLTYPE OnOptionsData( OPTIONSRECORD* pRec );
};
//example from source
HRESULT __stdcall TMbtQuoteNotify::QueryInterface( const GUID& IID,
void **Obj )
{
//return TInterfacedObject::QueryInterface(IID, (void *)Obj);
//no BCB5
return IMbtQuotesNotify::QueryInterface( IID, Obj );
}
The class will be assigned to a IMbtQuoteNotify pointer.
1) Can anyone furnish some example code to instruct me where I'm going
wrong?
2) How to create an instance of this class?
IMbtQuotesNotify pMbtQuotesNotify;
A Delphi example: pMbtQuotesNotify := TMbtQuoteNotify.Create but what
is the
correct method for BCB5?
3) How do I connect this class to receive events? Would I
QueryInterface pMbtQuotesNotify?
Thanks for any help.
Adam