Help with Visual Basic ActiveX DLL showing form within Visual C++ ATL app 
Author Message
 Help with Visual Basic ActiveX DLL showing form within Visual C++ ATL app

I have created a Visual Basic DLL and can call methods within it
successfully from a Visual C++ app as long as none of the methods shows a
form.  Once the form is displayed I receive an UNHANDLED EXCEPTION from
Kernel32.  My VB code within the method that shows the form is simply:

    Public Sub showForm
        Load Form1
        Form1.Show
    End Sub

The code that creates the VB DLL from Visual C:

    #import "VBTest.dll" no_namespace

    void testStart()
    {
        CoInitialize(NULL);
        _IVBTestPtr p;
        p.CreateInstance(__uuidof(IVBTest));
        p->showForm;    // Kernel32 Exception Here!
    }

I really need to be able to display the VB form from my VC program and,
since this should be such a basic problem, I was hoping somebody here may be
able to enlighten me.

Thanks,
Chris



Tue, 12 Aug 2003 04:41:41 GMT  
 Help with Visual Basic ActiveX DLL showing form within Visual C++ ATL app
First you need to deal with the unhandled exception and get the real error
that is occuring.  The unhandled exception is the result of your use of
#import.  #import generates wrapper classes for the COM interfaces imported
by #import.  These wrappers use C++ exception handling and wrap their calls
in try...catch blocks.

Place your code in a try...catch block and you will be able to get the real
error that is causing your problems.

I note that you have not checked if 'p' is intitalized after calling
CreateInstance.  If the CreateInstance call failed, the subsequent call to
p->showForm() could cause a RTE.

If would definitely check p to see if it is initialize.

Brian Griffin


Quote:
> I have created a Visual Basic DLL and can call methods within it
> successfully from a Visual C++ app as long as none of the methods shows a
> form.  Once the form is displayed I receive an UNHANDLED EXCEPTION from
> Kernel32.  My VB code within the method that shows the form is simply:

>     Public Sub showForm
>         Load Form1
>         Form1.Show
>     End Sub

> The code that creates the VB DLL from Visual C:

>     #import "VBTest.dll" no_namespace

>     void testStart()
>     {
>         CoInitialize(NULL);
>         _IVBTestPtr p;
>         p.CreateInstance(__uuidof(IVBTest));
>         p->showForm;    // Kernel32 Exception Here!
>     }

> I really need to be able to display the VB form from my VC program and,
> since this should be such a basic problem, I was hoping somebody here may
be
> able to enlighten me.

> Thanks,
> Chris



Tue, 19 Aug 2003 14:39:22 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using Visual Basic ActiveX dll within C++??

2. Using a VISUAL Basic COM component from within Visual C++

3. ActiveX created in Visual C++ 6 gives problems in Visual Basic 6

4. ActiveX created in Visual C++ 6 gives problems in Visual Basic 6

5. Visual Basic <-> Visual C++ DLL Interface

6. No C++ headers and includes for ActiveX dll produced by Visual Basic

7. passing strings from a (Visual C++) DLL to Excel and Visual Basic

8. Visual C++ DLL in Visual Basic

9. Visual Basic 4.0 usage of DLLs written in Visual C++ 4.0

10. Calling a Visual Basic .DLL from Visual C++/MFC

11. Visual C++ DLL in Visual Basic

12. Visual Basic 4.0 usage of DLLs written in Visual C++ 4.0

 

 
Powered by phpBB® Forum Software