Solved

How to have a VB.Net Form always above a VB6 Form, but not topmost

Posted on 2011-03-03
5
757 Views
Last Modified: 2013-11-27
Question: are there any api’s (or equivalent) which allow a VB.Net Form to be placed always above a VB6 MDI form, but not topmost?

I have a VB6 software program which is integrated with Visual Studio Tools for Applications (VSTA).  VSTA allows access to the host’s (VB6) object model, and is Microsoft’s replacement for Visual Basic for Applications (VBA).

I would like the end user to be able to create custom forms within VSTA using VB.Net, and make the VB6 MDI form and the VSTA forms appear as a single form.  Basically, the new VB.Net forms would need to always be above the VB6 MDI form, but not topmost.  

Currently, I set the VB.Net forms to always on top, but this is not the best solution because the user may need to open additional software.  Also, to make it appear as a single form, I use the same color and eliminate the border and caption, thus the end user can not tell that he is using forms on more than one program.

In summary, what code should be run when first opening the VB.Net form so that it is always above the VB6 MDI form.  If needed, I can obtain the VB6 form's hwnd.

Your help would be greatly appreciated.
0
Comment
Question by:Leaping-Dog
  • 3
  • 2
5 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35033777
Use the SetParent() API to make the VB.Net form a child of the VB6 form:
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_26533276.html
0
 

Author Comment

by:Leaping-Dog
ID: 35034014
Thanks for the reply Idle Mind.

Your solution is similar to what I am looking for but not quite the same.

My host is a VB6 MDI form, and then this VB6 program opens a VB.Net form (using VSTA).  Thus, I need the VB.Net form to be a child of the VB6 host MDI form, and always be above the VB6 MDI form.

I need to place the API commands that will do this within the VB.NET child form - if at all possible.

0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 35034027
You said:

If needed, I can obtain the VB6 form's hwnd.

So in the VB.Net child form you call the SetParent() API and pass the VB.Net handle as the first parameter and the VB6 hwnd as the second paramter:

    ' in the VB.net child form:
    SetParent(Me.Handle, VB6_Form_hWnd_Here)

In the example I use SetWindowPos() afterwards to move it to a good position within the external window.
0
 

Author Comment

by:Leaping-Dog
ID: 35034408
Your second solution was dead on.  

Please let me express my deep gratitude for your excellent help on this problem.  You can't believe how much this small enhancement will improve our software.

Thanks again.

Dog.
0
 

Author Closing Comment

by:Leaping-Dog
ID: 35034412
Just great!!!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now