JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: PictureBox Problem!!! Help! Archived to Disk
If you can use an image control instead, it has a stretch feature...
Otherwise, try the following (of course, picture1 will have to have a picture loaded):
Option Explicit
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 Form_Load()
Me.Visible = True
DoEvents
' Set the graphic mode to persistent
Me.AutoRedraw = True
' API uses pixels, set pixels for the form, and boxes
' that way can just set width & height to desired pixel
Me.ScaleMode = vbPixels
Picture1.ScaleMode = vbPixels
Picture2.ScaleMode = vbPixels
' Set the width and height
Picture2.Width = 210
Picture2.Height = 305
DoEvents
' Stretch the picture
StretchBlt Picture2.hdc, 0, 0, 210, 305, Picture1.hdc, 0&, 0&, Picture1.Width, Picture1.Height, vbSrcCopy
End Sub
|