Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
495 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi



Loremo - the 1.5 liter car coming in 2009




Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (0)


How to create a animated (rotating) hourglass.Format this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi 3.x (or higher)
Category:
VCL-General
Skill Level:
Scoring:
Last Update:
09/27/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet hourglass cursor animate hourglas.ani getwindowsdirectory loadcursorfromfile includetrailingpath includetrailingbackslash
Times Scored:
5
Visits:
3645
Uploader: Henk Schreij
Company:
Reference: N/A
 
Question/Problem/Abstract:
when you have a prolonged job you can show a animated (rotating) hourglass as cursor. Here is the way how to do it.
Answer:



If your program has a prolonged job, you can show an hourglass in the meantime. When the job takes a very long time the user may still think the computer has given up. If it isn't possible to use a Progressbar, you can use a rotating hourglass. Therefore Windows has a file named hourglas.ani that you must load at the startup of your program. Pay attention that that the name is in the Dos 8.3-format, in which 'hourglas' is with one 's'.

This code snippet shows how to load the cursor in the OnCreate of your main-form:

procedure TForm1.FormCreate(Sender: TObject);
begin
  Screen.Cursors[1]:=
    LoadCursorFromFile('C:\windows\cursors\hourglas.ani');
end;

Instead of using a 1 between the '['-brackets you can use any positive number (negative numbers and zero are used by Windows). For instance you use this number like:

procedure TForm1.Button1Click(Sender: TObject);
begin
  Screen.Cursor:= 1;
  //long time job
  Screen.Cursor:= crDefault;
end;

If you have NT instead of Windows, the rotating hourglass will be in 'C:\winnt\cursors\hourglas.ani'.

If you have a program that is used by NT as well as Windows, it will be smart if the cursor is looked up in the right directory. This can be done as followed:

procedure TForm1.FormCreate(Sender: TObject);
var
  sPath: array[0..MAX_PATH-1] of Char;
  P: PChar;
begin
GetWindowsDirectory(sPath, SizeOf(sPath));
P:= PChar(IncludeTrailingBackslash(sPath)
     + 'cursors\hourglas.ani');
Screen.Cursors[1]:= LoadCursorFromFile(P);
end;

The function IncludeTrailingBackslash exists since Delphi 5. If you have an earlier version you must write some code yourself. If you have Delphi 6 you can use IncludeTrailingPathDelimiter which is compatible with Kylix.





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment













 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
D. Wischnewski
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)