12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

160 Day 5<br />

Tucked <strong>in</strong>to this group of classes is the TMediaPlayer class. This class allows you to play media<br />

files like WAV audio, AVI video, and MIDI audio. The media can be played, stopped,<br />

paused, or positioned at a particular po<strong>in</strong>t <strong>in</strong> the file, as well as many other operations. This<br />

class has many properties and events that greatly simplify the complex world of the W<strong>in</strong>dows<br />

Media Control Interface (MCI).<br />

The System group <strong>in</strong>cludes OLE and dynamic data exchange (DDE) classes as well.<br />

GDI Classes<br />

The GDI (graphics device <strong>in</strong>terface) classes typically get a lot of work <strong>in</strong> W<strong>in</strong>dows GUI<br />

applications. These classes encapsulate the use of bitmaps, fonts, device contexts (DCs),<br />

brushes, and pens. It is through these GDI objects that graphics and text are displayed on a<br />

w<strong>in</strong>dow. The GDI classes are not associated with a specific component, but many components<br />

have <strong>in</strong>stances of these classes as properties. For example, an edit control has a property<br />

called Font that is an <strong>in</strong>stance of the TFont class.<br />

The term device context is well known by W<strong>in</strong>dows programmers whether they program <strong>in</strong><br />

C or with one of the <strong>C++</strong> frameworks. In VCL, though, the term is not widely used. This<br />

is because VCL calls DCs canvases and encapsulates the complex world of DCs <strong>in</strong> the TCanvas<br />

class. A canvas provides a surface that you can draw on us<strong>in</strong>g methods like MoveTo(),<br />

L<strong>in</strong>eTo(), and TextOut(). Bitmaps can be displayed on the canvas us<strong>in</strong>g the Draw() or<br />

StretchDraw() methods. The concept of a canvas that you draw on makes more sense than<br />

the archaic term device context, don’t you th<strong>in</strong>k?<br />

The TCanvas class conta<strong>in</strong>s <strong>in</strong>stances of the other GDI classes. For example, when you do a<br />

MoveTo()/L<strong>in</strong>eTo() sequence, a l<strong>in</strong>e is drawn with the current pen color. The Pen property is<br />

used to determ<strong>in</strong>e the current pen color and is an <strong>in</strong>stance of the TPen class. TPen has properties<br />

that determ<strong>in</strong>e what type of l<strong>in</strong>e to draw: the l<strong>in</strong>e width, the l<strong>in</strong>e style (solid, dashed, dotted,<br />

and so on), and the mode with which to draw the l<strong>in</strong>e.<br />

The TBrush class represents a brush that is used as the fill pattern for canvas operations like<br />

FillRect(), Polygon(), and Ellipse(). TBrush properties <strong>in</strong>clude Color, Style, and Bitmap.<br />

The Style property allows you to set a hatch pattern for the brush. The Bitmap property allows<br />

you to specify a bitmap that will be used for the fill pattern.<br />

TBitmap encapsulates bitmap operations <strong>in</strong> VCL. Properties <strong>in</strong>clude Palette, Height, Width,<br />

and TransparentColor. Methods <strong>in</strong>clude LoadFromFile(), LoadFromResourceID(), and<br />

SaveToFile(). TBitmap is used by other component classes such as TImage, TBitBtn, and<br />

TSpeedButton <strong>in</strong> addition to TCanvas.<br />

The TFont class handles font operations. Properties <strong>in</strong>clude Color, Height, and Style (bold,<br />

italic, normal, and so on). The TFont class is used by all component classes that display text.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!