Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resize frame with form 1

Status
Not open for further replies.

TallOne

Programmer
May 14, 2004
164
US
Hello All,

I'm trying to iterate over the frames on a form in my form_resize event to resize them with the form. Here's my code. What am I doing wrong? Thanks in advance!

Private Sub Form_Resize()
'Variables
Dim fra As Frame
Dim MinHeight As Long
Dim MinWidth As Long
'I've actually got these next two lines in form_load
MinHeight = Me.Height
MinWidth = Me.Width
'Check to see if form's getting too
'small forcing a min height and width
If Me.WindowState = vbMinimized Then Exit Sub 'Avoid error-NO resize if minimized
If MinHeight > frmMain.Height Then
frmMain.Height = MinHeight
Exit Sub
ElseIf MinWidth > frmMain.Width Then
frmMain.Width = MinWidth
Exit Sub
End If

On Error Resume Next
For Each fra In frmMain
If fra.Visible = True Then
fra.Top = 10
fra.Left = 0
fra.Width = frmMain.ScaleWidth
fra.Height = frmMain.Height - 1200
End If
Next
End Sub

Any help would be greatly appreciated. fra doesn't seem to be set or assigned to anything during For Each, therefore the if statement is skipped....I think.
 
I am a little rusty on VB6. Doing VB.Net
Dim fra as Control ' Test for Frame
For Each fra In me.Controls ' Get all controls
if Typeof ctl is Frame then
If fra.Visible = True Then
fra.Top = 10
fra.Left = 0
fra.Width = frmMain.ScaleWidth
fra.Height = frmMain.Height - 1200
End If
end if
Next


Forms/Controls Resizing/Tabbing
Compare Code
Generate Sort Class in VB
Check To MS)
 
Thanks John!
Did exactly what I wanted!

Oops I did have to change
if Typeof ctl
to
if Typeof fra

Here's a star :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top