mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 19:19:24 +02:00
LCL + win32 interface: implemented Application.Restore and Application.Minimize + events (bug #1391) from Boguslaw Brandys
git-svn-id: trunk@10265 -
This commit is contained in:
parent
0999d7c7a8
commit
d3748b96c4
13
lcl/forms.pp
13
lcl/forms.pp
@ -907,6 +907,8 @@ type
|
|||||||
FOnIdleEnd: TNotifyEvent;
|
FOnIdleEnd: TNotifyEvent;
|
||||||
FOnEndSession : TNotifyEvent;
|
FOnEndSession : TNotifyEvent;
|
||||||
FOnQueryEndSession : TQueryEndSessionEvent;
|
FOnQueryEndSession : TQueryEndSessionEvent;
|
||||||
|
FOnMinimize: TNotifyEvent;
|
||||||
|
FOnRestore: TNotifyEvent;
|
||||||
FOnShortcut: TShortcutEvent;
|
FOnShortcut: TShortcutEvent;
|
||||||
FOnShowHint: TShowHintEvent;
|
FOnShowHint: TShowHintEvent;
|
||||||
FOnUserInput: TOnUserInputEvent;
|
FOnUserInput: TOnUserInputEvent;
|
||||||
@ -991,6 +993,7 @@ type
|
|||||||
procedure Initialize; override;
|
procedure Initialize; override;
|
||||||
function MessageBox(Text, Caption: PChar; Flags: Longint): Integer;
|
function MessageBox(Text, Caption: PChar; Flags: Longint): Integer;
|
||||||
procedure Minimize;
|
procedure Minimize;
|
||||||
|
procedure Restore;
|
||||||
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
||||||
Procedure ProcessMessages;
|
Procedure ProcessMessages;
|
||||||
Procedure Idle(Wait: Boolean);
|
Procedure Idle(Wait: Boolean);
|
||||||
@ -1027,6 +1030,8 @@ type
|
|||||||
function IsShortcut(var Message: TLMKey): boolean;
|
function IsShortcut(var Message: TLMKey): boolean;
|
||||||
procedure IntfQueryEndSession(var Cancel : Boolean);
|
procedure IntfQueryEndSession(var Cancel : Boolean);
|
||||||
procedure IntfEndSession;
|
procedure IntfEndSession;
|
||||||
|
procedure IntfAppMinimize;
|
||||||
|
procedure IntfAppRestore;
|
||||||
public
|
public
|
||||||
procedure DoEscapeKey(AControl: TWinControl; var Key: Word;
|
procedure DoEscapeKey(AControl: TWinControl; var Key: Word;
|
||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
@ -1056,6 +1061,8 @@ type
|
|||||||
property OnIdleEnd: TNotifyEvent read FOnIdleEnd write FOnIdleEnd;
|
property OnIdleEnd: TNotifyEvent read FOnIdleEnd write FOnIdleEnd;
|
||||||
property OnEndSession: TNotifyEvent read FOnEndSession write FOnEndSession;
|
property OnEndSession: TNotifyEvent read FOnEndSession write FOnEndSession;
|
||||||
property OnQueryEndSession: TQueryEndSessionEvent read FOnQueryEndSession write FOnQueryEndSession;
|
property OnQueryEndSession: TQueryEndSessionEvent read FOnQueryEndSession write FOnQueryEndSession;
|
||||||
|
property OnMinimize: TNotifyEvent read FOnMinimize write FOnMinimize;
|
||||||
|
property OnRestore: TNotifyEvent read FOnRestore write FOnRestore;
|
||||||
property OnHelp: THelpEvent read FOnHelp write FOnHelp;
|
property OnHelp: THelpEvent read FOnHelp write FOnHelp;
|
||||||
property OnHint: TNotifyEvent read FOnHint write FOnHint;
|
property OnHint: TNotifyEvent read FOnHint write FOnHint;
|
||||||
property OnShortcut: TShortcutEvent read FOnShortcut write FOnShortcut;
|
property OnShortcut: TShortcutEvent read FOnShortcut write FOnShortcut;
|
||||||
@ -1094,6 +1101,8 @@ type
|
|||||||
FOnUserInput: TOnUserInputEvent;
|
FOnUserInput: TOnUserInputEvent;
|
||||||
FOnEndSession : TNotifyEvent;
|
FOnEndSession : TNotifyEvent;
|
||||||
FOnQueryEndSession : TQueryEndSessionEvent;
|
FOnQueryEndSession : TQueryEndSessionEvent;
|
||||||
|
FOnMinimize : TNotifyEvent;
|
||||||
|
FOnRestore : TNotifyEvent;
|
||||||
procedure SetShowMainForm(const AValue: Boolean);
|
procedure SetShowMainForm(const AValue: Boolean);
|
||||||
protected
|
protected
|
||||||
Procedure SetCaptureExceptions(Const AValue : boolean);
|
Procedure SetCaptureExceptions(Const AValue : boolean);
|
||||||
@ -1112,6 +1121,8 @@ type
|
|||||||
Procedure SetOnIdleEnd(Const AValue : TNotifyEvent);
|
Procedure SetOnIdleEnd(Const AValue : TNotifyEvent);
|
||||||
Procedure SetOnEndSession(Const AValue : TNotifyEvent);
|
Procedure SetOnEndSession(Const AValue : TNotifyEvent);
|
||||||
Procedure SetOnQueryEndSession(Const AValue : TQueryEndSessionEvent);
|
Procedure SetOnQueryEndSession(Const AValue : TQueryEndSessionEvent);
|
||||||
|
Procedure SetOnMinimize(Const AValue : TNotifyEvent);
|
||||||
|
Procedure SetOnRestore(Const AValue : TNotifyEvent);
|
||||||
Procedure SetOnHelp(Const AValue : THelpEvent);
|
Procedure SetOnHelp(Const AValue : THelpEvent);
|
||||||
Procedure SetOnHint(Const AValue : TNotifyEvent);
|
Procedure SetOnHint(Const AValue : TNotifyEvent);
|
||||||
Procedure SetOnShowHint(Const AValue : TShowHintEvent);
|
Procedure SetOnShowHint(Const AValue : TShowHintEvent);
|
||||||
@ -1137,6 +1148,8 @@ type
|
|||||||
property OnIdleEnd: TNotifyEvent read FOnIdleEnd write SetOnIdleEnd;
|
property OnIdleEnd: TNotifyEvent read FOnIdleEnd write SetOnIdleEnd;
|
||||||
property OnEndSession : TNotifyEvent read FOnEndSession write SetOnEndSession;
|
property OnEndSession : TNotifyEvent read FOnEndSession write SetOnEndSession;
|
||||||
property OnQueryEndSession : TQueryEndSessionEvent read FOnQueryEndSession write SetOnQueryEndSession;
|
property OnQueryEndSession : TQueryEndSessionEvent read FOnQueryEndSession write SetOnQueryEndSession;
|
||||||
|
property OnMinimize : TNotifyEvent read FOnMinimize write SetOnMinimize;
|
||||||
|
property OnRestore : TNotifyEvent read FOnRestore write SetOnRestore;
|
||||||
property OnHelp: THelpEvent read FOnHelp write SetOnHelp;
|
property OnHelp: THelpEvent read FOnHelp write SetOnHelp;
|
||||||
property OnHint: TNotifyEvent read FOnHint write SetOnHint;
|
property OnHint: TNotifyEvent read FOnHint write SetOnHint;
|
||||||
property OnShowHint: TShowHintEvent read FOnShowHint write SetOnShowHint;
|
property OnShowHint: TShowHintEvent read FOnShowHint write SetOnShowHint;
|
||||||
|
@ -243,6 +243,19 @@ begin
|
|||||||
WidgetSet.AppMinimize;
|
WidgetSet.AppMinimize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TApplication.Restore
|
||||||
|
Params: None
|
||||||
|
Returns: Nothing
|
||||||
|
|
||||||
|
Restore minimized application.
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TApplication.Restore;
|
||||||
|
begin
|
||||||
|
//debugln('TApplication.Restore');
|
||||||
|
WidgetSet.AppRestore;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
TApplication ProcesssMessages "Enter the messageloop and process until empty"
|
TApplication ProcesssMessages "Enter the messageloop and process until empty"
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
@ -1394,6 +1407,24 @@ begin
|
|||||||
if Assigned(FOnQueryEndSession) then FOnQueryEndSession(Cancel);
|
if Assigned(FOnQueryEndSession) then FOnQueryEndSession(Cancel);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
procedure TApplication.IntfAppMinimize;
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TApplication.IntfAppMinimize;
|
||||||
|
begin
|
||||||
|
if Assigned(FOnMinimize) then FOnMinimize(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
procedure TApplication.IntfAppRestore;
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TApplication.IntfAppRestore;
|
||||||
|
begin
|
||||||
|
if Assigned(FOnRestore) then FOnRestore(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
procedure TApplication.DoBeforeMouseMessage(CurMouseControl: TControl);
|
procedure TApplication.DoBeforeMouseMessage(CurMouseControl: TControl);
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
|
@ -147,6 +147,22 @@ begin
|
|||||||
Application.OnQueryEndSession := AValue;
|
Application.OnQueryEndSession := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TApplicationProperties.SetOnMinimize(const AValue: TNotifyEvent);
|
||||||
|
begin
|
||||||
|
FOnMinimize := AValue;
|
||||||
|
|
||||||
|
If not (csDesigning in ComponentState) then
|
||||||
|
Application.OnMinimize := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TApplicationProperties.SetOnRestore(const AValue: TNotifyEvent);
|
||||||
|
begin
|
||||||
|
FOnRestore := AValue;
|
||||||
|
|
||||||
|
If not (csDesigning in ComponentState) then
|
||||||
|
Application.OnRestore := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure TApplicationProperties.SetOnHelp(Const AValue : THelpEvent);
|
Procedure TApplicationProperties.SetOnHelp(Const AValue : THelpEvent);
|
||||||
begin
|
begin
|
||||||
|
@ -65,6 +65,7 @@ type
|
|||||||
procedure AppProcessMessages; virtual; abstract;
|
procedure AppProcessMessages; virtual; abstract;
|
||||||
procedure AppTerminate; virtual; abstract;
|
procedure AppTerminate; virtual; abstract;
|
||||||
procedure AppMinimize; virtual; abstract;
|
procedure AppMinimize; virtual; abstract;
|
||||||
|
procedure AppRestore; virtual; abstract;
|
||||||
procedure AppBringToFront; virtual; abstract;
|
procedure AppBringToFront; virtual; abstract;
|
||||||
procedure AppSetTitle(const ATitle: string); virtual;
|
procedure AppSetTitle(const ATitle: string); virtual;
|
||||||
|
|
||||||
|
@ -733,9 +733,42 @@ Var
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
SC_MINIMIZE:
|
SC_MINIMIZE:
|
||||||
if (Application <> nil) and (Application.MainForm = lWinControl) then
|
begin
|
||||||
Window := TWin32WidgetSet(WidgetSet).AppHandle;
|
if (Application <> nil) and (lWinControl<> nil) and
|
||||||
|
(Application.MainForm = lWinControl) then
|
||||||
|
Window := TWin32WidgetSet(WidgetSet).AppHandle;
|
||||||
|
if Window = TWin32WidgetSet(WidgetSet).AppHandle then
|
||||||
|
begin
|
||||||
|
if (Application <> nil) and (Application.MainForm <> nil) and
|
||||||
|
Application.MainForm.HandleAllocated then
|
||||||
|
begin
|
||||||
|
//DebugLn('SC_MINIMIZE');
|
||||||
|
//LMessage.Msg := LM_NULL;
|
||||||
|
Application.IntfAppMinimize();
|
||||||
|
//LMessage.Result := 0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
SC_RESTORE:
|
||||||
|
begin
|
||||||
|
if (Application <> nil) and (lWinControl<> nil) and
|
||||||
|
(Application.MainForm = lWinControl) then
|
||||||
|
Window := TWin32WidgetSet(WidgetSet).AppHandle;
|
||||||
|
if Window = TWin32WidgetSet(WidgetSet).AppHandle then
|
||||||
|
begin
|
||||||
|
if (Application <> nil) and (Application.MainForm <> nil) and
|
||||||
|
Application.MainForm.HandleAllocated then
|
||||||
|
begin
|
||||||
|
//DebugLn('SC_RESTORE');
|
||||||
|
//LMessage.Msg := LM_NULL;
|
||||||
|
Application.IntfAppRestore();
|
||||||
|
//LMessage.Result := 0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -181,6 +181,7 @@ Type
|
|||||||
{ Initialize the API }
|
{ Initialize the API }
|
||||||
procedure AppInit(var ScreenInfo: TScreenInfo); override;
|
procedure AppInit(var ScreenInfo: TScreenInfo); override;
|
||||||
procedure AppMinimize; override;
|
procedure AppMinimize; override;
|
||||||
|
procedure AppRestore; override;
|
||||||
procedure AppBringToFront; override;
|
procedure AppBringToFront; override;
|
||||||
procedure AppProcessMessages; override;
|
procedure AppProcessMessages; override;
|
||||||
procedure AppWaitMessage; override;
|
procedure AppWaitMessage; override;
|
||||||
|
@ -216,6 +216,19 @@ begin
|
|||||||
Windows.SendMessage(FAppHandle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
|
Windows.SendMessage(FAppHandle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TWin32WidgetSet.AppRestore
|
||||||
|
Params: None
|
||||||
|
Returns: Nothing
|
||||||
|
|
||||||
|
Restore minimized whole application from taskbar
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TWin32WidgetSet.AppRestore;
|
||||||
|
begin
|
||||||
|
Windows.SendMessage(FAppHandle, WM_SYSCOMMAND, SC_RESTORE, 0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TWin32WidgetSet.AppBringToFront
|
Method: TWin32WidgetSet.AppBringToFront
|
||||||
Params: None
|
Params: None
|
||||||
|
Loading…
Reference in New Issue
Block a user