Resize Form & Controls For Screen Size - VB6-VBForums
Results 1 to 6 of 6

Thread: Resize Form & Controls For Screen Size - VB6

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2011
    Posts
    74

    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
    4,023

    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
    3,187

    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,355

    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
    3,187

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.