How can I stretch a image in a Picture control?
Thanks
Printable View
How can I stretch a image in a Picture control?
Thanks
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/s...b&Number=55565
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
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