mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 12:19:14 +02:00
LCL: TApplicationProperties now uses handler lists instead of global events
git-svn-id: trunk@13358 -
This commit is contained in:
parent
b0034a4a02
commit
30a0f52908
31
lcl/forms.pp
31
lcl/forms.pp
@ -862,7 +862,7 @@ type
|
|||||||
Result: LRESULT;
|
Result: LRESULT;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TAppHintTimerType = (ahtNone, ahtShowHint, ahtHideHint, ahtReshowHint);
|
TAppHintTimerType = (ahttNone, ahttShowHint, ahttHideHint, ahttReshowHint);
|
||||||
|
|
||||||
TShowHintEvent = procedure (var HintStr: string; var CanShow: Boolean;
|
TShowHintEvent = procedure (var HintStr: string; var CanShow: Boolean;
|
||||||
var HintInfo: THintInfo) of object;
|
var HintInfo: THintInfo) of object;
|
||||||
@ -899,7 +899,16 @@ type
|
|||||||
ahtKeyDownAfter, // after interface and LCL
|
ahtKeyDownAfter, // after interface and LCL
|
||||||
ahtActivate,
|
ahtActivate,
|
||||||
ahtDeactivate,
|
ahtDeactivate,
|
||||||
ahtUserInput
|
ahtUserInput,
|
||||||
|
ahtException,
|
||||||
|
ahtEndSession,
|
||||||
|
ahtQueryEndSession,
|
||||||
|
ahtMinimize,
|
||||||
|
ahtRestore,
|
||||||
|
ahtDropFiles,
|
||||||
|
ahtHelp,
|
||||||
|
ahtHint,
|
||||||
|
ahtShowHint
|
||||||
);
|
);
|
||||||
|
|
||||||
PAsyncCallQueueItem = ^TAsyncCallQueueItem;
|
PAsyncCallQueueItem = ^TAsyncCallQueueItem;
|
||||||
@ -1076,6 +1085,24 @@ type
|
|||||||
procedure RemoveOnActivateHandler(Handler: TNotifyEvent);
|
procedure RemoveOnActivateHandler(Handler: TNotifyEvent);
|
||||||
procedure AddOnDeactivateHandler(Handler: TNotifyEvent; AsLast: Boolean=true);
|
procedure AddOnDeactivateHandler(Handler: TNotifyEvent; AsLast: Boolean=true);
|
||||||
procedure RemoveOnDeactivateHandler(Handler: TNotifyEvent);
|
procedure RemoveOnDeactivateHandler(Handler: TNotifyEvent);
|
||||||
|
procedure AddOnExceptionHandler(Handler: TExceptionEvent; AsLast: Boolean=true);
|
||||||
|
procedure RemoveOnExceptionHandler(Handler: TExceptionEvent);
|
||||||
|
procedure AddOnEndSessionHandler(Handler: TNotifyEvent; AsLast: Boolean=true);
|
||||||
|
procedure RemoveOnEndSessionHandler(Handler: TNotifyEvent);
|
||||||
|
procedure AddOnQueryEndSessionHandler(Handler: TQueryEndSessionEvent; AsLast: Boolean=true);
|
||||||
|
procedure RemoveOnQueryEndSessionHandler(Handler: TQueryEndSessionEvent);
|
||||||
|
procedure AddOnMinimizeHandler(Handler: TNotifyEvent; AsLast: Boolean=true);
|
||||||
|
procedure RemoveOnMinimizeHandler(Handler: TNotifyEvent);
|
||||||
|
procedure AddOnRestoreHandler(Handler: TNotifyEvent; AsLast: Boolean=true);
|
||||||
|
procedure RemoveOnRestoreHandler(Handler: TNotifyEvent);
|
||||||
|
procedure AddOnDropFilesHandler(Handler: TDropFilesEvent; AsLast: Boolean=true);
|
||||||
|
procedure RemoveOnDropFilesHandler(Handler: TDropFilesEvent);
|
||||||
|
procedure AddOnHelpHandler(Handler: THelpEvent; AsLast: Boolean=true);
|
||||||
|
procedure RemoveOnHelpHandler(Handler: THelpEvent);
|
||||||
|
procedure AddOnHintHandler(Handler: TNotifyEvent; AsLast: Boolean=true);
|
||||||
|
procedure RemoveOnHintHandler(Handler: TNotifyEvent);
|
||||||
|
procedure AddOnShowHintHandler(Handler: TShowHintEvent; AsLast: Boolean=true);
|
||||||
|
procedure RemoveOnShowHintHandler(Handler: TShowHintEvent);
|
||||||
procedure RemoveAllHandlersOfObject(AnObject: TObject); virtual;
|
procedure RemoveAllHandlersOfObject(AnObject: TObject); virtual;
|
||||||
procedure DoBeforeMouseMessage(CurMouseControl: TControl);
|
procedure DoBeforeMouseMessage(CurMouseControl: TControl);
|
||||||
function IsShortcut(var Message: TLMKey): boolean;
|
function IsShortcut(var Message: TLMKey): boolean;
|
||||||
|
@ -395,6 +395,7 @@ function TApplication.InvokeHelp(Command: Word; Data: Longint): Boolean;
|
|||||||
var
|
var
|
||||||
CallHelp: Boolean;
|
CallHelp: Boolean;
|
||||||
ActiveForm: TCustomForm;
|
ActiveForm: TCustomForm;
|
||||||
|
i: LongInt;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
CallHelp := True;
|
CallHelp := True;
|
||||||
@ -403,8 +404,12 @@ begin
|
|||||||
{ let existing hooks get called, if any. }
|
{ let existing hooks get called, if any. }
|
||||||
if Assigned(ActiveForm) and Assigned(ActiveForm.FOnHelp) then
|
if Assigned(ActiveForm) and Assigned(ActiveForm.FOnHelp) then
|
||||||
Result := ActiveForm.FOnHelp(Command, Data, CallHelp)
|
Result := ActiveForm.FOnHelp(Command, Data, CallHelp)
|
||||||
else if Assigned(FOnHelp) then
|
else if Assigned(FOnHelp) then begin
|
||||||
Result := FOnHelp(Command, Data, CallHelp);
|
Result := FOnHelp(Command, Data, CallHelp);
|
||||||
|
i:=FApplicationHandlers[ahtHelp].Count;
|
||||||
|
while (not Result) and (FApplicationHandlers[ahtHelp].NextDownIndex(i)) do
|
||||||
|
Result:=THelpEvent(FApplicationHandlers[ahtHelp][i])(Command, Data, CallHelp);
|
||||||
|
end;
|
||||||
|
|
||||||
if CallHelp then begin
|
if CallHelp then begin
|
||||||
if Assigned(ActiveForm) and ActiveForm.HandleAllocated
|
if Assigned(ActiveForm) and ActiveForm.HandleAllocated
|
||||||
@ -525,7 +530,7 @@ procedure TApplication.StopHintTimer;
|
|||||||
begin
|
begin
|
||||||
if FHintTimer <> nil then
|
if FHintTimer <> nil then
|
||||||
FHintTimer.Enabled := false;
|
FHintTimer.Enabled := false;
|
||||||
FHintTimerType := ahtNone;
|
FHintTimerType := ahttNone;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -596,15 +601,15 @@ begin
|
|||||||
{$ifdef DebugHintWindow}
|
{$ifdef DebugHintWindow}
|
||||||
DebugLn('TApplication.DoOnMouseMove Info.ControlHasHint=',dbgs(Info.ControlHasHint),' Type=',dbgs(ord(FHintTimerType)),' FHintControl=',DbgSName(FHintControl),' Info.Control=',DbgSName(Info.Control));
|
DebugLn('TApplication.DoOnMouseMove Info.ControlHasHint=',dbgs(Info.ControlHasHint),' Type=',dbgs(ord(FHintTimerType)),' FHintControl=',DbgSName(FHintControl),' Info.Control=',DbgSName(Info.Control));
|
||||||
{$endif}
|
{$endif}
|
||||||
if (FHintControl <> Info.Control) or (not (FHintTimerType in [ahtShowHint])) then
|
if (FHintControl <> Info.Control) or (not (FHintTimerType in [ahttShowHint])) then
|
||||||
begin
|
begin
|
||||||
if Info.ControlHasHint then
|
if Info.ControlHasHint then
|
||||||
begin
|
begin
|
||||||
FHintControl := Info.Control;
|
FHintControl := Info.Control;
|
||||||
case FHintTimerType of
|
case FHintTimerType of
|
||||||
ahtNone, ahtShowHint:
|
ahttNone, ahttShowHint:
|
||||||
StartHintTimer(HintPause, ahtShowHint);
|
StartHintTimer(HintPause, ahttShowHint);
|
||||||
ahtHideHint:
|
ahttHideHint:
|
||||||
ShowHintWindow(Info);
|
ShowHintWindow(Info);
|
||||||
else
|
else
|
||||||
HideHint;
|
HideHint;
|
||||||
@ -630,6 +635,7 @@ var
|
|||||||
CanShow: Boolean;
|
CanShow: Boolean;
|
||||||
HintWinRect: TRect;
|
HintWinRect: TRect;
|
||||||
CurHeight: Integer;
|
CurHeight: Integer;
|
||||||
|
i: LongInt;
|
||||||
begin
|
begin
|
||||||
if not FShowHint or (FHintControl=nil) then
|
if not FShowHint or (FHintControl=nil) then
|
||||||
Exit;
|
Exit;
|
||||||
@ -671,8 +677,13 @@ begin
|
|||||||
or (not HintInfo.HintWindowClass.InheritsFrom(THintWindow)) then
|
or (not HintInfo.HintWindowClass.InheritsFrom(THintWindow)) then
|
||||||
HintInfo.HintWindowClass := HintWindowClass;
|
HintInfo.HintWindowClass := HintWindowClass;
|
||||||
|
|
||||||
if CanShow and Assigned(FOnShowHint) then
|
i:=FApplicationHandlers[ahtShowHint].Count;
|
||||||
|
if CanShow
|
||||||
|
and (Assigned(FOnShowHint) or (i>0)) then begin
|
||||||
FOnShowHint(HintInfo.HintStr, CanShow, HintInfo);
|
FOnShowHint(HintInfo.HintStr, CanShow, HintInfo);
|
||||||
|
while FApplicationHandlers[ahtShowHint].NextDownIndex(i) do
|
||||||
|
TShowHintEvent(FApplicationHandlers[ahtShowHint][i])(HintInfo.HintStr, CanShow, HintInfo);
|
||||||
|
end;
|
||||||
if CanShow and (FHintControl <> nil) and (HintInfo.HintStr <> '') then
|
if CanShow and (FHintControl <> nil) and (HintInfo.HintStr <> '') then
|
||||||
begin
|
begin
|
||||||
// create hint window
|
// create hint window
|
||||||
@ -719,7 +730,7 @@ begin
|
|||||||
//debugln('TApplication.ShowHintWindow B HintWinRect=',dbgs(HintWinRect),' HintStr="',DbgStr(HintInfo.HintStr),'"');
|
//debugln('TApplication.ShowHintWindow B HintWinRect=',dbgs(HintWinRect),' HintStr="',DbgStr(HintInfo.HintStr),'"');
|
||||||
FHintWindow.ActivateHint(HintWinRect,HintInfo.HintStr);
|
FHintWindow.ActivateHint(HintWinRect,HintInfo.HintStr);
|
||||||
// start hide timer
|
// start hide timer
|
||||||
StartHintTimer(HintHidePause,ahtHideHint);
|
StartHintTimer(HintHidePause,ahttHideHint);
|
||||||
end else
|
end else
|
||||||
HideHint;
|
HideHint;
|
||||||
|
|
||||||
@ -766,7 +777,7 @@ begin
|
|||||||
OldHintTimerType := FHintTimerType;
|
OldHintTimerType := FHintTimerType;
|
||||||
StopHintTimer;
|
StopHintTimer;
|
||||||
case OldHintTimerType of
|
case OldHintTimerType of
|
||||||
ahtShowHint:
|
ahttShowHint:
|
||||||
begin
|
begin
|
||||||
Info := GetHintInfoAtMouse;
|
Info := GetHintInfoAtMouse;
|
||||||
if Info.ControlHasHint then
|
if Info.ControlHasHint then
|
||||||
@ -893,6 +904,8 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TApplication.HandleException(Sender: TObject);
|
procedure TApplication.HandleException(Sender: TObject);
|
||||||
|
|
||||||
|
var
|
||||||
|
i: LongInt;
|
||||||
begin
|
begin
|
||||||
if Self=nil then exit;
|
if Self=nil then exit;
|
||||||
if AppHandlingException in FFlags then begin
|
if AppHandlingException in FFlags then begin
|
||||||
@ -904,6 +917,7 @@ begin
|
|||||||
Halt;
|
Halt;
|
||||||
end;
|
end;
|
||||||
Include(FFlags,AppHandlingException);
|
Include(FFlags,AppHandlingException);
|
||||||
|
|
||||||
if StopOnException then
|
if StopOnException then
|
||||||
inherited Terminate;
|
inherited Terminate;
|
||||||
if not (AppNoExceptionMessages in FFlags) then begin
|
if not (AppNoExceptionMessages in FFlags) then begin
|
||||||
@ -922,9 +936,13 @@ begin
|
|||||||
// handle the exception
|
// handle the exception
|
||||||
if ExceptObject is Exception then begin
|
if ExceptObject is Exception then begin
|
||||||
if not (ExceptObject is EAbort) then
|
if not (ExceptObject is EAbort) then
|
||||||
if Assigned(OnException) then
|
i:=FApplicationHandlers[ahtUserInput].Count;
|
||||||
OnException(Sender, Exception(ExceptObject))
|
if Assigned(OnException) or (i>0) then begin
|
||||||
else
|
if Assigned(OnException) then
|
||||||
|
OnException(Sender, Exception(ExceptObject));
|
||||||
|
while FApplicationHandlers[ahtException].NextDownIndex(i) do
|
||||||
|
TExceptionEvent(FApplicationHandlers[ahtException][i])(Self,Exception(ExceptObject));
|
||||||
|
end else
|
||||||
ShowException(Exception(ExceptObject));
|
ShowException(Exception(ExceptObject));
|
||||||
end else
|
end else
|
||||||
SysUtils.ShowException(ExceptObject, ExceptAddr);
|
SysUtils.ShowException(ExceptObject, ExceptAddr);
|
||||||
@ -1150,9 +1168,10 @@ procedure TApplication.SetHint(const AValue: string);
|
|||||||
begin
|
begin
|
||||||
if FHint=AValue then exit;
|
if FHint=AValue then exit;
|
||||||
FHint:=AValue;
|
FHint:=AValue;
|
||||||
if Assigned(FOnHint) then
|
if Assigned(FOnHint) or (FApplicationHandlers[ahtHint].Count>0) then begin
|
||||||
FOnHint(Self)
|
FOnHint(Self);
|
||||||
else begin
|
FApplicationHandlers[ahtHint].CallNotifyEvents(Self);
|
||||||
|
end else begin
|
||||||
// Send THintAction
|
// Send THintAction
|
||||||
with TCustomHintAction.Create(Self) do begin
|
with TCustomHintAction.Create(Self) do begin
|
||||||
Hint := FHint;
|
Hint := FHint;
|
||||||
@ -1422,6 +1441,105 @@ begin
|
|||||||
RemoveHandler(ahtDeactivate,TMethod(Handler));
|
RemoveHandler(ahtDeactivate,TMethod(Handler));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.AddOnExceptionHandler(Handler: TExceptionEvent;
|
||||||
|
AsLast: Boolean);
|
||||||
|
begin
|
||||||
|
AddHandler(ahtException,TMethod(Handler),AsLast);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.RemoveOnExceptionHandler(Handler: TExceptionEvent);
|
||||||
|
begin
|
||||||
|
RemoveHandler(ahtException,TMethod(Handler));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.AddOnEndSessionHandler(Handler: TNotifyEvent;
|
||||||
|
AsLast: Boolean);
|
||||||
|
begin
|
||||||
|
AddHandler(ahtEndSession,TMethod(Handler),AsLast);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.RemoveOnEndSessionHandler(Handler: TNotifyEvent);
|
||||||
|
begin
|
||||||
|
RemoveHandler(ahtEndSession,TMethod(Handler));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.AddOnQueryEndSessionHandler(
|
||||||
|
Handler: TQueryEndSessionEvent; AsLast: Boolean);
|
||||||
|
begin
|
||||||
|
AddHandler(ahtQueryEndSession,TMethod(Handler),AsLast);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.RemoveOnQueryEndSessionHandler(
|
||||||
|
Handler: TQueryEndSessionEvent);
|
||||||
|
begin
|
||||||
|
RemoveHandler(ahtQueryEndSession,TMethod(Handler));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.AddOnMinimizeHandler(Handler: TNotifyEvent;
|
||||||
|
AsLast: Boolean);
|
||||||
|
begin
|
||||||
|
AddHandler(ahtMinimize,TMethod(Handler),AsLast);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.RemoveOnMinimizeHandler(Handler: TNotifyEvent);
|
||||||
|
begin
|
||||||
|
RemoveHandler(ahtMinimize,TMethod(Handler));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.AddOnRestoreHandler(Handler: TNotifyEvent;
|
||||||
|
AsLast: Boolean);
|
||||||
|
begin
|
||||||
|
AddHandler(ahtRestore,TMethod(Handler),AsLast);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.RemoveOnRestoreHandler(Handler: TNotifyEvent);
|
||||||
|
begin
|
||||||
|
RemoveHandler(ahtRestore,TMethod(Handler));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.AddOnDropFilesHandler(Handler: TDropFilesEvent;
|
||||||
|
AsLast: Boolean);
|
||||||
|
begin
|
||||||
|
AddHandler(ahtDropFiles,TMethod(Handler),AsLast);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.RemoveOnDropFilesHandler(Handler: TDropFilesEvent);
|
||||||
|
begin
|
||||||
|
RemoveHandler(ahtDropFiles,TMethod(Handler));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.AddOnHelpHandler(Handler: THelpEvent; AsLast: Boolean);
|
||||||
|
begin
|
||||||
|
AddHandler(ahtHelp,TMethod(Handler),AsLast);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.RemoveOnHelpHandler(Handler: THelpEvent);
|
||||||
|
begin
|
||||||
|
RemoveHandler(ahtHelp,TMethod(Handler));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.AddOnHintHandler(Handler: TNotifyEvent; AsLast: Boolean
|
||||||
|
);
|
||||||
|
begin
|
||||||
|
AddHandler(ahtHint,TMethod(Handler),AsLast);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.RemoveOnHintHandler(Handler: TNotifyEvent);
|
||||||
|
begin
|
||||||
|
RemoveHandler(ahtHint,TMethod(Handler));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.AddOnShowHintHandler(Handler: TShowHintEvent;
|
||||||
|
AsLast: Boolean);
|
||||||
|
begin
|
||||||
|
AddHandler(ahtShowHint,TMethod(Handler),AsLast);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.RemoveOnShowHintHandler(Handler: TShowHintEvent);
|
||||||
|
begin
|
||||||
|
RemoveHandler(ahtShowHint,TMethod(Handler));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TApplication.RemoveAllHandlersOfObject(AnObject: TObject);
|
procedure TApplication.RemoveAllHandlersOfObject(AnObject: TObject);
|
||||||
var
|
var
|
||||||
HandlerType: TApplicationHandlerType;
|
HandlerType: TApplicationHandlerType;
|
||||||
@ -1437,14 +1555,20 @@ end;
|
|||||||
procedure TApplication.IntfEndSession;
|
procedure TApplication.IntfEndSession;
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnEndSession) then FOnEndSession(Self);
|
if Assigned(FOnEndSession) then FOnEndSession(Self);
|
||||||
|
FApplicationHandlers[ahtEndSession].CallNotifyEvents(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
procedure TApplication.IntfQueryEndSession(var Cancel : Boolean);
|
procedure TApplication.IntfQueryEndSession(var Cancel : Boolean);
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TApplication.IntfQueryEndSession(var Cancel : Boolean);
|
procedure TApplication.IntfQueryEndSession(var Cancel : Boolean);
|
||||||
|
var
|
||||||
|
i: LongInt;
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnQueryEndSession) then FOnQueryEndSession(Cancel);
|
if Assigned(FOnQueryEndSession) then FOnQueryEndSession(Cancel);
|
||||||
|
i:=FApplicationHandlers[ahtQueryEndSession].Count;
|
||||||
|
while FApplicationHandlers[ahtQueryEndSession].NextDownIndex(i) do
|
||||||
|
TQueryEndSessionEvent(FApplicationHandlers[ahtQueryEndSession][i])(Cancel);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -1453,6 +1577,7 @@ end;
|
|||||||
procedure TApplication.IntfAppMinimize;
|
procedure TApplication.IntfAppMinimize;
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnMinimize) then FOnMinimize(Self);
|
if Assigned(FOnMinimize) then FOnMinimize(Self);
|
||||||
|
FApplicationHandlers[ahtMinimize].CallNotifyEvents(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -1461,6 +1586,7 @@ end;
|
|||||||
procedure TApplication.IntfAppRestore;
|
procedure TApplication.IntfAppRestore;
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnRestore) then FOnRestore(Self);
|
if Assigned(FOnRestore) then FOnRestore(Self);
|
||||||
|
FApplicationHandlers[ahtRestore].CallNotifyEvents(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -1471,8 +1597,13 @@ end;
|
|||||||
This function is called by the interface.
|
This function is called by the interface.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TApplication.IntfDropFiles(const FileNames: array of String);
|
procedure TApplication.IntfDropFiles(const FileNames: array of String);
|
||||||
|
var
|
||||||
|
i: LongInt;
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnDropFiles) then FOnDropFiles(Self, FileNames);
|
if Assigned(FOnDropFiles) then FOnDropFiles(Self, FileNames);
|
||||||
|
i:=FApplicationHandlers[ahtDropFiles].Count;
|
||||||
|
while FApplicationHandlers[ahtDropFiles].NextDownIndex(i) do
|
||||||
|
TDropFilesEvent(FApplicationHandlers[ahtDropFiles][i])(Self,Filenames);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
@ -107,107 +107,167 @@ end;
|
|||||||
|
|
||||||
Procedure TApplicationProperties.SetOnException(Const AValue : TExceptionEvent);
|
Procedure TApplicationProperties.SetOnException(Const AValue : TExceptionEvent);
|
||||||
begin
|
begin
|
||||||
|
if (TMethod(FOnException).Data=TMethod(AValue).Data)
|
||||||
|
and (TMethod(FOnException).Code=TMethod(AValue).Code) then exit;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
|
and Assigned(FOnException) then
|
||||||
|
Application.RemoveOnExceptionHandler(FOnException);
|
||||||
FOnException := AValue;
|
FOnException := AValue;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
If not (csDesigning in ComponentState) then
|
and Assigned(FOnException) then
|
||||||
Application.OnException := AValue;
|
Application.AddOnExceptionHandler(FOnException);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TApplicationProperties.SetOnIdle(Const AValue : TIdleEvent);
|
Procedure TApplicationProperties.SetOnIdle(Const AValue : TIdleEvent);
|
||||||
begin
|
begin
|
||||||
|
if (TMethod(FOnIdle).Data=TMethod(AValue).Data)
|
||||||
|
and (TMethod(FOnIdle).Code=TMethod(AValue).Code) then exit;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
|
and Assigned(FOnIdle) then
|
||||||
|
Application.RemoveOnIdleHandler(FOnIdle);
|
||||||
FOnIdle := AValue;
|
FOnIdle := AValue;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
If not (csDesigning in ComponentState) then
|
and Assigned(FOnIdle) then
|
||||||
Application.OnIdle := AValue;
|
Application.AddOnIdleHandler(FOnIdle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TApplicationProperties.SetOnIdleEnd(Const AValue : TNotifyEvent);
|
Procedure TApplicationProperties.SetOnIdleEnd(Const AValue : TNotifyEvent);
|
||||||
begin
|
begin
|
||||||
|
if (TMethod(FOnIdleEnd).Data=TMethod(AValue).Data)
|
||||||
|
and (TMethod(FOnIdleEnd).Code=TMethod(AValue).Code) then exit;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
|
and Assigned(FOnIdleEnd) then
|
||||||
|
Application.RemoveOnIdleEndHandler(FOnIdleEnd);
|
||||||
FOnIdleEnd := AValue;
|
FOnIdleEnd := AValue;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
If not (csDesigning in ComponentState) then
|
and Assigned(FOnIdleEnd) then
|
||||||
Application.OnIdleEnd := AValue;
|
Application.AddOnIdleEndHandler(FOnIdleEnd);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure TApplicationProperties.SetOnEndSession(Const AValue : TNotifyEvent);
|
Procedure TApplicationProperties.SetOnEndSession(Const AValue : TNotifyEvent);
|
||||||
begin
|
begin
|
||||||
|
if (TMethod(FOnEndSession).Data=TMethod(AValue).Data)
|
||||||
|
and (TMethod(FOnEndSession).Code=TMethod(AValue).Code) then exit;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
|
and Assigned(FOnEndSession) then
|
||||||
|
Application.RemoveOnEndSessionHandler(FOnEndSession);
|
||||||
FOnEndSession := AValue;
|
FOnEndSession := AValue;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
If not (csDesigning in ComponentState) then
|
and Assigned(FOnEndSession) then
|
||||||
Application.OnEndSession := AValue;
|
Application.AddOnEndSessionHandler(FOnEndSession);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure TApplicationProperties.SetOnQueryEndSession(Const AValue : TQueryEndSessionEvent);
|
Procedure TApplicationProperties.SetOnQueryEndSession(Const AValue : TQueryEndSessionEvent);
|
||||||
begin
|
begin
|
||||||
|
if (TMethod(FOnQueryEndSession).Data=TMethod(AValue).Data)
|
||||||
|
and (TMethod(FOnQueryEndSession).Code=TMethod(AValue).Code) then exit;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
|
and Assigned(FOnQueryEndSession) then
|
||||||
|
Application.RemoveOnQueryEndSessionHandler(FOnQueryEndSession);
|
||||||
FOnQueryEndSession := AValue;
|
FOnQueryEndSession := AValue;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
If not (csDesigning in ComponentState) then
|
and Assigned(FOnQueryEndSession) then
|
||||||
Application.OnQueryEndSession := AValue;
|
Application.AddOnQueryEndSessionHandler(FOnQueryEndSession);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TApplicationProperties.SetOnMinimize(const AValue: TNotifyEvent);
|
procedure TApplicationProperties.SetOnMinimize(const AValue: TNotifyEvent);
|
||||||
begin
|
begin
|
||||||
|
if (TMethod(FOnMinimize).Data=TMethod(AValue).Data)
|
||||||
|
and (TMethod(FOnMinimize).Code=TMethod(AValue).Code) then exit;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
|
and Assigned(FOnMinimize) then
|
||||||
|
Application.RemoveOnMinimizeHandler(FOnMinimize);
|
||||||
FOnMinimize := AValue;
|
FOnMinimize := AValue;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
If not (csDesigning in ComponentState) then
|
and Assigned(FOnMinimize) then
|
||||||
Application.OnMinimize := AValue;
|
Application.AddOnMinimizeHandler(FOnMinimize);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TApplicationProperties.SetOnRestore(const AValue: TNotifyEvent);
|
procedure TApplicationProperties.SetOnRestore(const AValue: TNotifyEvent);
|
||||||
begin
|
begin
|
||||||
|
if (TMethod(FOnRestore).Data=TMethod(AValue).Data)
|
||||||
|
and (TMethod(FOnRestore).Code=TMethod(AValue).Code) then exit;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
|
and Assigned(FOnRestore) then
|
||||||
|
Application.RemoveOnRestoreHandler(FOnRestore);
|
||||||
FOnRestore := AValue;
|
FOnRestore := AValue;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
If not (csDesigning in ComponentState) then
|
and Assigned(FOnRestore) then
|
||||||
Application.OnRestore := AValue;
|
Application.AddOnRestoreHandler(FOnRestore);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TApplicationProperties.SetOnDropFiles(const AValue: TDropFilesEvent);
|
Procedure TApplicationProperties.SetOnDropFiles(const AValue: TDropFilesEvent);
|
||||||
begin
|
begin
|
||||||
|
if (TMethod(FOnDropFiles).Data=TMethod(AValue).Data)
|
||||||
|
and (TMethod(FOnDropFiles).Code=TMethod(AValue).Code) then exit;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
|
and Assigned(FOnDropFiles) then
|
||||||
|
Application.RemoveOnDropFilesHandler(FOnDropFiles);
|
||||||
FOnDropFiles := AValue;
|
FOnDropFiles := AValue;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
If not (csDesigning in ComponentState) then
|
and Assigned(FOnDropFiles) then
|
||||||
Application.OnDropFiles := AValue;
|
Application.AddOnDropFilesHandler(FOnDropFiles);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TApplicationProperties.SetOnHelp(Const AValue : THelpEvent);
|
Procedure TApplicationProperties.SetOnHelp(Const AValue : THelpEvent);
|
||||||
begin
|
begin
|
||||||
|
if (TMethod(FOnHelp).Data=TMethod(AValue).Data)
|
||||||
|
and (TMethod(FOnHelp).Code=TMethod(AValue).Code) then exit;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
|
and Assigned(FOnHelp) then
|
||||||
|
Application.RemoveOnHelpHandler(FOnHelp);
|
||||||
FOnHelp := AValue;
|
FOnHelp := AValue;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
If not (csDesigning in ComponentState) then
|
and Assigned(FOnHelp) then
|
||||||
Application.OnHelp := AValue;
|
Application.AddOnHelpHandler(FOnHelp);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TApplicationProperties.SetOnHint(Const AValue : TNotifyEvent);
|
Procedure TApplicationProperties.SetOnHint(Const AValue : TNotifyEvent);
|
||||||
begin
|
begin
|
||||||
|
if (TMethod(FOnHint).Data=TMethod(AValue).Data)
|
||||||
|
and (TMethod(FOnHint).Code=TMethod(AValue).Code) then exit;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
|
and Assigned(FOnHint) then
|
||||||
|
Application.RemoveOnHintHandler(FOnHint);
|
||||||
FOnHint := AValue;
|
FOnHint := AValue;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
If not (csDesigning in ComponentState) then
|
and Assigned(FOnHint) then
|
||||||
Application.OnHint := AValue;
|
Application.AddOnHintHandler(FOnHint);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TApplicationProperties.SetOnShowHint(Const AValue : TShowHintEvent);
|
Procedure TApplicationProperties.SetOnShowHint(Const AValue : TShowHintEvent);
|
||||||
begin
|
begin
|
||||||
|
if (TMethod(FOnShowHint).Data=TMethod(AValue).Data)
|
||||||
|
and (TMethod(FOnShowHint).Code=TMethod(AValue).Code) then exit;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
|
and Assigned(FOnShowHint) then
|
||||||
|
Application.RemoveOnShowHintHandler(FOnShowHint);
|
||||||
FOnShowHint := AValue;
|
FOnShowHint := AValue;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
If not (csDesigning in ComponentState) then
|
and Assigned(FOnShowHint) then
|
||||||
Application.OnShowHint := AValue;
|
Application.AddOnShowHintHandler(FOnShowHint);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TApplicationProperties.SetOnUserInput(Const AValue : TOnUserInputEvent);
|
Procedure TApplicationProperties.SetOnUserInput(Const AValue : TOnUserInputEvent);
|
||||||
begin
|
begin
|
||||||
|
if (TMethod(FOnUserInput).Data=TMethod(AValue).Data)
|
||||||
|
and (TMethod(FOnUserInput).Code=TMethod(AValue).Code) then exit;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
|
and Assigned(FOnUserInput) then
|
||||||
|
Application.RemoveOnUserInputHandler(FOnUserInput);
|
||||||
FOnUserInput := AValue;
|
FOnUserInput := AValue;
|
||||||
|
if not (csDesigning in ComponentState)
|
||||||
If not (csDesigning in ComponentState) then
|
and Assigned(FOnUserInput) then
|
||||||
Application.OnUserInput := AValue;
|
Application.AddOnUserInputHandler(FOnUserInput);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TApplicationProperties.Create(AOwner: TComponent);
|
constructor TApplicationProperties.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
|
|
||||||
If (csDesigning in ComponentState) then begin
|
if (csDesigning in ComponentState) then begin
|
||||||
FCaptureExceptions:=true;
|
FCaptureExceptions:=true;
|
||||||
FHintColor := DefHintColor;
|
FHintColor := DefHintColor;
|
||||||
FHintPause := DefHintPause;
|
FHintPause := DefHintPause;
|
||||||
@ -243,27 +303,8 @@ end;
|
|||||||
|
|
||||||
destructor TApplicationProperties.Destroy;
|
destructor TApplicationProperties.Destroy;
|
||||||
begin
|
begin
|
||||||
If not (csDesigning in ComponentState) then begin
|
If not (csDesigning in ComponentState) then
|
||||||
if Application.OnException=FOnException then
|
Application.RemoveAllHandlersOfObject(Self);
|
||||||
Application.OnException:=nil;
|
|
||||||
if Application.OnIdle=FOnIdle then
|
|
||||||
Application.OnIdle:=nil;
|
|
||||||
if Application.OnIdleEnd=FOnIdleEnd then
|
|
||||||
Application.OnIdleEnd:=nil;
|
|
||||||
if Application.OnHelp=FOnHelp then
|
|
||||||
Application.OnHelp:=nil;
|
|
||||||
if Application.OnHint=FOnHint then
|
|
||||||
Application.OnHint:=nil;
|
|
||||||
if Application.OnShowHint=FOnShowHint then
|
|
||||||
Application.OnShowHint:=nil;
|
|
||||||
if Application.OnUserInput=FOnUserInput then
|
|
||||||
Application.OnUserInput:=nil;
|
|
||||||
if Application.OnEndSession=FOnEndSession then
|
|
||||||
Application.OnEndSession:=nil;
|
|
||||||
if Application.OnQueryEndSession=FOnQueryEndSession then
|
|
||||||
Application.OnQueryEndSession:=nil;
|
|
||||||
end;
|
|
||||||
|
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user