borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (ListView)Next Topic (Activex) New Topic New Poll Post Reply
AndreaVB Forum : ActiveX : HowTo: Open a non-modal VB form (activex dll) from a C# client
Poster Message
fabiocannizzo
Level: Guest


icon HowTo: Open a non-modal VB form (activex dll) from a C# client

I am trying to open a form defined in a VB activeX DLL from a C# client in non modal way.

On the VB side I have a form (myForm) and an exposed class (myVBclass):

public function getFormHandle() as long
   getFormHandle = myForm.hWnd
end function

public sub showForm()
   myForm.show
end function

On the C# side I instantiate the ActiveX dll (converted with tlbimp), create an object of type myVBclass:

myVBclass vbClass = new myVBclass();
long hwnd = vbClass.getFormHandle();  // this works!
vbClass.showForm();  // this does not works, only modal show is allowed

In C++ there was the same problem, but you could get around that via attaching an MFC CWnd object to the HWND returned by VB, then doing Show of the CWnd object.
CWnd pWnd;
pWnd.Attach(hWnd);
pWnd.ShowWindow(SW_SHOW);

How can I do the same thing in C#?

Thanks

Regards,
Fabio

19-11-2004 at 10:29 AM
| Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: HowTo: Open a non-modal VB form (activex dll) from a C# client

Hi,
The reason the Form is being shown as Modal is 'cos an ActiveX dll is run in the same process as the calling procedure. Therefore the procedure cannot continue until you dispose of the call to the dll.
Why not make the VB side into an Out-Of-Process ActiveX exe which will run in its own thread and therefore not be modal?


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

19-11-2004 at 10:35 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : ActiveX : HowTo: Open a non-modal VB form (activex dll) from a C# client
Previous Topic (ListView)Next Topic (Activex) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder