Title: RE: [msvc] Automation, IDispatch, Class Explosing The Interface

> BTW, my previous answer will still work in this context as well,
> if there is
> a need to hit internal stuff. The call itself is safe even with
> the spoofing
> since it's marked local, provided you cast it properly (I recommend using
> reinterpret_cast).

Talking of casting, during my experimentation I wanted to try and use
dynamic_cast for the first time ever, because I wanted to guarantee that if
the memory image pointed to by the pointer was not of the intended class,
then it would return NULL.

Now, since I'm in an automation environment I had the pointer to the object
cast to a long (the only way I could get it across the COM interface - I
tried using a (short *) for a buffer pointer elsewhere and for some reason
VB thought it was just a short (not a pointer) and refused to compile).

So I have a long which is actually a pointer to my class. Under normal
circumstances I would have done this:

CMyControl *pControl = (CMyControl *)lControlPointer ;

But to try and use dynamic_cast, I did this:

CMyControl *pControl = dynamic_cast<CMyControl *>(lControlPointer);

But it refused to compile, waffling on about void * is not a valid type or
something equally meaningless to me.

What did I do wrong? Did I misunderstand? I'm sure I saw somewhere that one
of these xxx_cast<type>(value) things returns NULL for an invalid cast...

--
Jason Teagle
[EMAIL PROTECTED]

Reply via email to