mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-31 22:20:24 +02:00
added Application.OnEndSession and Application.OnQueryEndSession from Boguslaw Brandys
git-svn-id: trunk@8941 -
This commit is contained in:
parent
0ee592fa18
commit
1305af6d49
14
lcl/forms.pp
14
lcl/forms.pp
@ -799,6 +799,7 @@ type
|
||||
|
||||
{ TApplication }
|
||||
|
||||
TQueryEndSessionEvent = procedure (var Cancel : Boolean) of object;
|
||||
TExceptionEvent = procedure (Sender: TObject; E: Exception) of object;
|
||||
TIdleEvent = procedure (Sender: TObject; var Done: Boolean) of object;
|
||||
TOnUserInputEvent = procedure(Sender: TObject; Msg: Cardinal) of object;
|
||||
@ -906,6 +907,8 @@ type
|
||||
FOnHint: TNotifyEvent;
|
||||
FOnIdle: TIdleEvent;
|
||||
FOnIdleEnd: TNotifyEvent;
|
||||
FOnEndSession : TNotifyEvent;
|
||||
FOnQueryEndSession : TQueryEndSessionEvent;
|
||||
FOnShortcut: TShortcutEvent;
|
||||
FOnShowHint: TShowHintEvent;
|
||||
FOnUserInput: TOnUserInputEvent;
|
||||
@ -1016,6 +1019,8 @@ type
|
||||
procedure RemoveAllHandlersOfObject(AnObject: TObject); virtual;
|
||||
procedure DoBeforeMouseMessage(CurMouseControl: TControl);
|
||||
function IsShortcut(var Message: TLMKey): boolean;
|
||||
procedure IntfQueryEndSession(var Cancel : Boolean);
|
||||
procedure IntfEndSession;
|
||||
public
|
||||
procedure DoEscapeKey(AControl: TWinControl; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
@ -1042,6 +1047,8 @@ type
|
||||
property OnDeactivate: TNotifyEvent read FOnDeactivate write FOnDeactivate;
|
||||
property OnIdle: TIdleEvent read FOnIdle write FOnIdle;
|
||||
property OnIdleEnd: TNotifyEvent read FOnIdleEnd write FOnIdleEnd;
|
||||
property OnEndSession: TNotifyEvent read FOnEndSession write FOnEndSession;
|
||||
property OnQueryEndSession: TQueryEndSessionEvent read FOnQueryEndSession write FOnQueryEndSession;
|
||||
property OnHelp: THelpEvent read FOnHelp write FOnHelp;
|
||||
property OnHint: TNotifyEvent read FOnHint write FOnHint;
|
||||
property OnShortcut: TShortcutEvent read FOnShortcut write FOnShortcut;
|
||||
@ -1077,6 +1084,8 @@ type
|
||||
FOnHint: TNotifyEvent;
|
||||
FOnShowHint: TShowHintEvent;
|
||||
FOnUserInput: TOnUserInputEvent;
|
||||
FOnEndSession : TNotifyEvent;
|
||||
FOnQueryEndSession : TQueryEndSessionEvent;
|
||||
procedure SetShowMainForm(const AValue: Boolean);
|
||||
protected
|
||||
Procedure SetCaptureExceptions(Const AValue : boolean);
|
||||
@ -1093,6 +1102,8 @@ type
|
||||
Procedure SetOnException(Const AValue : TExceptionEvent);
|
||||
Procedure SetOnIdle(Const AValue : TIdleEvent);
|
||||
Procedure SetOnIdleEnd(Const AValue : TNotifyEvent);
|
||||
Procedure SetOnEndSession(Const AValue : TNotifyEvent);
|
||||
Procedure SetOnQueryEndSession(Const AValue : TQueryEndSessionEvent);
|
||||
Procedure SetOnHelp(Const AValue : THelpEvent);
|
||||
Procedure SetOnHint(Const AValue : TNotifyEvent);
|
||||
Procedure SetOnShowHint(Const AValue : TShowHintEvent);
|
||||
@ -1116,6 +1127,8 @@ type
|
||||
property OnException: TExceptionEvent read FOnException write SetOnException;
|
||||
property OnIdle: TIdleEvent read FOnIdle write SetOnIdle;
|
||||
property OnIdleEnd: TNotifyEvent read FOnIdleEnd write SetOnIdleEnd;
|
||||
property OnEndSession : TNotifyEvent read FOnEndSession write SetOnEndSession;
|
||||
property OnQueryEndSession : TQueryEndSessionEvent read FOnQueryEndSession write SetOnQueryEndSession;
|
||||
property OnHelp: THelpEvent read FOnHelp write SetOnHelp;
|
||||
property OnHint: TNotifyEvent read FOnHint write SetOnHint;
|
||||
property OnShowHint: TShowHintEvent read FOnShowHint write SetOnShowHint;
|
||||
@ -1226,6 +1239,7 @@ function FindRootDesigner(AComponent: TComponent): TIDesigner;
|
||||
function IsAccel(VK: word; const Str: string): Boolean;
|
||||
procedure NotifyApplicationUserInput(Msg: Cardinal);
|
||||
|
||||
|
||||
function InitResourceComponent(Instance: TComponent;
|
||||
RootAncestor: TClass):Boolean;
|
||||
|
||||
|
@ -1377,6 +1377,27 @@ begin
|
||||
FApplicationHandlers[HandlerType].RemoveAllMethodsOfObject(AnObject);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TApplication.IntfEndSession();
|
||||
------------------------------------------------------------------------------}
|
||||
|
||||
procedure TApplication.IntfEndSession();
|
||||
begin
|
||||
if Assigned(FOnEndSession) then FOnEndSession(Self);
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TApplication.IntfQueryEndSession(var Cancel : Boolean);
|
||||
------------------------------------------------------------------------------}
|
||||
|
||||
procedure TApplication.IntfQueryEndSession(var Cancel : Boolean);
|
||||
begin
|
||||
if Assigned(FOnQueryEndSession) then FOnQueryEndSession(Cancel);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TApplication.DoBeforeMouseMessage(CurMouseControl: TControl);
|
||||
------------------------------------------------------------------------------}
|
||||
|
@ -129,6 +129,25 @@ begin
|
||||
Application.OnIdleEnd := AValue;
|
||||
end;
|
||||
|
||||
|
||||
Procedure TApplicationProperties.SetOnEndSession(Const AValue : TNotifyEvent);
|
||||
begin
|
||||
FOnEndSession := AValue;
|
||||
|
||||
If not (csDesigning in ComponentState) then
|
||||
Application.OnEndSession := AValue;
|
||||
end;
|
||||
|
||||
|
||||
Procedure TApplicationProperties.SetOnQueryEndSession(Const AValue : TQueryEndSessionEvent);
|
||||
begin
|
||||
FOnQueryEndSession := AValue;
|
||||
|
||||
If not (csDesigning in ComponentState) then
|
||||
Application.OnQueryEndSession := AValue;
|
||||
end;
|
||||
|
||||
|
||||
Procedure TApplicationProperties.SetOnHelp(Const AValue : THelpEvent);
|
||||
begin
|
||||
FOnHelp := AValue;
|
||||
@ -196,6 +215,8 @@ begin
|
||||
FOnHint := nil;
|
||||
FOnShowHint := nil;
|
||||
FOnUserInput := nil;
|
||||
FOnEndSession := nil;
|
||||
FOnQueryEndSession := nil;
|
||||
end;
|
||||
|
||||
// included by forms.pp
|
||||
|
@ -211,7 +211,8 @@ Var
|
||||
LMMove: TLMMove; // used by WM_MOVE
|
||||
LMNotify: TLMNotify; // used by WM_NOTIFY
|
||||
DrawListItemStruct: TDrawListItemStruct; //used by WM_DRAWITEM
|
||||
|
||||
CancelEndSession : Boolean;//use by WM_QUERYENDSESSION
|
||||
|
||||
procedure ShowHideTabPage(NotebookHandle: HWnd; Showing: boolean);
|
||||
var
|
||||
NoteBook: TCustomNotebook;
|
||||
@ -1638,6 +1639,35 @@ Begin
|
||||
// winxp theme changed, recheck whether themes are enabled
|
||||
TWin32WidgetSet(WidgetSet).UpdateThemesActive;
|
||||
end;
|
||||
|
||||
WM_ENDSESSION:
|
||||
begin
|
||||
if (Application<>nil) and (TWin32WidgetSet(WidgetSet).AppHandle=Window) and
|
||||
(WParam>0) and (LParam=0) then
|
||||
begin
|
||||
LMessage.Msg := LM_NULL; // no need to go through delivermessage
|
||||
WinProcess := false;
|
||||
Application.IntfEndSession();
|
||||
LMessage.Result := 0;
|
||||
end;
|
||||
end;
|
||||
|
||||
WM_QUERYENDSESSION:
|
||||
begin
|
||||
if (Application<>nil) and (TWin32WidgetSet(WidgetSet).AppHandle=Window) and
|
||||
(LParam=0) then
|
||||
begin
|
||||
LMessage.Msg := LM_NULL; // no need to go through delivermessage
|
||||
WinProcess := false;
|
||||
CancelEndSession := false;
|
||||
Application.IntfQueryEndSession(CancelEndSession);
|
||||
if CancelEndSession
|
||||
then LMessage.Result := 0
|
||||
else LMessage.Result := 1;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{$ifdef PassWin32MessagesToLCL}
|
||||
else
|
||||
// pass along user defined messages
|
||||
@ -1648,7 +1678,8 @@ Begin
|
||||
LMessage.LParam := LParam;
|
||||
WinProcess := false;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
{$endif}
|
||||
End;
|
||||
|
||||
If WinProcess Then
|
||||
|
Loading…
Reference in New Issue
Block a user