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

> Sorry for the confusion.

Ah, OK.

>
> > I should also say again that I only have an IDispatch pointer to work
> > with, I want to get that existing control, not create a new instance.
>
> Then, you should replace your IDispatch pointer with my sample's pFoo,
> and call QueryInterface( ) on that pointer.

Hmmm... OK.

> You should compile with RTTI support (-GR) for dynamic_cast to work.
> And even then, you should compile all your modules (.dll and .exe) with
> this option enabled, or it will fail at runtime.

It did mention -GR somewhere along the line. I thought that with MFC, RTTI
was on by default - otherwise, how does
CObject::IsKindOf(RUNTIME_CLASS(class name) ) work? I don't have to add any
extra compiler options for that to work...

>
> Anyway, like I said, this is a very dangerous thing to do.

Why? If dynamic_cast will return NULL for something which is NOT the right
type, how can it be dangerous? Or is it dangerous because trying to cast
anything other than a genuine pointer (to another pointer type) will cause
problems? It's a bit of a lousy feature if it won't at least safely attempt
to cast ANY type to another before it starts checking. I realise the value I
get could be completely of the wrong type, but isn't that the whole point of
using this feature, to CHECK if it's the right type?

--
Jason Teagle
[EMAIL PROTECTED]

Reply via email to