type
TExitManager =
class abstract
private class var
FManager: THintManager;
FGlow: TGlowEffect;
private
class procedure HideHint(Sender: TObject);
class function ShowHint(Sender: TObject; Form: TCustomForm; Position: TRectF; Text:
string; Image: THintImage; AssignedComp: TControl): Boolean;
public
class procedure DontExit(Sender: TObject; UserMessage:
string = '
');
class destructor Destroy;
end;
class destructor TExitManager.Destroy;
begin
FreeAndNil(FManager);
FreeAndNil(FGlow);
end;
class procedure TExitManager.DontExit(Sender: TObject; UserMessage:
string);
begin
if not (Sender
is TControl)
then
raise Exception.Create('
nee, so nich');
if not Assigned(FManager)
then begin
FManager := THintManager.Create(
nil);
FManager.GlowColor := TAlphaColorRec.Firebrick;
FManager.GlowEnabled := True;
FManager.OnShowHint := ShowHint;
FManager.OnHideHint := HideHint;
FGlow := TGlowEffect.Create(
nil);
FGlow.GlowColor := TAlphaColorRec.Firebrick;
end;
if Trim(UserMessage) = '
'
then
UserMessage := '
Fehlerhafte Eingabe';
FManager.ShowHint(TControl(Sender), UserMessage, hiDefault, True);
(TControl(Sender)
as IControl).DoEnter;
Abort;
end;
class procedure TExitManager.HideHint(Sender: TObject);
begin
FGlow.Parent :=
nil;
end;
class function TExitManager.ShowHint(Sender: TObject; Form: TCustomForm; Position: TRectF; Text:
string; Image: THintImage; AssignedComp: TControl): Boolean;
begin
//AssignedComp.InsertObject(0, FGlow); // FGlow.Parent := AssignedComp; FGlow.BringToFront;
Result := False;
end;