> Hi,
>
[quoted text clipped - 3 lines]
>
> Christian
You can't throw an exception (well not delibrately or reliably <g>), but you
can use VB's own structured error handling to raise an Event.
-ralph
Christian Havel - 14 Aug 2007 12:08 GMT
Hi Ralph,
thanks for your help.
Christian
> > Hi,
> >
[quoted text clipped - 9 lines]
>
> -ralph
> Hi,
>
> I want to throw an exception from my VB6 ocx-control which should be handled
> by the C++ / MFC container.
> How do I do this?
Err.Raise vbObjectError Or 1001, "MyComponent", "Description of problem"
Assuming you are using a smart pointers created with _COM_SMARTPTR_TYPEDEF
macro then you can access the your component properties and methods in much
the same way as you do in VB. A _com_error will be thrown in C++ if you
raise an error in VB.
If you are accessing your component raw then all calls to your component
will be returning a HRESULT (the value of err.number) and you'll be getting
the normal return values via an out parameter. In this case to access the
extended error info such as source and description you will need to
QueryInterface your object for the IErrorInfo interface then use GetSource
and GetDescription methods.

Signature
Anthony Jones - MVP ASP/ASP.NET
Christian Havel - 14 Aug 2007 10:34 GMT
Hi Anthony,
thanks for your help! It works.
Bye
Christian
> > Hi,
> >
[quoted text clipped - 16 lines]
> QueryInterface your object for the IErrorInfo interface then use GetSource
> and GetDescription methods.