MFC + ATL: throwing an error back to VB 
Author Message
 MFC + ATL: throwing an error back to VB

Hello,

Has anybody got a complete and simple example on how one can generate an
exception from VC++ 6 that will be catched by VB. I would very much

I am trying with AfxThrowOleDispatchException(0,"ERROR",0); but I catch
nothing error in VB.
I have been looking a lot in msdn, codeguru... and I could not find clear
explanation with a complete example throwing error back to VB.

My code in VC++ is straightforward :

STDMETHODIMP CRaiseErrorObj::DivideBy0()
{
 AFX_MANAGE_STATE(AfxGetStaticModuleState())

  AfxThrowOleDispatchException(0,"ERROR...",0);

 return S_FALSE;

Quote:
}

and in VB :

Sub test()
  Dim o As RaiseErrorObj
  On Error GoTo HandleError
  Set o = New RaiseErrorObj
  o.DivideBy0

  Set o = Nothing
  Exit Sub
HandleError:
  MsgBox Err.Description
End Sub

Many thanks in advance,

Michael



Mon, 09 Aug 2004 17:07:06 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Throw exception from ATL COM for both VB and VC++ client

2. ATL Call back to a VB client?

3. Throwing errors to VB client

4. Throwing error from typelib to VB

5. Throwing an Error from ATL COM controls method

6. atl vb runtime error

7. ATL and 'Rich VB Error'

8. Trouble with VB-contol in ATL/MFC-control

9. ATL COM DLL in VB IDE error...

10. propagate error from ATL to VB

11. How to send errors from ATL to VB

12. Atl Dll events stop in VB IDE after error triggered

 

 
Powered by phpBB® Forum Software