Results 1 to 6 of 6

Thread: Screen Resolution problem

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Baltimore,MD
    Posts
    536

    Talking 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!

  2. #2
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Just constantly move the label to the the position you want in a timer or somthing:

    VB Code:
    1. Private Sub Timer_Timer()
    2. Label1.Move (Me.ScaleWidth - Label1.Width) / 2, (Me.ScaleHeight - Label1.Height) / 2 'this will keep it centered in the form.
    3. End Sub
    <removed by admin>

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Baltimore,MD
    Posts
    536

    Talking 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!

  4. #4
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    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.
    <removed by admin>

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Baltimore,MD
    Posts
    536

    Talking 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!

  6. #6
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    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
  •  



Click Here to Expand Forum to Full Width