CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2001
    Location
    Romania
    Posts
    71

    Stretch a Picture control

    How can I stretch a image in a Picture control?
    Thanks


  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Stretch a Picture control

    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


  3. #3
    Join Date
    Jun 2000
    Posts
    11

    Re: Stretch a Picture control

    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


  4. #4
    Join Date
    Apr 2000
    Posts
    737

    Re: Stretch a Picture control

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured