C H A P T E R
T W E N T Y - T W O
Graphics in Delphi
■
Painting on a form
■
Animated buttons
■
An
image viewer
■
Drawing over a bitmap
■
Graphical grids and games
■
Using TeeChart
■
Windows metafiles
22
Copyright ©1999 SYBEX, Inc., Alameda, CA. www.sybex.com
www.sybex.com
4
I
n Chapter 6 of
Mastering Delphi 5, I
introduced the Canvas object, Windows
painting process, and the OnPaint event. In this bonus chapter, I’m
going to start
from this point and continue covering graphics, following a number of different
directions. (For all the
code discussed here and in Mastering Delphi 5, check the
Sybex Web site.)
I’ll start with the development of a complex program to demonstrate how the
Windows painting model works. Then I’ll focus on some graphical components,
such as graphical buttons and grids. During this part of the chapter we’ll
also add
some animation to the controls.
Finally, this chapter will discuss the use of bitmaps, covering some advanced
features
for fast graphics rendering, metafiles, the TeeChart component (including
its use on the Web), and few more topics related to the overall issue of graphics.
Drawing on a Form
In Chapter 6, we saw that it is possible to paint directly
on the surface of a form in
response to a mouse event. To see this behavior, simply create a new form with
the following OnMouseDown event handler:
procedure TForm1.FormMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);