Hi everyone. I'm encountering a roadblock with a VB6/C# integration project which I'm hoping someone will have a solution or workaround for.![]()
Basic Synopsis: I have an existing program written entirely in VB6, and I'm (unsuccessfully) trying to use the VB6 program to open a modal wizard dialog programmed in C#, but I'm unable to pass to the C# application the appropriate Win32 handle of the VB6 application (to make the VB6 program the "owner") and as such the C# program does not run in modal mode.
In my VB6 application, I call the C# application using a Shell command:
The Main() of the C# project takes in the hWnd argument and passes it on to the main form:Code:Private Sub mnuImport_Click() Shell App.Path & "\ImportWizard.exe " & Me.hWnd, vbNormalFocus End Sub
Finally, in the constructor of the main form that accepts a long value, I attempt to open the form as a modal dialog, which is where the roadblock is:Code:[ STAThread ] static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (args.Length > 0) { long hWnd = Convert.ToInt64(args[0]); Application.Run(new frmWizard(hWnd)); } else { Application.Run(new frmWizard()); } }
Basically, my problem is: the ShowDialog() method only accepts an IWin32Window object, and the only reference to the VB6 window I can give is the value passed from the hWnd property. It seems as though ShowDialog() will only accept a Win32 handle from a form which implements the IWin32Window interface, in which case I may be in trouble.Code:public frmWizard(long handle) { InitializeComponent(); this.ShowDialog(handle); //doesn't work }![]()
Any ideas/feedback would be greatly appreciated.
Thanks.![]()




Reply With Quote