Funny name huh?
Anyway, I know there is a method of resizing a control (such as a text box) to the client size of a form. I need to resize the form so it's client size is the size of a control.
Printable View
Funny name huh?
Anyway, I know there is a method of resizing a control (such as a text box) to the client size of a form. I need to resize the form so it's client size is the size of a control.
Is that what you were looking for?Code:Me.Width = Control.Width
Me.Height = Control.Height
you mean like this?
Code:Private Sub Form_Resize()
On Error Resume Next
Text1.Left = 0
Text1.Top = 0
Text1.Width = Me.Width
Text1.Height = Me.Height
End Sub
neither of those would work. the first would make the outside of the form the same size as the form. need to set just the client area.
the second resizes the control. I need to resize the form.
If you have listbox and you wanted the form to be the size of the listbox then the first method would do that.
ie.
Form1.Widht = List1.Width
Form1.Height = List1.Height
so you need to do this???
??Code:Private Sub Form_Load()
Me.Width = Control.Width
Me.Height = Control.Height
End Sub
this is what happens when i use that code. screenshot at http://agent_153.tripod.com/problem.gif
i need the form to fit around the control, without resizing the control, but resizing the form
you may have to change the numbers a little.Code:Private Sub Form_Load()
Me.Width = Control.Width + 5
Me.Height = Control.Height + 5
End Sub
this should work...alows you to move the textbox to a
positon where the form can size itself around it and
then put your form back to it's original state.
'This will resize it to the size of the textbox
'and wrap around it...then you can double click
'the textbox to reset your form to it's origial stature
Code:Option Explicit
Public tl As Integer, tt As Integer
Public fh As Integer, fw As Integer
'
'command button call cmdShrink
Private Sub cmdShrink_Click()
tt = Text1.Top
tl = Text1.Left
fh = Form1.Height
fw = Form1.Width
Form1.Height = Text1.Height + 380
Form1.Width = Text1.Width + 80
Text1.Top = 0
Text1.Left = 0
End Sub
Private Sub Text1_DblClick()
Text1.Left = tl
Text1.Top = tt
Form1.Height = fh
Form1.Width = fw
End Sub
that's the problem. i need to figure out how much to offset the size of the form by. I don't want to hardwire the numbers like above, incase the user has weird windows desktop settings.
I think i can fgure the size of the border by comparing scalewdthi to width (same with height)
I'll post back if it doesn't work
Look under: HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics for the sizes
OK, i figured it out:-----Code:Private Sub Form_Load()
Dim bw&
Dim bh&
With Text1
bw = Width - ScaleWidth
bh = Height - ScaleHeight
Me.Width = .Width + bw
Me.Height = .Height + bh
.Top = 0
.Left = 0
End With
End Sub
scaleheight/scalewidth return the client size (changing them sets the user scalemode) while width/height return the outer rectangle of the form.
[Edited by agent on 08-21-2000 at 08:03 PM]