home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Programmer'…arterly (Limited Edition)
/
Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso
/
code
/
ch13code
/
genform.bas
next >
Wrap
BASIC Source File
|
1995-08-12
|
2KB
|
46 lines
Attribute VB_Name = "Module1"
Option Explicit
' Keeps scroll bars on the outer edges of a form
' after resizing. Assumes that the horizontal
' and scroll bars in the form's controls
' collect apply to the form.
Sub AdjustScrollBars(frmTarget As Form)
' Declare size and object variables.
Dim sHeight As Single, sWidth As Single
Dim objCount As Object
Dim scrHScroll As Control, scrVScroll As Control
' Search through the form's controls collection...
For Each objCount In frmTarget.Controls
' Find the horizontal scroll bar.
If TypeName(objCount) = "HScrollBar" Then
' Initialize object variable.
Set scrHScroll = objCount
' If visible, then record height to help position
' vertical scroll bar later.
If scrHScroll.Visible = True Then
sHeight = scrHScroll.Height
End If
' Find the vertical scroll bar.
ElseIf TypeName(objCount) = "VScrollBar" Then
' Initialize object variable.
Set scrVScroll = objCount
' If visible, then record width to help position
' horizontal scroll bar later.
If scrVScroll.Visible = True Then
sWidth = scrVScroll.Width
End If
End If
Next objCount
' Set position of horizontal scroll bar (if one exists).
If TypeName(scrHScroll) = "HScrollBar" Then
scrHScroll.TOP = frmTarget.ScaleHeight - sHeight
scrHScroll.Width = frmTarget.ScaleWidth - sWidth
End If
' Set position of vertical scroll bar (if one exists).
If TypeName(scrVScroll) = "VScrollBar" Then
scrVScroll.Left = frmTarget.ScaleWidth - sWidth
scrVScroll.Height = frmTarget.ScaleHeight - sHeight
End If
End Sub