Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / August 2007



Tip: Looking for answers? Try searching our database.

Throw Exception from VB6 for C++/MFC container

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Christian Havel - 10 Aug 2007 11:12 GMT
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?

Christian
Ralph - 10 Aug 2007 13:28 GMT
> 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
Anthony Jones - 11 Aug 2007 11:06 GMT
> 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.