Sub TileMDIBkgd(MDIForm As Form, bkgdtiler As Form, bkgdfile As String) If bkgdfile = "" Then Exit Sub Dim ScWidth%, ScHeight% ScWidth% = Screen.Width / Screen.TwipsPerPixelX ScHeight% = Screen.Height / Screen.TwipsPerPixelY Load bkgdtiler bkgdtiler.Height = Screen.Height bkgdtiler.Width = Screen.Width bkgdtiler.ScaleMode = 3 bkgdtiler!Picture1.Top = 0 bkgdtiler!Picture1.Left = 0 bkgdtiler!Picture1.Picture = LoadPicture(bkgdfile) bkgdtiler!Picture1.ScaleMode = 3
For n% = 0 To ScHeight% Step bkgdtiler!Picture1.ScaleHeight For o% = 0 To ScWidth% Step bkgdtiler!Picture1.ScaleWidth bkgdtiler.PaintPicture bkgdtiler!Picture1.Picture, o%, n% Next o% Next n%
MDIForm.Picture = bkgdtiler.Image Unload bkgdtiler End Sub
以下为一应用实例:
Private Sub MDIForm_Load() TileMDIBkgd Me, Form1, "c:\windows\Tiles.bmp" End Sub
用了一个时钟控件.判断窗体面积有没有发生变化. dim mai as double Private Sub Form_Load() Image1.Stretch = True Image1.Top = 0 Image1.Left = 0 Image1.Height = Me.ScaleHeight Image1.Width = Me.ScaleWidth mai = Me.ScaleHeight * Me.ScaleWidth End Sub
Private Sub Timer1_Timer() If Me.ScaleHeight * Me.ScaleWidth <> mai Then Image1.Stretch = True Image1.Top = 0 Image1.Left = 0 Image1.Height = Me.ScaleHeight Image1.Width = Me.ScaleWidth mai = Me.ScaleHeight * Me.ScaleWidth End If End Sub