WinForms and COM Interop

G

Guest

I've a .NET WinForms application. The forms needs to be showed from a VB6
application. I wrote a simple class "COMWrapper" registered for COM Interop
that instances the appropriate form and show it.

The problems appeara when I show a MessageBox from the form. When I press OK
the parent form "disapper". The form has this behavior ONLY with the
ShowInTaskBar = FALSE

Any ideas?

Thanks in advance

Massimo
 
D

Dmytro Lapshyn [MVP]

Hi Massimo,

Your wrapper should require the parent VB6 app to pass the handle of its
main form to the .NET app.
Then, in the .NET app, you can use the static Form.FromHandle method to get
an instance of the Form class from the passed handle and set this instance
as the owner of the .NET form.
 
G

Guest

Sorry for the late response, but it doesn't work. Then Form.FromHandle method
returns a null reference :(

I also tried with Form.FromChildHandle but i receive the same response...


Dmytro Lapshyn said:
Hi Massimo,

Your wrapper should require the parent VB6 app to pass the handle of its
main form to the .NET app.
Then, in the .NET app, you can use the static Form.FromHandle method to get
an instance of the Form class from the passed handle and set this instance
as the owner of the .NET form.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


iacoware said:
I've a .NET WinForms application. The forms needs to be showed from a VB6
application. I wrote a simple class "COMWrapper" registered for COM
Interop
that instances the appropriate form and show it.

The problems appeara when I show a MessageBox from the form. When I press
OK
the parent form "disapper". The form has this behavior ONLY with the
ShowInTaskBar = FALSE

Any ideas?

Thanks in advance

Massimo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top