Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleStretch a picture to fill a PictureBox
DescriptionThis example shows how to stretch a picture to fill a PictureBox in Visual Basic 6. It uses the PaintPicture method.
Keywordsstretch, picture, squeeze, resize
CategoriesGraphics
 
When the form resizes, it makes the picVisible control fill the form. When the picVisible control resizes, the program uses the PaintPicture method to copy a hidden picture onto it.
 
' Make picVisible fill the form.
Private Sub Form_Resize()
    picVisible.Move 0, 0, ScaleWidth, ScaleHeight
End Sub

' Copy the image into picVisible.
Private Sub picVisible_Resize()
    picVisible.PaintPicture picHidden.Picture, _
        0, 0, picVisible.ScaleWidth, _
        picVisible.ScaleHeight, _
        0, 0, picHidden.ScaleWidth, _
        picHidden.ScaleHeight, vbSrcCopy
End Sub
 
My book Visual Basic Graphics Programming shows how to resize a picture smoothly without jagged aliasing effects.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated