Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleDraw on an MDI parent form's background
KeywordsMDI, background, draw, MDIForm
CategoriesGraphics, Tips and Tricks
 
MDI parent forms do not provide methods for drawing on them, but they do have a Picture property. Draw on hidden PictureBox and then copy the image into the MDI parent's Picture property.
 
Private Sub AnimationTimer_Timer()
Const R = 500
Static X As Single
Static Y As Single
Static Vx As Single
Static Vy As Single
Static done_before As Boolean

    If Not done_before Then
        done_before = True
        Randomize
        Vx = 50 + Rnd * 50
        Vy = 50 + Rnd * 50
        X = ScaleWidth / 2
        Y = ScaleHeight / 2
    End If
    
    ' Clear the backdrop.
    Backdrop.Line (0, 0)-(ScaleWidth, ScaleHeight), _
        Backdrop.BackColor, BF
    
    ' Draw the circle.
    Backdrop.Circle (X, Y), R
    Backdrop.Picture = Backdrop.Image
    MDIForm1.Picture = Backdrop.Picture
    
    ' Move the circle.
    X = X + Vx
    If (X + R > ScaleWidth) Or (X - R < 0) Then
        X = X - Vx
        Vx = -Vx
    End If
    Y = Y + Vy
    If (Y + R > ScaleHeight) Or (Y - R < 0) Then
        Y = Y - Vy
        Vy = -Vy
    End If
End Sub

Private Sub MDIForm_Resize()
    Backdrop.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated