Results 1 to 3 of 3

Thread: Screen Resolution

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2001
    Location
    Richmond, VA
    Posts
    59
    Can someone explain how to adjust my application so that regardless of what screen resolution a user is using my application will fit correctly.

  2. #2
    Hyperactive Member
    Join Date
    Dec 2000
    Location
    Denver
    Posts
    265

    depends on your needs..

    It depends on your needs when you say you want your application to fit. If you just want the window to fit the entire screen you can use

    Me.WindowState = vbMaximized

    If you're talking about resizing controls on a form you would need to create a module with a resize sub or function. Something like this:

    Code:
    Function resize(formname As Form)
    Dim resizeamt As Single
    dim swidth as single
    
    'get the screen resolution
    swidth = Screen.Width \ screen.TwipsPerPixelX
    
    'I just guessed at these values...you'd have to test them
    Select Case swidth
    Case 800
        resizeamt = 1
        myfontsize = 9
    Case 960
        resizeamt = 1.3
        myfontsize = 12
    Case 1024
        resizeamt = 1.3
        myfontsize = 12
    Case 1152
        resizeamt = 1.4
        myfontsize = 13
    Case 1280
        resizeamt = 1.4
        myfontsize = 13
    Case 1600
        resizeamt = 1.6
        myfontsize = 14
    Case Else
        'assume 800x600 for any other resolutions
        resizeamt = 1
        myfontsize = 9
    End Select
    
    'check each control on the form
    For i = 0 To formname.Count - 1
        
    If TypeOf formname.controls(i) Is TextBox Then
            formname.controls(i).Height = formname.controls(i).Height * resizeamt
            formname.controls(i).width = formname.controls(i).Width * resizeamt 'optional to change width
    
    ElseIf TypeOf formname.controls(i) Is ComboBox Then
            'you can't use .height with comboboxes, but fontsize will work
            formname.controls(i).FontSize = myfontsize  
    
    ElseIf TypeOf formname.controls(i) Is ListBox Then
           formname.controls(i).Width = formname.controls(i).Width * resizeamt 'optional to change width
            formname.controls(i).Height =  formname.controls(i).height * resizeamt
        End If
        
    Next
    
    
    End Function
    hope this helps a bit

    ~Acoustic

  3. #3
    Addicted Member CoMMiE's Avatar
    Join Date
    Jul 2000
    Location
    Malaysia, Kuala Lumpur
    Posts
    179
    Hi FMCAR10
    Try this artical in vbworld
    http://www.vb-world.net/tips/tip489.html

    There is one problem with the code thought, it doesnt work well with tabstrip

    Does anyone here has a solution for that?

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