|
-
Dec 10th, 2006, 10:14 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Center screen - stupid problem
Hi All.
I have the monitor of LCD. So when I will use this following code then my form is not on a screen centrally but in a bottom of the right corner of my screen.
VB Code:
Option Explicit
Private Sub CenterForm(pobjForm As Form)
With pobjForm
.Top = (Screen.Height) / 2
.Left = (Screen.Width) / 2
End With
End Sub
Private Sub Form_Load()
CenterForm Me
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Me.Top = (Screen.Height) / 2 ' here the same
' Me.Left = (Screen.Width) / 2
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
How to make it correctly? Thanks in advance
I know, I know, my English is bad, sorry .....
-
Dec 10th, 2006, 10:18 AM
#2
Re: Center screen - stupid problem
Set .StartUpPosition to 2 - CenterScreen at design time.
Or:
VB Code:
'...
.Top = (Screen.Height - pobjForm.Height) / 2
.Left = (Screen.Width - pobjForm.Width) / 2
'...
Last edited by gavio; Dec 10th, 2006 at 11:24 AM.
-
Dec 10th, 2006, 10:21 AM
#3
Re: Center screen - stupid problem
try:
VB Code:
obj.Top = (Screen.Height / 2) - (obj.Height / 2)
obj.Left = (Screen.Width / 2) - (obj.Width / 2)
-
Dec 10th, 2006, 11:08 AM
#4
Re: Center screen - stupid problem
... and finally:
VB Code:
Form1.Move (Screen.Width - Form1.Width) / 2, (Screen.Height - Form1.Height) / 2
-
Dec 10th, 2006, 11:09 AM
#5
Re: Center screen - stupid problem
@gavio: you need to use form's full size and NOT scale size.
-
Dec 10th, 2006, 11:17 AM
#6
Re: Center screen - stupid problem
 Originally Posted by RhinoBull
... and finally:
VB Code:
Form1.Move (Screen.Width - Form1.Width) / 2, (Screen.Height - Form1.Height) / 2
Whenever precision is not a concern (as in this case), we should use \ instead of /. This makes our programs a bit faster.
VB Code:
Form1.Move (Screen.Width - Form1.Width) \ 2, (Screen.Height - Form1.Height) \ 2
Pradeep
-
Dec 10th, 2006, 11:20 AM
#7
Re: Center screen - stupid problem
 Originally Posted by Pradeep1210
Whenever precision is not a concern (as in this case), we should use \ instead of /.
That's irrelevant, Pradeep - position/size are Integers anyway...
-
Dec 10th, 2006, 11:25 AM
#8
Re: Center screen - stupid problem
 Originally Posted by RhinoBull
@gavio: you need to use form's full size and NOT scale size.
Edited my post
-
Dec 10th, 2006, 11:40 AM
#9
Re: Center screen - stupid problem
 Originally Posted by RhinoBull
That's irrelevant, Pradeep - position/size are Integers anyway... 
That's why we should use \ instead of using / as the result would be same, but fast.
I read somewhere that \ is the fastest and / the slowest in terms of arithmetic operators.
Pradeep
-
Dec 10th, 2006, 11:56 AM
#10
Re: Center screen - stupid problem
 Originally Posted by Pradeep1210
I read somewhere that \ is the fastest and / the slowest in terms of arithmetic operators. 
If it is then it could be by 1/1000th of a nanosecond... so please...
-
Dec 10th, 2006, 12:06 PM
#11
Re: Center screen - stupid problem
 Originally Posted by RhinoBull
If it is then it could be by 1/1000th of a nanosecond... so please...
Actually I never meant how much we would gain or loose.
I just meant that we should improve our programming habits. Most programmers tend to use the / everytime, whether they are dealing with precision digits or not.
As a rule we should always consider \ instead of / unless precision is a big concern to us.
Remember a bucket fills drop by drop 
Pradeep
Last edited by Pradeep1210; Dec 10th, 2006 at 12:25 PM.
-
Dec 10th, 2006, 12:09 PM
#12
Thread Starter
Hyperactive Member
-
Dec 10th, 2006, 12:13 PM
#13
Re: Center screen - stupid problem
 Originally Posted by Pradeep1210
...I just meant that we should improve our programming habits...
So how is it an improvement?
-
Dec 10th, 2006, 12:22 PM
#14
Re: [RESOLVED] Center screen - stupid problem
Ohh.. sorry. They tend to use / everytime instead of \.
Pradeep 
Edited and corrected the post.
Last edited by Pradeep1210; Dec 10th, 2006 at 12:26 PM.
-
Dec 10th, 2006, 12:26 PM
#15
Re: [RESOLVED] Center screen - stupid problem
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
|