|
-
Oct 1st, 2012, 06:15 AM
#1
Thread Starter
PowerPoster
[RESOLVED] center a smaller form over the calling form
i am trying to center a smaller form over the calling form
like this:
code in the smaller form
Public Sub CenterMe(frm As Form)
Me.Left = frm.ScaleWidth / 2 - Me.Width / 2
Me.Top = frm.ScaleHeight / 2 - Me.Height / 2
Me.Show
End Sub
Calling it like this:
form1.CenterMe frmKeno
The smaller form is too far left and not high enough. (not centered)
what am i doing wrong ?
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Oct 1st, 2012, 06:45 AM
#2
Re: center a smaller form over the calling form
1. You are not taking into account the main form's Left & Top properties
2. Not sure why you're using width for one form and scalewidth for the other, etc.
Code:
Private Sub CenterMe(Main As Form)
Left = Main.Left + (Abs(Main.ScaleWidth - ScaleWidth)) \ 2
Top = Main.Top + (Abs(Main.ScaleHeight - ScaleHeight)) \ 2
End Sub
-
Oct 1st, 2012, 07:24 AM
#3
Thread Starter
PowerPoster
Re: center a smaller form over the calling form
thanks that fixed the issue
Not sure why you're using width for one form and scalewidth for the other, etc.
i was trying different things
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Oct 1st, 2012, 08:20 AM
#4
Re: [RESOLVED] center a smaller form over the calling form
It can also be done by setting the StartUpPosition property to "1 - CenterOwner" on the form you are trying to center and then from the other form call it using the syntax
Form2.Show , Me
No calculations required.
-
Oct 1st, 2012, 11:29 AM
#5
Thread Starter
PowerPoster
Re: [RESOLVED] center a smaller form over the calling form
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
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
|