|
-
Aug 14th, 2000, 10:46 AM
#1
Thread Starter
Fanatic Member
Hi.
I have a project with a MDI parent and children forms. I want each child form to be displayed in the upper left-hand corner of the Parent form when it is activated. However, I can't figure out how to do this. The forms are displayed at various places on the parent form when they are loaded.
Anyone have any ideas on how to change this?
Thanks.
-
Aug 14th, 2000, 10:51 AM
#2
Member
On the properties of the child form, set the Top and Left properties to '0' and the Startup-Position property to '0-Manual'
Tim
VB6, SP4
GT Vengeance
-
Aug 14th, 2000, 10:51 AM
#3
In the Form_Load event of the child form just add:
Good luck!
-
Aug 14th, 2000, 11:26 AM
#4
Thread Starter
Fanatic Member
Thx.
for the replies Tim and Joacim.
FYI, Tim, your advice didn't work for some reason, but Joacim's did.
All the best.
-
Aug 14th, 2000, 11:28 AM
#5
TimC's method works fine.
Code:
Private Sub Form_Load()
Me.Left = 0
Me.Top = 0
End Sub
-
Aug 14th, 2000, 11:33 AM
#6
Thread Starter
Fanatic Member
Maybe...
TimC's method didn't work for me because I changed the properties at design-time rather than run-time? Either way, I accomplished my objective.
-
Aug 14th, 2000, 12:25 PM
#7
Member
Question. When I design a program, and I position the forms using the little property window, so that they appear where I want them to, isn't that Design-Time. And when I use code to have them move while the program is running, isn't that Run-Time? Or am I using the wrong definitions. I am new to this, and if I would like to know if I am not thinking about this correctly.
Tim
VB6, SP4
GT Vengeance
-
Aug 14th, 2000, 05:32 PM
#8
Thread Starter
Fanatic Member
Hi TimC,
Question. When I design a program, and I position the forms using the little property window, so that they appear where I want them to, isn't that Design-Time. And when I use code to have them move while the program is running, isn't that Run-Time?
Your understanding of design-time and run-time are correct. My problem was that, for some reason, when my program executed, the forms didn't appear where I placed them in the Form Layout window. Thus, I had to position them in code.
All the best.
-
Aug 15th, 2000, 06:41 AM
#9
The reason you can't assign the form positon during design time is because a MDI form always position child forms in a cascading fashion by default. It also changing the size of the child forms.
-
Aug 15th, 2000, 07:37 AM
#10
Thread Starter
Fanatic Member
Oh...Thanks for the explanation Joacim.
-
Aug 15th, 2000, 08:08 AM
#11
Member
I was looking over some code from projects and I do also set my child forms position run-time:
Me.Left = 0
Me.top = 0
Or to whatever position I want them. I do remember having some trouble positioning them. I do believe you can stop them from being resized by changing the border property. I was having trouble with that, and that did stop that from happening. Although I believe I am getting off topic....
Tim
VB6, SP4
GT Vengeance
-
Aug 15th, 2000, 10:17 AM
#12
New Member
This is a helpful topic for me, but, how can I set the postion of a form at start up, relative to the position of the "parent" form, whatever that may be?
Regards
Steve
-
Aug 15th, 2000, 11:46 AM
#13
Thread Starter
Fanatic Member
Relativity....
Hi Steve,
I don't know much about working with MDI Forms (I started this post, remember ), but this should accomplish what you're looking for.
Code:
Private Sub MDIForm_Load()
MDIForm1.Move 0, 0
Load Form1
End Sub
Private Sub Form_Load()
Form1.Move 0, 0
Form1.Left = MDIForm1.Left + 100
Form1.Top = MDIForm1.Top + 100
End Sub
I played around with it a little and the Move statements were helpful in making sure that everything fell into place.
I hope this helps.
-
Aug 15th, 2000, 12:11 PM
#14
Actually what the Move method is doing is setting the Left, Top, Width and Height properties (if you pass all optional arguments).
So a statement like this:
Is equal to:
Code:
Me.Left = 0
Me.Top = 0
An other exemple:
Code:
Me.Move 0, 0, frmMdi.ScaleWidth, frmMdi.ScaleHeight
Is equal to:
Code:
Me.Left = 0
Me.Top = 0
Me.Width = frmMdi.ScaleWidth
Me.Height = frmMdi.ScaleHeight
-
Aug 16th, 2000, 04:45 AM
#15
New Member
Thanks for your help
I've now got the form doing exactly what I want. I've also found that you can use the screen object to position the forms so they never go off the edge of the screen. This is useful if a form is modal when its loaded, because you want it to be accessible.
eg:
If Me.Left > Screen.Width - Me.Width Then
Me.Left = Screen.Width - Me.Width
End If
Regards
Steve
-
Aug 16th, 2000, 07:24 AM
#16
New Member
ME.Move = 0,0 or Me.top =0
Me.left=0
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
|