Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-03-03
5
Medium Priority
?
800 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 2000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Make the most of your online learning experience.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Simple Linear Regression
Starting up a Project

604 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