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.

Cursors<br />

VCL Components<br />

The Cursor property controls the cursor that is displayed when the user moves the mouse<br />

cursor over the component. W<strong>in</strong>dows automatically changes cursors for some components.<br />

For example, W<strong>in</strong>dows changes the cursor to an I-beam when the cursor is moved over an<br />

Edit, a Memo, or a RichEdit component, to name just a few. To let W<strong>in</strong>dows manage the<br />

cursor, leave the Cursor property set to crDefault. If you have specialized w<strong>in</strong>dows<br />

(components), you can specify one of the other cursors. When the mouse is moved over that<br />

component, W<strong>in</strong>dows will change the cursor to the one you have specified.<br />

Frequently you will need to change cursors at runtime. A long process, for <strong>in</strong>stance, should<br />

be <strong>in</strong>dicated to the user by display<strong>in</strong>g the hourglass cursor. When you reset the cursor you<br />

need to be sure to set the cursor back to whatever it was orig<strong>in</strong>ally. The follow<strong>in</strong>g code snippet<br />

illustrates:<br />

TCursor oldCursor = Cursor;<br />

Cursor = TCursor(crHourGlass);<br />

// do some stuff which takes a long time<br />

Cursor = oldCursor;<br />

This ensures that the cursor that was orig<strong>in</strong>ally set for the application is properly restored.<br />

Another cursor property, DragCursor, is used to set the cursor that is used when the mouse<br />

cursor is be<strong>in</strong>g dragged from the component and the target can accept the drag. As with<br />

colors, you should be prudent <strong>in</strong> your use of cursors. Use custom cursors when needed, but<br />

don’t overdo it.<br />

Enabled<br />

NOTE<br />

Components can be enabled or disabled through the Enabled property. When a component<br />

is disabled, it cannot accept focus (click<strong>in</strong>g on it has no effect), and usually it gives some visual<br />

cue to <strong>in</strong>dicate that it is disabled. In the case of buttons, for <strong>in</strong>stance, the button text is grayed<br />

out as is any bitmap on the button. Enabled is a boolean property—set it to true to enable<br />

the component, or set it to false to disable the component. Enabl<strong>in</strong>g and disabl<strong>in</strong>g w<strong>in</strong>dows<br />

(remember that w<strong>in</strong>dowed components are w<strong>in</strong>dows, too) is a feature of W<strong>in</strong>dows itself.<br />

Some components show their disabled state at design time, but most do<br />

not. The BitBtn component is one that does show its disabled state at<br />

design time.<br />

The Enabled property applies mostly to w<strong>in</strong>dowed components, but can apply to nonw<strong>in</strong>dowed<br />

components as well. The SpeedButton component is an example of a non-w<strong>in</strong>dowed<br />

component that can be disabled.<br />

277<br />

8

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

Saved successfully!

Ooh no, something went wrong!