Solved

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

Posted on 2011-03-03
5
773 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 86

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 86

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…

730 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