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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

158 Day 5<br />

Standard Component Classes<br />

The standard components are those components that encapsulate the most common<br />

W<strong>in</strong>dows controls. The standard component classes <strong>in</strong>clude TButton, TEdit, TListBox,<br />

TMemo, TMa<strong>in</strong>Menu, TPopupMenu, TCheckBox, TRadioButton, TRadioGroup, TGroupBox, and<br />

TPanel.<br />

Most of these classes encapsulate a W<strong>in</strong>dows control, so I won’t discuss all of them right now.<br />

The TMa<strong>in</strong>Menu class encapsulates an application’s ma<strong>in</strong> menu. At design time, doubleclick<strong>in</strong>g<br />

the Ma<strong>in</strong>Menu component’s icon br<strong>in</strong>gs up the Menu Editor. TMa<strong>in</strong>Menu has properties<br />

that control whether the menu item is grayed out, whether it is checked, the help context ID,<br />

the item’s h<strong>in</strong>t text, and others. Each menu item has a s<strong>in</strong>gle event, OnClick, so that you can<br />

attach a function to a menu item be<strong>in</strong>g selected. I’ll discuss menus and the Menu Editor <strong>in</strong><br />

more detail on Day 7, “Work<strong>in</strong>g with the Form Designer and the Menu Designer.”<br />

Another of the standard components of <strong>in</strong>terest is TPanel.<br />

A panel represents a rectangular region on a form, usually with its own components,<br />

that can be treated as a s<strong>in</strong>gle unit.<br />

NEW TERM<br />

For <strong>in</strong>stance, if you wanted to build a speedbar for an application, you would start with a<br />

panel and then place speed buttons on the panel. If you move the panel, the speed buttons<br />

move with it. Panels can be used for a wide variety of tasks <strong>in</strong> <strong>C++</strong>Builder. You could use a<br />

panel to build a status bar, for example. Panels have properties that control what type of edge<br />

the panel should have; whether the panel is raised, sunken, or flat; and the width of the border.<br />

Comb<strong>in</strong>ations of these properties can be used to create a variety of 3D panels.<br />

<strong>C++</strong>Builder has another group of components that I’ll throw <strong>in</strong> with the standard controls.<br />

These controls can be found under the Additional tab on the Component Palette. The classes<br />

represent<strong>in</strong>g these components <strong>in</strong>clude TBitBtn, TSpeedButton, TMaskEdit, TStr<strong>in</strong>gGrid,<br />

TDrawGrid, TImage, TShape, TBevel, and TScrollBox. The TBitBtn class represents a button<br />

that has an image on it. TSpeedButton is also a button with an image, but this component is<br />

designed to be used as a speed button on a control bar. A TSpeedButton is not a true button,<br />

but rather a graphical depiction of a button. This allows you to have a large number of speed<br />

buttons and not consume W<strong>in</strong>dows resources for each of the buttons. The TImage component<br />

allows you to place an image on a form that can then be selected from a file on disk. The<br />

TBevel component can be used to create boxes and l<strong>in</strong>es that are raised (bumps) or lowered<br />

(dips). Bevels can be used to divide up a form <strong>in</strong>to visual regions and generally to provide an<br />

aesthetically pleas<strong>in</strong>g form.<br />

W<strong>in</strong>dows 95 Custom Control Classes<br />

VCL has component classes that encapsulate many of the W<strong>in</strong>dows 32-bit custom controls.<br />

These classes <strong>in</strong>clude TListView, TTreeView, TProgressBar, TTabControl, TPageControl,

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

Saved successfully!

Ooh no, something went wrong!