GetScrollDirectionSize Example VB

This example demonstrates how a call to the GetScrollDirectionSize method can be used to calculate the size needed to display 4 thumbnails in the scrolling direction while displaying 2 thumbnails in the non-scrolling direction.

First, the user is allowed to set the thumbnail width and height. The non-scrolling dimension is then derived from the average of the GetMimimumSize and GetMaximumSize methods. In this particular example, the scrolling direction is horizontal.

Private Sub cmdControlSize_Click()
    Dim lMinSize, lMaxSize, lVSize, lHSize As Long
    Dim bScroll As Boolean
    Dim iNonScrollThumbCount As Long    
    bScroll = True
    iNonScrollThumbCount = 2        'Number of thumbnails desired in 
                                    'non-scrolling direction    
    ImgThumbnail1.ScrollDirection = Horizontal
    ImgThumbnail1.UISetThumbSize    'User sets thumb size interactively 
    'Determine min and max control size taking a scrollbar into account
    lMinSize = ImgThumbnail1.GetMinimumSize(iNonScrollThumbCount, bScroll)
    lMaxSize = ImgThumbnail1.GetMaximumSize(iNonScrollThumbCount, bScroll)
    lVSize = (lMinSize + lMaxSize) / 2  'Average of the min & max nonscrolling size
    lHSize = ImgThumbnail1.GetScrollDirectionSize(4, iNonScrollThumbCount, lVSize, True)    
    'Prior to resizing the Thumbnail control, it is necessary to ensure 
    'the unit of   'measure for the form and Thumbnail control are the
    'same. The thumbnail methods return units in pixels - so the scale 
    'mode for the form must be set to pixels.
    Form1.ScaleMode = vbPixel
    ImgThumbnail1.Width = lHSize
    ImgThumbnail1.Height = lVSize
End Sub