hello there
does anyone know how i can tile a picture as a bacground for a form, the picture might be small, but i either want to stretch it or tile it all over the form
Printable View
hello there
does anyone know how i can tile a picture as a bacground for a form, the picture might be small, but i either want to stretch it or tile it all over the form
To tile a picture:
Code:Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long
Private Sub Form_Load()
AutoRedraw = True
Picture1.AutoRedraw = True
ScaleMode = 3
For x = 0 To Width Step Picture1.Width
For y = 0 To Height Step Picture1.Height
DoEvents
BitBlt hDC, x, y, Picture1.Width, Picture1.Height, Picture1.hDC, 0, 0, vbSrcCopy
Form1.Refresh
Next y
Next x
End Sub
Or:
Code:Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long
Private Sub Form_Load()
ScaleMode = 3
Picture1.AutoRedraw = True
End Sub
Private Sub Form_Paint()
For x = 0 To Width Step Picture1.Width
For y = 0 To Height Step Picture1.Height
DoEvents
BitBlt hDC, x, y, Picture1.Width, Picture1.Height, Picture1.hDC, 0, 0, vbSrcCopy
Next y
Next x
End Sub
And to stretch it.
Code:Private Sub Form_Load()
AutoRedraw = True
End Sub
Private Sub Form_Resize()
PaintPicture Picture1, 0, 0, Width, Height
End Sub
thx a lot megatron, thats just exactly what i was looking for