Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 16271, TAutoCursor -- auto restores default screen cursor

by Kevin Berry Email: Anonymous


Tiny screen cursor class restores the screen cursor whenever the function it's in exits.
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For C++Builder, Version 1.0  to 5.0 288 downloads
Copyright: No significant restrictions


Size: 621 bytes
Updated on Fri, 22 Jun 2001 14:52:46 GMT
Originally uploaded on Fri, 22 Jun 2001 14:42:30 GMT
SHA1 Hash: 0AEBFD4C1C83656A418341185B47EA347F79F25F
MD5 Hash: 26BF9FDD9D5C04385BB89214C91ADCCA

    Explore the files in this upload

Description
TAutoCursor AutoCursor;

Place the statement above at the point in any function that an hourglass screen cursor should appear. When the function exits, the old screen cursor will be restored (usually an arrow) by AutoCursor's destructor.

With AutoCursor, there's no need to write "Screen->Cursor = crDefault;" before every possible function exit point.

class TAutoCursor
{
TCursor OldCursor;
public:
TAutoCursor() {OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass;}
~TAutoCursor(){Screen->Cursor = OldCursor;}
};

While AutoCursor exists, the screen cursor can still be manually changed to any TCursor desired.

This class can be enhanced by adding another constructor to the class to take the startup cursor desired:

TAutoCursor(TCursor Value){OldCursor = Screen->Cursor; Screen->Cursor = Value;}

The usage would then be:

TAutoCursor AutoCursor(crHandPoint); //or any other TCursor type

Kevin Berry
kevinberry@charter.net

(The download is simply the text in this description).

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Server Response from: ETNACDC03