|
-
Mar 22nd, 2008, 08:29 PM
#1
Thread Starter
New Member
Using frame to link another form
hey everyone.
I've been searching around for help but wansn't able to find anything, so i decided to make an account here and ask for help.
So uhm, while searching i found similar topics but nothing i was looking for, what i would like to do is link, for example, "Form 2" inside the "form1", Using something like a frame (like frontpage in poor words).
So yeah, if for example i'd have that form 1 and would like to open the form 2 inside the form 1 in the center, i need a code for this.
I was thinking to make the form2.show and then set the position in the center of form 1, but then if i'd move it the form 2 wouldn't move as well, so i'm looking for a code that opens Form 2 inside the Form 1 (but that doesn't delete Form 1 content, just open the form2 in a setted position).
-
Mar 22nd, 2008, 09:50 PM
#2
Re: Using frame to link another form
Are you sure you do not want to use MDI forms?
Placing another vb form inside of a frame or another container can be done pretty easily... The only difficult thing is positioning it inside the new container. VB Frames are always scalemode of Twips, so in the code below, I am placing the form 3 pixels from left edge & 15 pixels from top edge.
Add 2 forms to your project. On Form1 add 1 command button & 1 frame. Make Form2 (the one that will be hosted) borderstyle = zero. Then run the project
Code:
Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Command1_Click()
SetParent Form2.hWnd, Frame1.hWnd
Form2.Move Screen.TwipsPerPixelX * 3, Screen.TwipsPerPixelY * 15
Form2.Show
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unload Form2 ' gotta do this else project will not close properly
End Sub
-
Mar 23rd, 2008, 06:22 AM
#3
Thread Starter
New Member
Re: Using frame to link another form
Thanks for your time =).
That helped me A lot, thanks very much!
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
|