-
Jun 30th, 2015, 01:52 AM
#1
Form2 on top of Form1
How can I make Form2 show on top of Form1 and have it stay there. I tried using top-most and that works however it also makes Form2 on top of every other Form which I don't want
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 30th, 2015, 02:09 AM
#2
Re: Form2 on top of Form1
From Form1
Code:
Private Sub Command1_Click()
Form2.Show , Me
End Sub
Remember that, in this case:
1. when you minizime Form1, Form2 also will be minimized.
2. when you close Form1, Form2 also will be close.
-
Jun 30th, 2015, 06:46 AM
#3
Re: Form2 on top of Form1
Sounds like the behaviour of a dialog to me.
Code:
Form2.Show vbModal, Me
Regards, Phill W.
-
Jun 30th, 2015, 10:03 AM
#4
Re: Form2 on top of Form1
Form2.Show vbModal, Me won't work as it blocks user's from using controls on Form1 but would be the correct way if Form2 was to be like a modal Form
Form2.Show , Me works correctly
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jun 30th, 2015, 12:47 PM
#5
Re: Form2 on top of Form1
Why not just use the Setparent API
Code:
Option Explicit
Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Command1_Click()
Form2.Show
SetParent Form2.hWnd, Me.hWnd
End Sub
If you don't know where you're going, any road will take you there...
My VB6 love-children: Vee-Hive and Vee-Launcher
-
Jun 30th, 2015, 01:12 PM
#6
Re: Form2 on top of Form1
Originally Posted by ColinE66
Why not just use the Setparent API
Code:
Option Explicit
Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Command1_Click()
Form2.Show
SetParent Form2.hWnd, Me.hWnd
End Sub
See my other Thread http://www.vbforums.com/showthread.p...=1#post4899547
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|