Solved

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

Posted on 2011-03-03
5
779 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
A short article about problems I had with the new location API and permissions in Marshmallow
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

729 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