Results 1 to 4 of 4

Thread: VB.NET : Me.Width= Screen.Allscreen(0).Bound.Width give wrong result.

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2017
    Posts
    45

    VB.NET : Me.Width= Screen.Allscreen(0).Bound.Width give wrong result.

    Hi All,

    Code:
    Private Sub Form1_Resize(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Me.Resize
            On Error Resume Next
            If Me.WindowState = 1 Then Exit Sub ' if minimized do not set width and height
            If Me.WindowState = 2 Then Exit Sub ' if maximized do not set width and height
            If testScaling = 0 Then
                testScaling = 1
            End If
            Me.Width = (Screen.AllScreens(0).Bounds.Width / testScaling)
            Me.Height = (Screen.AllScreens(0).Bounds.Height / testScaling)
    End Sub
    in this Me.Height give wright result but Me.Width give multiple of two monitor width so application streched in both monitor.


    under form_load


    we have written

    Code:
    Dim myScreens() As Screen = Screen.AllScreens
            Dim tempitem As Screen
            For Each tempitem In myScreens
                If tempitem.Primary = True Then
                    mainscreen = tempitem
                End If
            Next
           Me.Width = myScreens(0).Bounds.Width
           Me.height= myScreen(0).Bounds.Height
    could you please help me to solve this issue.

    I maked my application as screen saver in window. Once window satrt it start my screen saver and in that case my application look strech because of Me.Width taking double of original value.


    Kindly help me to resolve this issue. I tried several way but it is not working

  2. #2

    Thread Starter
    Member
    Join Date
    Jun 2017
    Posts
    45

    Re: VB.NET : Me.Width= Screen.Allscreen(0).Bound.Width give wrong result.

    My screen resolution is width=1920, Height=1080

    But it showing Me.width=3840 and Me.Height= 1080

  3. #3
    New Member
    Join Date
    Aug 2017
    Posts
    3

    Re: VB.NET : Me.Width= Screen.Allscreen(0).Bound.Width give wrong result.

    I tested this Code and it was working. can You Show Your Full Code?

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2017
    Posts
    45

    Re: VB.NET : Me.Width= Screen.Allscreen(0).Bound.Width give wrong result.

    Thanks you so much ,i did mistake,it is working fine

Tags for this Thread

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