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 >
BASIC Source File  |  1995-08-12  |  2KB  |  46 lines

  1. Attribute VB_Name = "Module1"
  2. Option Explicit
  3.  
  4. ' Keeps scroll bars on the outer edges of a form
  5. ' after resizing. Assumes that the horizontal
  6. ' and scroll bars in the form's controls
  7. ' collect apply to the form.
  8. Sub AdjustScrollBars(frmTarget As Form)
  9.     ' Declare size and object variables.
  10.     Dim sHeight As Single, sWidth As Single
  11.     Dim objCount As Object
  12.     Dim scrHScroll As Control, scrVScroll As Control
  13.     ' Search through the form's controls collection...
  14.     For Each objCount In frmTarget.Controls
  15.         ' Find the horizontal scroll bar.
  16.         If TypeName(objCount) = "HScrollBar" Then
  17.             ' Initialize object variable.
  18.             Set scrHScroll = objCount
  19.             ' If visible, then record height to help position
  20.             ' vertical scroll bar later.
  21.             If scrHScroll.Visible = True Then
  22.                 sHeight = scrHScroll.Height
  23.             End If
  24.         ' Find the vertical scroll bar.
  25.         ElseIf TypeName(objCount) = "VScrollBar" Then
  26.             ' Initialize object variable.
  27.             Set scrVScroll = objCount
  28.             ' If visible, then record width to help position
  29.             ' horizontal scroll bar later.
  30.             If scrVScroll.Visible = True Then
  31.                 sWidth = scrVScroll.Width
  32.             End If
  33.         End If
  34.     Next objCount
  35.     ' Set position of horizontal scroll bar (if one exists).
  36.     If TypeName(scrHScroll) = "HScrollBar" Then
  37.         scrHScroll.TOP = frmTarget.ScaleHeight - sHeight
  38.         scrHScroll.Width = frmTarget.ScaleWidth - sWidth
  39.     End If
  40.     ' Set position of vertical scroll bar (if one exists).
  41.     If TypeName(scrVScroll) = "VScrollBar" Then
  42.         scrVScroll.Left = frmTarget.ScaleWidth - sWidth
  43.         scrVScroll.Height = frmTarget.ScaleHeight - sHeight
  44.     End If
  45. End Sub
  46.