was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

58 Visitors Online


 
...Screen.Cursor ändern, ohne zurücksetzen zu müssen?
Autor: KK Gian
[ Tip ausdrucken ]  

Tip Bewertung (13):  
     


// By implementing Interface we can set the cursor without restore it in the end.
// Example: In convensional way...
var
  
Cur: TCursor;
begin
  
Cur := Screen.Cursor;
  Screen.Cursor := crSQLWait;
  //do coding here
  //What happend is that if your code did not finish, the screen cursor will
  //remain as crSQLWait.. even with try..finally block (sometimes)
  
Screen.Cursor := Cur;
end;

// By using interface, we can implement as follows
type
  
ImyCursor = interface
    
[(GUID - Ctrl - Shift - G)]
  end;
  TmyCursor = class(TInterfacedObjects, ImyCursor);
  private
  
FCursor: TCursor;
  public
constructor 
Create;
  destructor Destroy; override;
    end;

implementation

TmyCursor.Create;

begin
  
FCursor := Screen.Cursor;
end;

TmyCursor.Destroy;

begin
  
Screen.Cursor := FCursor;
  inherited;
end;

procedure....var
  
C: ImyCursor;
begin
  
C := TmyCursor.Create;
  Screen.Curosr := crSQLWait; // whatever cursor you like
  // Do coding here without worring to free it.
  // Screen Cursor will restore when the TMyCursor object get out of scope.
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners