I need to interact with an ActiveX DLL written in VB from a VC++/MFC client.
I used the wizard to generate an
MFC client application, used #import to
import
the typelibrary of the DLL - so now I've got the wrapper class & smart
pointer
generated, together with intellisense, etc. So now I can successfully call
methods and access properties exposed by the (single) interface that the
ActiveX DLL exposes. However, I am UNABLE to catch any of the events fired
by the DLL. I have followed the classic methodology of adding an ATL COM
sink class to my client application to be the event sink that IMPLEMENTS the
outgoing/event interface. I don't get any errors with the AtlAdvise()
function either.
Relevant sections from the .TLH file generated by the #import are given
below:
--- <.TLH excerpt > ---
//
// Named GUID constants initializations
//
extern "C" const GUID __declspec(selectany) LIBID_ABC =
{0x11afced7,0xefc0,0x423f,{0xba,0x9b,0xdf,0x64,0xc4,0xc6,0x95,0x90}};
extern "C" const GUID __declspec(selectany) IID__Interface =
{0xe59aeaf9,0x1fb3,0x4116,{0x96,0xb1,0xdf,0x67,0x18,0xb0,0x02,0x23}};
extern "C" const GUID __declspec(selectany) CLSID_Interface =
{0x1ba50c86,0xa653,0x4498,{0x8c,0x55,0xe0,0xbf,0x0d,0xb1,0x71,0xd3}};
extern "C" const GUID __declspec(selectany) DIID___Interface =
{0xbe5bef05,0x4e18,0x4b8b,{0x89,0x62,0xad,0x79,0x7a,0x73,0x28,0x03}};
---<< >>---
DIID___Interface is the IID of the outgoing/source/event dispinterface
__Interface whose events I need to catch.
The event interface generated in the .TLH file by #import is as follows:
struct __declspec(uuid("be5bef05-4e18-4b8b-8962-ad797a732803"))
__Interface : IDispatch
{
//
// Wrapper methods for error-handling
//
// Methods:
HRESULT Queue (
enum enumQueue EventType,
enum enumImageGroup DocumentType,
VARIANT_BOOL * Abort );
HRESULT Transfer (
enum enumTransferEvents EventType,
short CurrentImage,
short TotalImages,
VARIANT_BOOL * Abort );
Quote:
};
The 'Queue' and 'Transfer' events are what I am interested in.
What is not normal though is that the .TLI file generates the following:
---<< .TLI excerpt >> ---
//
// dispinterface __Interface wrapper method implementations
//
inline HRESULT __Interface::Queue ( enum enumQueue EventType,
enum enumImageGroup DocumentType, VARIANT_BOOL * Abort ) {
return _com_dispatch_method(this, 0x1, DISPATCH_METHOD, VT_EMPTY, NULL,
L"\x0003\x0003\x400b", EventType, DocumentType, Abort);
Quote:
}
inline HRESULT __Interface::Transfer ( enum enumTransferEvents EventType,
short CurrentImage, short TotalImages, VARIANT_BOOL * Abort ) {
return _com_dispatch_method(this, 0x2, DISPATCH_METHOD, VT_EMPTY, NULL,
L"\x0003\x0002\x0002\x400b", EventType, CurrentImage, TotalImages,
Abort);
Quote:
}
---<< >>---
In normal DLLs that implement custom interfaces, I see something like the
following INSTEAD:
//
// interface IFinishedEvent wrapper method implementations
//
inline HRESULT IFinishedEvent::Finished ( ) {
HRESULT _hr = raw_Finished();
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _hr;
i.e., NO CALL TO _com_dispatch_method(), but instead a direct call
to the corresponding raw_xxx() method that actually implements the event
handler code.
What do I need to do to make this thing work and catch the events
I'm after? HELP!!!
Any help will be greatly appreciated.
Thanks in advance,
Dom.