Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
XML RSS Feed
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
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-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated