Click to See Complete Forum and Search --> : Stretch a Picture control


valentindvf
July 1st, 2001, 02:07 PM
How can I stretch a image in a Picture control?
Thanks

shree
July 1st, 2001, 07:22 PM
Unless your image is a metafile, the picture box doesn't allow stretching. You can use the Image control which has a stretch property, or use two pictureboxes. The following post contains a solution to sooming in a picturebox.

http://codeguru.com/cgi-bin/bbs/wt/showpost.pl?Board=vb&Number=55565

saju_peruvachira
July 2nd, 2001, 03:49 AM
There is a method called PaintPicture for the Picture Box.
Example:

PicBox.PaintPicture PicBox.Picture, 0, 0, PicBox.Width, PicBox.Height

The arguments are the picture, left, top, right,bottom

Try this.
Saju

cksiow
July 3rd, 2001, 08:03 PM
try the following, it did work on my pc. you need two picture box, call picdest & picsrc.


private Declare Function StretchBlt Lib "gdi32" (byval hdc as Long, byval x as Long, byval y as Long, byval nWidth as Long, byval nHeight as Long, byval hSrcDC as Long, byval xSrc as Long, byval ySrc as Long, byval nSrcWidth as Long, byval nSrcHeight as Long, byval dwRop as Long) as Long

private Sub Command1_Click()

picDest.Picture = LoadPicture("d:\windows\winlogo.gif")

End Sub

private Sub Form_Load()
picSrc.Visible = false
picSrc.ScaleMode = vbPixels
picDest.AutoRedraw = true
picDest.ScaleMode = vbPixels
End Sub

private Sub picDest_Change()

picSrc.Picture = LoadPicture("d:\windows\winlogo.gif")
StretchBlt picDest.hdc, 0, 0, picDest.ScaleWidth, picDest.ScaleHeight, picSrc.hdc, 0, 0, picSrc.Picture.Width / 26.46, picSrc.Picture.Height / 26.46, vbSrcCopy
picDest.Refresh


End Sub






HTH

cksiow
http://vblib.virtualave.net - share our codes