Created
December 22, 2015 09:00
-
-
Save tdelphi/99c4c847fd91da59ea97 to your computer and use it in GitHub Desktop.
tlazyCursorChanger based on Barry K method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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