Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleTile an MDIForm's background
KeywordsMDI, MDIForm, background, tile
CategoriesTips and Tricks, Graphics
 
Put a PictureBox named picHidden on the MDIForm and set its Visible property to False. Put another PictureBox named picTile in picHidden and give it the tile picture you want.

When the MDIForm resizes, resize picHidden so it is large enough to cover the MDIForm.

When picHidden resizes, tile the picture onto picHidden. Then copy the picHidden.Picture to the MDIForm's Picture property.

 
Private Sub MDIForm_Resize()
    ' Make picHidden fill the MDI form.
    picHidden.Move 0, 0, Width, Height
End Sub

' Tile the MDI form.
Private Sub picHidden_Resize()
Dim X As Single
Dim Y As Single

    ' Tile picHidden.
    Y = 0
    Do While Y <= picHidden.ScaleHeight
        X = 0
        Do While X <= picHidden.ScaleWidth
            picHidden.PaintPicture picTile.Picture, X, Y, _
                picTile.ScaleWidth, picTile.ScaleHeight
            X = X + picTile.ScaleWidth
        Loop
        Y = Y + picTile.ScaleHeight
    Loop

    Picture = picHidden.Image
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated