How to set background picture for form (like the background image of a HTML Document)
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 'Forms - How to set background picture for form (like the background image of a HTML Document) 'Function which fill forms with some little pictures (like the background image 'of a HTML Document). 'insert this code in a module and call from form_load. 'pic is the picture path and ctl is the form. Public Sub BackPicture(Ctl As VB.Form, ByVal pic As String) Dim img() As VB.Image ReDim Preserve img(1) Set img(0) = Ctl.Controls.Add("VB.image", "img") img(0).Picture = LoadPicture(pic) hmax = Screen.Width / img(0).Width + 2 vmax = Screen.Height / img(0).Height + 2 For L = 1 To vmax For h = 1 To hmax cpt = cpt + 1 'Load img(cpt) ReDim Preserve img(cpt) Set img(cpt) = Ctl.Controls.Add("VB.image", "img" & cpt) With img(cpt) .Visible = True .Picture = img(0).Picture .Top = L * .Height - (.Height) .Left = h * .Width - (.Width) End With Next Next End Sub Private Sub Form_Load() Call BackPicture(Me, "C:\WINDOWS\Blue Lace 16.bmp") End Sub |