Active X Events question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Active X Events question

Ian Oldham
I need to state up front that my COM/Active X knowledge is somewhat lacking,
especially when it comes to the terminology involved so one syllable answers
please ;-).

I ran the BeeGrid control through the ActiveX component wizard and have got
a load of BeeGrid..... subclasses under IDispatch that match the interfaces
in the control's documentation, I assume this is what's meant by "generating
the interface".

I've created a view and a presenter to hold the control which I can then
show and invoke method's on it. My problem is that when I handle an event
(in the presenter) that should pass say a RowBuffer
(BeeGridOLEDB10IsgRowBuffer exists under IDispatch) I actually get an
IDispatch object that has a typeInfo of "a
TKindInterfaceAnalyzer('IsgRowBuffer')". I don't see how I should then use
this IDispatch object in place of the BeeGridOLEDB10IsgRowBuffer that I was
expecting to receive.

Have I got the wrong end of the stick? or is there something else I need to
do?

    Thanks, Ian.


Reply | Threaded
Open this post in threaded view
|

Re: Active X Events question

Blair McGlashan
Ian

You wrote in message
news:_xE97.14438$[hidden email]...
> ...
> I ran the BeeGrid control through the ActiveX component wizard and have
got
> a load of BeeGrid..... subclasses under IDispatch that match the
interfaces
> in the control's documentation, I assume this is what's meant by
"generating
> the interface".

Yes.

> I've created a view and a presenter to hold the control which I can then
> show and invoke method's on it. My problem is that when I handle an event
> (in the presenter) that should pass say a RowBuffer
> (BeeGridOLEDB10IsgRowBuffer exists under IDispatch) I actually get an
> IDispatch object that has a typeInfo of "a
> TKindInterfaceAnalyzer('IsgRowBuffer')". I don't see how I should then use
> this IDispatch object in place of the BeeGridOLEDB10IsgRowBuffer that I
was
> expecting to receive.

Active-X event interfaces (also called "source" interfaces) are normally
implemented as dispinterfaces, i.e. as raw IDispatch, because VB had (has?)
a limitation that it could only implement IDispatch based event interface.
This is not fundamental to event interfaces, but it is almost universally
the case that they are pure dynamic dispatch (not vtbl extension with typed
methods). This means the events are received through IDispatch::Invoke(),
and so the argument types are restricted to those supported inside a
VARIANT. Cutting a long story short this means that any "interface"
arguments passed to the event handle will be of generic IDispatch type. You
can convert these to their more specialised/concrete type by sending them
#asImplType, which will attempt a down cast where possible. The system does
not do this by default because it relies on type information and is a
relatively costly thing to do should the argument not be used (there may be
no observers or the handlers may ignore the argument). You can also use
#queryInterface: to query off the interface you are expecting, which does
not rely on the availability of type information and is quicker.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: Active X Events question

Ian Oldham-3
In reply to this post by Ian Oldham
Typical isn't it... you spend ages looking at a problem, give up, ask for
help, and about 2 seconds later spot what the answer is.

You "cast" the IDispatch to the underlying type by using
IDispatch>>asImplType.


"Ian Oldham" <[hidden email]> wrote in message
news:_xE97.14438$[hidden email]...
> I need to state up front that my COM/Active X knowledge is somewhat
lacking,
> especially when it comes to the terminology involved so one syllable
answers
> please ;-).
>
> I ran the BeeGrid control through the ActiveX component wizard and have
got
> a load of BeeGrid..... subclasses under IDispatch that match the
interfaces
> in the control's documentation, I assume this is what's meant by
"generating
> the interface".
>
> I've created a view and a presenter to hold the control which I can then
> show and invoke method's on it. My problem is that when I handle an event
> (in the presenter) that should pass say a RowBuffer
> (BeeGridOLEDB10IsgRowBuffer exists under IDispatch) I actually get an
> IDispatch object that has a typeInfo of "a
> TKindInterfaceAnalyzer('IsgRowBuffer')". I don't see how I should then use
> this IDispatch object in place of the BeeGridOLEDB10IsgRowBuffer that I
was
> expecting to receive.
>
> Have I got the wrong end of the stick? or is there something else I need
to
> do?
>
>     Thanks, Ian.
>
>