-
Mar 5th, 2013, 01:25 PM
#1
Thread Starter
Lively Member
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
-
Mar 5th, 2013, 02:48 PM
#2
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.
-
Mar 5th, 2013, 04:04 PM
#3
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)
-
Mar 5th, 2013, 05:04 PM
#4
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.
-
Mar 5th, 2013, 05:25 PM
#5
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)
-
Mar 6th, 2013, 02:13 AM
#6
Re: Resize Form & Controls For Screen Size - VB6
I think OP stopped reading the instructions too early:
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
-
Feb 3rd, 2024, 01:01 AM
#7
New Member
Re: Resize Form & Controls For Screen Size - VB6
Originally Posted by Doogle
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
-
Feb 3rd, 2024, 01:22 AM
#8
New Member
Re: Resize Form & Controls For Screen Size - VB6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|