Solved

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

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
advertisement module in core php 4 81
Duplicate a row 2 29
Code enhancement 5 12
Spacing between controls 4 16
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.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
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 …

708 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

14 Experts available now in Live!

Get 1:1 Help Now