
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