Skip to content

Instantly share code, notes, and snippets.

@tdelphi
Created December 22, 2015 09:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdelphi/99c4c847fd91da59ea97 to your computer and use it in GitHub Desktop.
Save tdelphi/99c4c847fd91da59ea97 to your computer and use it in GitHub Desktop.
tlazyCursorChanger based on Barry K method
type
TScopeExitNotifier = class(TInterfacedObject)
private
FProc: TProc;
public
constructor Create(const AProc: TProc);
destructor Destroy; override;
end;
constructor TScopeExitNotifier.Create(const AProc: TProc);
begin
FProc := AProc;
end;
destructor TScopeExitNotifier.Destroy;
begin
if Assigned(FProc) then
FProc;
inherited;
end;
function MakeScopeExitNotifier(const AProc: TProc): IInterface;
begin
Result := TScopeExitNotifier.Create(AProc);
end;
function LazyChangeCursorToHourglass: IInterface;
var
tmpOldCursor: TCursor;
begin
tmpOldCursor := Screen.Cursor;
result := MakeScopeExitNotifier(procedure begin Screen.Cursor := tmpOldCursor; end);
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment