Results 1 to 8 of 8

Thread: Resize Form & Controls For Screen Size - VB6

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2011
    Posts
    81

    Resize Form & Controls For Screen Size - VB6

    Hi

    I´m trying to follow this tutorial:


    http://www.dreamincode.net/forums/to...reen-size-vb6/

    In his tutorial he says:

    "That's all the code you need for your form and control resizing based on the users screen resolution. It's all a matter of getting the mathematics right, then resetting the size of everything on the form to fit nicely in the current screen.

    Now for how to use it, in the Form_Load Event you add a call to:

    •GetLocation

    •ResizeForm
    "

    I´have tried

    Call GetLocation
    Call ResizeForm

    Then I get Argument not optionall. Has anyone followed this tutorial? What am I doing wrong? Does anyone know of another module to resize forms and controls to fit smaller screens. Í´m trying to avoid using ocx - but not outof cost 59$ but to avoid any installations on the users machine.

    All help appreciated,
    Keli

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,143

    Re: Resize Form & Controls For Screen Size - VB6

    Create a new project.
    On your form1 add a commandbutton, a textbox and a label (just leave them as default values)

    Put this in your formLoad routine:
    GetLocation Me
    CenterForm Me
    ResizeForm Me

    Put this in your form1's resize routine:
    ResizeControls Me

    Download and save the mdoule in the example's zip file (unzip it somewhere). Add that module in the IDE to your project.
    Run your project....try resizing your form and watch the controls resize as well.

  3. #3
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Resize Form & Controls For Screen Size - VB6

    Argument not optional (Error 449)

    The number and types of arguments must match those expected. This error has the following causes and solutions:

    • Incorrect number of arguments.
      Supply all necessary arguments. For example, the Left function requires two arguments; the first representing the character string being operated on, and the second representing the number of characters to return from the left side of the string. Because neither argument is optional, both must be supplied.

    • Omitted argument isn't optional.
      An argument can only be omitted from a call to a user-defined procedure if it was declared Optional in the procedure declaration. Either supply the argument in the call or declare the parameter Optional in the definition.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  4. #4
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Resize Form & Controls For Screen Size - VB6

    Not to be the devil's advocate, but there used to be a Resize 3rd party control available for very little cost that did about everything automatically for you as the form was resized. It even changed the font sizes on the controls. Resize might still be available, but it's been awhile since I used it. Limits could also be placed on it so that the user could not blow away the form.
    Doctor Ed

  5. #5
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Resize Form & Controls For Screen Size - VB6

    Another member of this forum recently had the same resizing problem as the OP. There were some excellent links to open-source Controls AutoResizer codes given there.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  6. #6
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Resize Form & Controls For Screen Size - VB6

    I think OP stopped reading the instructions too early:
    Quote Originally Posted by original tutorial
    Now for how to use it, in the Form_Load Event you add a call to:
    •GetLocation

    •ResizeForm
    And set the FontSize property of your controls, like this:

    Private Sub Form_Load()
    GetLocation Me
    CenterForm Me
    ResizeForm Me
    lblInstructions.Font = SetFontSize()
    End Sub

  7. #7
    New Member
    Join Date
    Feb 2024
    Posts
    2

    Re: Resize Form & Controls For Screen Size - VB6

    Quote Originally Posted by Doogle View Post
    I think OP stopped reading the instructions too early:
    Code:
      Dim intY As Integer
      Dim intX As Integer
    
      If (Me.WindowState = vbNormal) Then
      
        If (Me.Left Like "-*") Then
          Me.Left = 1500: DoEvents
        End If
        
        If (Me.Top Like "-*") Then
          Me.Top = 1500: DoEvents
        End If
        
        Me.Left = (Me.Left - intX)
        Me.Top = (Me.Top - intY)
        
        Me.Width = ((Screen.TwipsPerPixelX / Me.Left) - Me.Left - intX)
        Me.Height = ((Screen.TwipsPerPixelY / Me.Top) - Me.Top - intY)
    
      End If
    
      lstBookTitle.Height = (Me.Height - 950)
    
      frm1.Width = (Me.Width - lstBookTitle.Width - 675)
      frm1.Height = Me.Height - 1775
      
      rtfBook.Height = (Me.Height - 1710)
      rtfBook.Width = (Me.Width - 3455)
      
      cmdClose.Left = (Me.Width - cmdClose.Width - 400)
      cmdClose.Top = (Me.Height - cmdClose.Height - 750)
      
      Call Me.Refresh
      
      Me.AutoRedraw = True

  8. #8
    New Member
    Join Date
    Feb 2024
    Posts
    2

    Re: Resize Form & Controls For Screen Size - VB6

    On Error Resume Next

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