|
-
Sep 5th, 2001, 03:51 AM
#1
Thread Starter
Hyperactive Member
How can i stretch a picturebox?
How can i stretch the picture in a picturebox like i can in an imagecontrol?
-
Sep 5th, 2001, 03:54 AM
#2
Retired VBF Adm1nistrator
You could try using StretchBlt to blit to the picturebox
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Sep 5th, 2001, 04:00 AM
#3
New Member
repyl of your question
in picturebox control set the property autosize=true.
and in imagecontrol set the property stretch=true
try this
and enjoy your self
-
Sep 5th, 2001, 04:02 AM
#4
Retired VBF Adm1nistrator
Re: repyl of your question
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
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.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Sep 5th, 2001, 04:44 AM
#5
Thread Starter
Hyperactive Member
plenderj>> Explain some more about Bitblt. Some code would be great.. Thank you..
-
Sep 5th, 2001, 05:30 AM
#6
Retired VBF Adm1nistrator
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
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Sep 5th, 2001, 06:18 AM
#7
Thread Starter
Hyperactive Member
Thanx!! Got it and run it..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|