Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

interface callback class

14 views
Skip to first unread message

Adam

unread,
Jul 17, 2008, 6:31:16 PM7/17/08
to
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

0 new messages