Help with Visual Basic ActiveX DLL showing form within Visual C++ app 
Author Message
 Help with Visual Basic ActiveX DLL showing form within Visual C++ 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:39:25 GMT  
 Help with Visual Basic ActiveX DLL showing form within Visual C++ app
Hi,
Try (in your VB code) to make the form modal:
Form1.Show vbModal

This will make sure your VB procedure returns only AFTER the form is closed.

when you do not make the form modal, it shows the form and immediately
continues on.
What probably happens is that in your C++ code, the "p" object (which is the
VB COM Class) calls the showform, the form is shown and the sub immediately
returns, and your C++ function exits - thereby destroying the "p" object.
However, "p" still has its form open!

Hope this helps,

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



Sun, 17 Aug 2003 23:08:25 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Help with Visual Basic ActiveX DLL showing form within Visual C++ ATL app

2. Hook (Sending Message from a Visual C++ App To a Visual Basic App)

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

4. adapting Visual C++ dll for Visual Basic

5. How do you call a Visual C++ (DLL) function from Visual Basic

6. Calling Visual C++ 5.0 DLL Functions From Visual Basic 5.0

7. Visual C++ DLL in Visual Basic

8. Visual Basic and Visual C++ DLL with array of structures

9. Visual C++ DLL in Visual Basic

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

11. How to write Visual C++ DLL's and call them from Visual Basic

12. Visual C++ DLL in Visual Basic

 

 
Powered by phpBB® Forum Software