How can i stretch the picture in a picturebox like i can in an imagecontrol?
Printable View
How can i stretch the picture in a picturebox like i can in an imagecontrol?
You could try using StretchBlt to blit to the picturebox
in picturebox control set the property autosize=true.
and in imagecontrol set the property stretch=true
try this
and enjoy your self:cool:
The stretch property in the image control will stretch the picture to fix the control's size. The autosize property in the picturebox control will resize the picturebox to the size of the picture.Quote:
Originally posted by sipatel8
in picturebox control set the property autosize=true.
and in imagecontrol set the property stretch=true
try this
and enjoy your self:cool:
plenderj>> Explain some more about Bitblt. Some code would be great.. Thank you..
This should do it.
Add a picturebox called Picture1, and a small picture called a.bmp in the root directory, and this should do it.
VB Code:
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 Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hdc As Long) As Long Private Declare Function DeleteDC Lib "GDI32" (ByVal hdc As Long) As Long Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long Private Declare Function DeleteObject Lib "GDI32" (ByVal hObject As Long) As Long Private Declare Function SelectObject Lib "GDI32" (ByVal hdc As Long, ByVal hObject As Long) As Long '' Device Contexts used for blitting Private myDc As Long Private DC As Long Private picTemp As IPictureDisp Private Sub Form_Load() DC = CreateCompatibleDC(Form1.hdc) If DC < 1 Then Exit Sub End If Set picTemp = LoadPicture("c:\a.bmp") SelectObject DC, picTemp GenerateDC = DC DeleteObject picTemp myDc = DC StretchBlt Picture1.hdc, 0, 0, Picture1.Width, Picture1.Height, myDc, 0, 0, Form1.ScaleX(picTemp.Width), Form1.ScaleY(picTemp.Height), vbSrcCopy End Sub
Thanx!! Got it and run it..:D