Link to home
Start Free TrialLog in
Avatar of VBTom
VBTom

asked on

Image Control Resizing

I'm using an array of Images controls that are loaded at run time from 0-99.  I want all of them to resize to the window in a 10 by 10 square when the window is resized, but they don't.  I think that this is because the stretch property is set to True.  Here is the code:

Private Sub Form_Resize()
    On Error Resume Next
    For I = 1 To H * W
        Unload MazPiece(I)
    Next I
    DoEvents
    MakeBoxes
End Sub

Public Sub MakeBoxes()
    A = ToolBar(8).Left + ToolBar(8).Width + 500 'Left Buffer
    WID = (Me.Width - A - 400) / W
    HEI = (Me.Height - 900) / H
    MazPiece(0).Height = HEI
    MazPiece(0).Width = WID
    MazPiece(0).Visible = True
    For I = 1 To H * W
        Load MazPiece(I)
        MazPiece(I).Width = WID
        MazPiece(I).Height = HEI
        MazPiece(I).Visible = True
    Next I
    Whatever = 0
    For Y = 1 To W
        For X = 1 To H
            Whatever = Whatever + 1
            MazPiece(Whatever).Left = ((X - 1) * WID) + A
            MazPiece(Whatever).Top = ((Y - 1) * HEI)
            MazPiece(Whatever).Picture = PicClip.GraphicCell(14)
        Next X
    Next Y
End Sub
ASKER CERTIFIED SOLUTION
Avatar of paul_tsekov
paul_tsekov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of VBTom
VBTom

ASKER

Thank you.  It worked just like I wanted it to.  I also found another answer that does the same thing elsewhere.  That answer is to make ImageX.Picture = LoadPicture("").  They both do the same thing though I'm not sure which one is faster.