|
-
Feb 16th, 2002, 01:06 AM
#1
Thread Starter
Fanatic Member
Screen Resolution problem
This is the problem I have come across. Lets say I create a form and I place a label in the center of the form. Now if I change the screen resolution to a bigger size the label is no longer in the middle of the screen it is in the bottom right. I want to know if anyone has a code so that I can have my label placed in the center or any other position on the form I want regardless of the screen resolution. Therefore, if I placed the label at the top of the form no matter what screen resolution is used the label stays at the top of the form, if anyone knows a code or procedure to accomplish this please inform thanks god bless!
Walter Richardson
Striver2000 Christian Productions
Iam seventeen but since I started VB in June of 01 GOD has been helping me excell by finding this great forum with a bunch of GREAT PEOPLE!
-
Feb 16th, 2002, 01:17 AM
#2
PowerPoster
Just constantly move the label to the the position you want in a timer or somthing:
VB Code:
Private Sub Timer_Timer()
Label1.Move (Me.ScaleWidth - Label1.Width) / 2, (Me.ScaleHeight - Label1.Height) / 2 'this will keep it centered in the form.
End Sub
-
Feb 16th, 2002, 01:51 AM
#3
Thread Starter
Fanatic Member
MidgetsBro
Can I put that code in the form load declarations and will it keep the position on the form when I use the code no mater what position I put the label
Walter Richardson
Striver2000 Christian Productions
Iam seventeen but since I started VB in June of 01 GOD has been helping me excell by finding this great forum with a bunch of GREAT PEOPLE!
-
Feb 16th, 2002, 02:00 AM
#4
PowerPoster
If you want it always in the middle, it will have to be in a timer, or a loop. If you put it in the form load, it will move it there at the beginning, but if you change the size, it will not move. You can also put this code in the Resize event of the form, so that when the form get's resized, it will move the label. Just make sure to add If Me.WindowState <> vbMinimized before the label.move statement, or else you will get an error when you minimize the application.
-
Feb 16th, 2002, 02:06 AM
#5
Thread Starter
Fanatic Member
question
so what interval should I use for the the timer.also will this code work if I place the labet at the bottom of the form and I want it to stay at the bottom regardless of the screen resolution
Walter Richardson
Striver2000 Christian Productions
Iam seventeen but since I started VB in June of 01 GOD has been helping me excell by finding this great forum with a bunch of GREAT PEOPLE!
-
Feb 16th, 2002, 02:15 AM
#6
Fanatic Member
instead of using the timer control, write the code in form load event and form resize event.
visual basic code:--------------------------------------------------------------------------------Private Sub Timer_Timer()
Label1.Move (Me.ScaleWidth - Label1.Width) / 2, (Me.ScaleHeight - Label1.Height) / 2 'this will keep it centered in the form.
End Sub
--------------------------------------------------------------------------------
regards,
prakash
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
|