Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
We have an application where we launch a VB modal dialog from a c# form on a button click. Even though the VB dialog is a modal window we are able to go back to C# dialog on click and then the application hangs.

Looks like the VB6 form does not have a parent and hence the issue. So we decided to pass the form handle from c# to VB and make our c# dialog as a parent to the VB dialog. Any help or a sample code would be really appreciated. Thanks.
Posted
Comments
Sergey Alexandrovich Kryukov 4-Jul-15 12:51pm    
It sounds like such a technology abuse... What gives you an idea to torture yourself with VB6 if you are using C#?
—SA
Suvendu Shekhar Giri 4-Jul-15 13:02pm    
Why not just another C# dialogue ? Any specific reason for that?
Guru16 4-Jul-15 13:12pm    
Yes because the c# dialog is from our project. The VB6 project is of another group and they are yet to upgrade to c#.

1 solution

Well, one of the optional parameters of the the VB6 Form.Show method[^] was a STRING representation of the owning form. I have no idea how you're going to use this from C#, or if it's even possible.

Seriously, rewrite the stupid form in C# and save yourself all the trouble of trying to interop with VB6.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 4-Jul-15 13:20pm    
There is no a need for string representation of anything, which would also be unreliable. There is System.Windows.Window.Form.Handle which can be passed. A modal form can be called with this handle as a "parent" handle (don't mix up with System.Windows.Window.Form notion of "Parent", which is a different thing).

But it's abominate even to discuss all that. You last statement is the best statement on this whole page.

—SA
Dave Kreskowiak 4-Jul-15 14:26pm    
I know that. I was just pointing out that the VB6 form took that as a parameter.

The way I would do it is to scrap the VB6 code and rewrite in .NET.

The gun-to-my-head method would be to get the window handle of the VB6 form and try to poke in the parent window handle using Win32 functions. Then grab the gun and turn it on the person pointing it at me.
Guru16 4-Jul-15 16:30pm    
@Dave Kreskowiak. Any idea how to do that? Any link or sample? Thanks.
Dave Kreskowiak 4-Jul-15 16:39pm    
Nope. Notice the word "try" in my post.

Samples for introp with VB6? Are you kidding? VB6 is long since dead and community support for it is dying out.
Sergey Alexandrovich Kryukov 5-Jul-15 0:14am    
Do be serious. Who would want to get into all that dirt? I don't know why would you do it.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900