|
-
Jul 9th, 2007, 10:16 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Form in a form
I need to have a maximized form with another form visible inside the first, it needs to be enabled, and 'on top' of the first.
I have tried by setting visible = true, enabled = true on both forms, however the maximized form is always on top thus hiding the other.
Is there any way to accomplish this.
Thank You
RT
-
Jul 9th, 2007, 10:21 PM
#2
Re: Form in a form
Look into MDI forms
-
Jul 10th, 2007, 07:42 AM
#3
Re: Form in a form
Or using the SetParent API.
-
Aug 15th, 2007, 03:07 PM
#4
Thread Starter
Addicted Member
Re: Form in a form
Or using the SetParent API.
How am I to do this?
-
Aug 15th, 2007, 06:44 PM
#5
Re: Form in a form
You could make it AlwaysOnTop, but I think Hack's SetParent suggestion is the better way to go. It's nice and easy:
Code:
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
SetParent frmChild.hWnd, frmParent.hWnd
Be sure to manually unload the child form in the parent form's unload event. (And set it to Nothing for good measure.)
-
Aug 16th, 2007, 07:23 AM
#6
Re: Form in a form
Is it a must to use the SetParent API? Because i try to stay away from it. I don't see why it is really needed with MDI forms could someone please explain?
Thanks HL
-
Aug 16th, 2007, 09:08 AM
#7
Re: Form in a form
Any particular reason you don't like the SetParent API?
-
Aug 16th, 2007, 09:29 AM
#8
Re: Form in a form
Any reason to not just set the form you want on top to OnTop?
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Aug 18th, 2007, 05:42 AM
#9
Re: Form in a form
No i stay away from it when dealing with MDI forms, thats all.
-
Aug 20th, 2007, 10:48 AM
#10
Thread Starter
Addicted Member
Re: Form in a form
You could make it AlwaysOnTop, but I think Hack's SetParent suggestion is the better way to go. It's nice and easy:
Code:
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
SetParent frmChild.hWnd, frmParent.hWnd
Be sure to manually unload the child form in the parent form's unload event. (And set it to Nothing for good measure.)
What are the variables (hWndChild, hWndNewParent) ? How do I use this function?
-
Aug 20th, 2007, 10:59 AM
#11
Re: Form in a form
 Originally Posted by Hell-Lord
Is it a must to use the SetParent API? Because i try to stay away from it. I don't see why it is really needed with MDI forms could someone please explain?
It isn't needed with an MDI project, but the OP's question did not mention MDI.
 Originally Posted by re_turner_jr
What are the variables (hWndChild, hWndNewParent) ? How do I use this function?
Those aren't functions, they are parameters. The first is the handle of the window to be moved, and the second is the handle of the window it will be moved to.
-
Aug 20th, 2007, 11:23 AM
#12
Re: Form in a form
 Originally Posted by re_turner_jr
What are the variables (hWndChild, hWndNewParent) ? How do I use this function?
They are the HWnd properties of the parent and child forms. I already gave you an example, which you quoted. Here's another:
SetParent [name of child form].hWnd, [name of parent form].hWnd
-
Aug 20th, 2007, 11:31 AM
#13
Re: Form in a form
When I've used this, I always found putting form directly into another form to look a little awarkward, so I always put the second form in a Frame on the first form.
It just looks nicer. In this case, you would use the Frame's hWnd.
-
Aug 20th, 2007, 11:44 AM
#14
Re: Form in a form
I kinda like the form within a form results because the user can then move the child form around the parent form to wherever they want. But if you need the child form to always be in the same place, then yeah, the frame idea is probably good.
Though I think there's a Moveable property you could set to False.
-
Aug 20th, 2007, 12:28 PM
#15
Re: Form in a form
Using the MDI approach is the proper way to do what you want. Using the SetParent API also creates other display issues like if you want to display the child form in a particular position then you need more APIs to position the form. Also, it will still retain its titlebar which the user can use to close the child form but that may then create a display issue or switching child forms issues. The MDI forms take care of allot of this form you.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
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
|