| The sample below assumes that the form has a picturebox to hold the bitmap to be tiled across the background: 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 Const SRCCOPY = &HCC0020 Sub Form_Resize () picture1.Visible = False picture1.Autoredraw = True picture1.AutoSize = True picture1.Borderstyle=0 picture1.Picture = LoadPicture("c:\windows\tiles.bmp") TileForm Me, picture1 End Sub Sub TileForm (frm As Form, pb As PictureBox) Dim x As Long Dim y As Long Dim z As Long frm.AutoRedraw = True frm.ScaleMode = vbPixels pb.ScaleMode = vbPixels For x = 0 To frm.ScaleWidth Step pb.Width For y = 0 To frm.ScaleHeight Step pb.Height z = BitBlt(frm.hDC, x, y, pb.Height, pb.Width, pb.hDC, 0, 0, SRCCOPY) Next y Next x frm.Refresh End Sub |
Tile a Form with a Bitmap |
Express News India | Freelance ecommerce web development India