Results 1 to 6 of 6

Thread: Resolution

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Question

    Does someone have code that makes a program's controls display correctly to fit the resolution of the computer that it's running on?

    Thx.

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    yes, this should do it, however, it's a little buggy.
    Code:
    Private ResHeight As Integer
    Private ResWidth As Integer
    Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    
    Private Const SM_CXSCREEN = 0
    Private Const SM_CYSCREEN = 1
    Private Const Design_Width = 800 'set to Width Res of Design Enviroment
    Private Const Design_Height = 600 ' set to Height res of Design Enviroment
    
    
    Private Sub GetScreenResolution()
    Dim lTemp As String
    ' Temporary string to hold returned screen
    ' resolution
    ResWidth = GetSystemMetrics(SM_CXSCREEN)
    ResHeight = GetSystemMetrics(SM_CYSCREEN)
    ' Call the API function twice to return
    ' screen size for each axis as format into
    ' the temporary string
    End Sub
    
    Private Sub ResizeAll()
    GetScreenResolution
    On Error Resume Next
    Dim WidthProp As Double
    Dim HeightProp As Double
    
    Dim frm As Form
    
    WidthProp = ResWidth / Design_Width
    
    HeightProp = ResHeight / Design_Height
    
    Dim Ctrl As Control
    
    For Each frm In VB.Forms
        For Each Ctrl In frm.Controls
        If TypeOf Ctrl Is Label Then
           Ctrl.FontSize = Ctrl.FontSize * HeightProp
        End If
        If TypeOf Ctrl Is Image Then Ctrl.Stretch = True
            Ctrl.Height = Ctrl.Height * HeightProp
            Ctrl.Top = Ctrl.Top * HeightProp
            Ctrl.Left = Ctrl.Left * WidthProp
            Ctrl.Width = Ctrl.Width * WidthProp
            DoEvents
        End if
        Next
    Next
    End Sub
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    email me if you want a dll to do the job.

    Wayne
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Thanks, guys

    I'll give gwdash's code a try (although I see that I'll need to alter it a bit because it only accounts for Labels and Images).

    If I have problems, I'll send you an email HeSaidJoe.

    Thx.

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    No problem..I have it a class module as well if you don't want the dll...I just find the dll is cleaner..with no messing around.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Problem not solved.

    Thanks for reading.

    Gwdash's code is incomplete and buggy (by his own admission) and HeSaidJoe didn't send me the dll after I emailed him. I said all that to say, will someone please post the code to make a program's controls display correctly to fit the resolution of the computer that it's running on?

    Thanks.

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