Two Minor Bugs with the Demonstration Application

Summary

Id:2185.1
Type:Bug Bug
Current Status:Open

Detail

22 Oct 2003OpenThomas N. Andersen

First thanks for that wonderful site, full of insights and help! ;o) I found a little bug in the VBScrollbardemo downloaded today 22 oct. 2003

Description

If you look at the frmScrollDemo form. Resize it smaller so both scrollbars show. Then scroll horizontal to the right. Then Click on the Form Maximize button. Result: The left part of the form is not visible ( picBox.left is not reset )

Fix:

Private Sub Form_Resize()
Dim lHeight As Long
Dim lWidth As Long
Dim lProportion As Long
   
   ' Pixels are the minimum change size for a screen object.
   ' Therefore we set the scroll bars in pixels.
 
   lHeight = (picClient.Height - Me.ScaleHeight) \ Screen.TwipsPerPixelY
   If (lHeight > 0) Then
      lProportion = lHeight \ (Me.ScaleHeight \ Screen.TwipsPerPixelY) + 1
      m_cScroll.LargeChange(efsVertical) = lHeight \ lProportion
      m_cScroll.Max(efsVertical) = lHeight
      m_cScroll.Visible(efsVertical) = True
   Else
      picClient.Top = 0
      m_cScroll.Visible(efsVertical) = False
   End If
   
   lWidth = (picClient.Width - Me.ScaleWidth) \ Screen.TwipsPerPixelX
   If (lWidth > 0) Then
      lProportion = lWidth \ (Me.ScaleWidth \ Screen.TwipsPerPixelX) + 1
      m_cScroll.LargeChange(efsHorizontal) = lWidth \ lProportion
      m_cScroll.Max(efsHorizontal) = lWidth
      m_cScroll.Visible(efsHorizontal) = True
   Else
      picClient.Left = 0
      m_cScroll.Visible(efsHorizontal) = False
   End If
   
End Sub

Another issue in Form_Load

Description

When Adding a extra control left of fraInfo it does not show

Fix

Replace the picClient.Move line with

   Dim hMin As Long
   hMin = lblDemo(lblDemo.UBound).Top + lblDemo(0).Height + 2 * Screen.TwipsPerPixelY
   If Me.ScaleHeight > hMin Then hMin = Me.ScaleHeight
   picClient.Move 0, 0, Me.ScaleLeft + Me.ScaleWidth, hMin

Result easier to understand and allow extra controls to be added to the form Left of the FraInfo.

Also: if Align is set on the picClient by accident a runtime error appears from the picClient.move

Fix: Add picClient.Align = 0 to Form_Load