1. Home
  2. Computing & Technology
  3. Visual Basic

Chapter 16 - Adding Graphics and Animation Effects

By Dan Mabbutt, About.com

5 of 5

The Code and Result of Monitoring the Paint Event

Paint

~~~~~~~~~~~~~~~~~~~~~~~~~
Dim paintcount As Integer = 0
Private Sub Form1_Paint( _
  ByVal sender As Object, _
  ByVal e As System.Windows.Forms.PaintEventArgs) _
  Handles MyBase.Paint
  paintcount += 1
  Debug.Write("Paint Event executed " _
    & CStr(paintcount) & vbCrLf)
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~

You will then see just when and how often the Paint event is called automatically as you resize, move, or minimize the window. In the My Moving Icon example in the book, because the timer is enabled from the first button click and never disabled, the form is repainted every 75 milliseconds no matter what else the program is doing. (This is why the example doesn't use a Paint event.)

Considerations like these can seriously impact the performance of your program ... or explain why it's not working the way you expect!

Index: Chapter 16 - Adding Graphics and Animation Effects

  1. Introduction to GDI+
  2. Cooperating With GDI+
  3. The GDI+ Coordinate System
  4. Understanding the Flow of Events
  5. The Code and Result of Monitoring the Paint Event

5 of 5

Explore Visual Basic

More from About.com

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Adding Graphics and Animation Effects

©2008 About.com, a part of The New York Times Company.

All rights reserved.