Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to change the mouse cursor into a hourglass/normal. Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
07-Sep-03
Category
Open Tools API / IDE
Language
Delphi 5.x
Views
185
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Erwin Molendijk

How to change the mousecursor into a hourglass/normal.

Answer:

1   unit waitcursor;
2   { WaitCursor  -  Copyright (c) 2001 by E.J.Molendijk
3   
4     A mousecursor hourglass/normal changer tool. Supports layered requests.
5   
6     WCursor.SetWait     = mouse cursor as Hourglass
7     WCursor.SetWaitSQL  = mouse cursor as SQL Hourglass
8     WCursor.SetNormal   = mouse cursor as normal
9   
10    example:
11        WCursor.setWait;
12        try
13          DoSometingVerySlow;
14        finally
15          WCursor.setNormal;
16        end;
17  }
18  
19  interface
20  
21  type
22    TWaitCursor = class
23    private
24      FCursor: integer;
25      FCnt: integer;
26    public
27      constructor Create;
28      destructor Destroy; override;
29      procedure SetCursor(Index: integer);
30      procedure SetWait;
31      procedure SetWaitSQL;
32      procedure SetNormal;
33    end;
34  
35  var
36    WCursor: TWaitCursor;
37  
38  implementation
39  
40  uses Forms, Controls;
41  
42  constructor TWaitCursor.Create;
43  begin
44    inherited;
45    // depth is zero
46    FCnt := 0;
47  
48    // remember default cursor
49    FCursor := Screen.Cursor;
50  end;
51  
52  destructor TWaitCursor.Destroy;
53  begin
54    // Reset to default cursor
55    Screen.Cursor := FCursor;
56    inherited;
57  end;
58  
59  procedure TWaitCursor.SetCursor(Index: integer);
60  begin
61    // select cursor
62    Screen.Cursor := Index;
63  end;
64  
65  procedure TWaitCursor.SetNormal;
66  begin
67    // decrease depth
68    if FCnt > 0 then
69      Dec(FCnt);
70  
71    // if we reach depth 0 we restore default cursor
72    if FCnt = 0 then
73      SetCursor(FCursor);
74  end;
75  
76  procedure TWaitCursor.SetWait;
77  begin
78    // increase depth
79    Inc(FCnt);
80  
81    // select wait cursor
82    SetCursor(crHourglass);
83  end;
84  
85  procedure TWaitCursor.SetWaitSQL;
86  begin
87    // increase depth
88    Inc(FCnt);
89  
90    // select wait cursor
91    SetCursor(crSQLWait);
92  end;
93  
94  initialization
95    WCursor := TWaitCursor.Create;
96  finalization
97    WCursor.Free;
98  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC