dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Change the Screen Resulation

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Change the Screen Resulation

    [Originally posted by Mohammad Farooq]

    Hello,
    How can i adjust the Screen Resulotion through VB to 800x600 by pressing a Command Button

    Thanks
    Farooq

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Change the Screen Resulation

    [Originally posted by Mike Lyons]

    You need to use some API code.

    For what it's worth, I never change the resolution through my software. It's generally considered bad manners for a program to change the user's screen resolution.

    The only exceptions are if you are creating a utility where this is a function the user would actually want to perform, or if you are creating some sort of game that truly requires that resolution. Keep in mind that if your application crashes before restoring the original resolution, the user will have to manually fix this up while cursing your name and product.

    Otherwise, leave it alone and instead write your forms to automatically scale to whatever resolution the user has.

    Mike

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Change the Screen Resulation

    [Originally posted by Mohammad Farooq]

    Thanks Mike

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Change the Screen Resulation

    [Originally posted by Mikekay2]

    I use the following code to rescale forms (if anyone has a better way can they let me know)

    in form load

    Dim TORESIZE as object

    For Each TORESIZE In Me
    If Not Rescale(TORESIZE) Then
    End If
    Next

    Public Function Rescale(Obj As Object) As Boolean

    On Local Error Resume Next
    Rescale = False

    With Obj

    .Stretch = True
    .ClipControls = False
    ' 9000 is size for resolution I developed in
    .Height = (.Height * Screen.Height) / 9000
    .Top = (.Top * Screen.Height) / 9000
    .Y1 = (.Y1 * Screen.Height) / 9000
    .Y2 = (.Y2 * Screen.Height) / 9000
    .ScaleHeight = (.ScaleHeight * Screen.Height) / 9000
    ' 12000 is size for resolution I developed in
    .Width = (.Width * Screen.Width) / 12000
    .Left = (.Left * Screen.Width) / 12000
    If (.Font.Size * Screen.Height) / 9000 < (.Font.Size * Screen.Width) / 12000 Then
    .Font.Size = (.Font.Size * Screen.Height) / 9000
    Else
    .Font.Size = (.Font.Size * Screen.Width) / 12000
    End If
    'some fonts look odd in large sizes
    If .Font.Size > 14 Then
    .Font.Name = "Arial"
    End If
    .X1 = (.X1 * Screen.Width) / 12000
    .X2 = (.X2 * Screen.Width) / 12000
    .ScaleWidth = (.ScaleWidth * Screen.Width) / 12000

    End With

    Rescale = True

    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center