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:
vincents 2006-11-30 13:40:34 +00:00
parent 0999d7c7a8
commit d3748b96c4
7 changed files with 110 additions and 2 deletions

View File

@ -907,6 +907,8 @@ type
FOnIdleEnd: TNotifyEvent;
FOnEndSession : TNotifyEvent;
FOnQueryEndSession : TQueryEndSessionEvent;
FOnMinimize: TNotifyEvent;
FOnRestore: TNotifyEvent;
FOnShortcut: TShortcutEvent;
FOnShowHint: TShowHintEvent;
FOnUserInput: TOnUserInputEvent;
@ -991,6 +993,7 @@ type
procedure Initialize; override;
function MessageBox(Text, Caption: PChar; Flags: Longint): Integer;
procedure Minimize;
procedure Restore;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
Procedure ProcessMessages;
Procedure Idle(Wait: Boolean);
@ -1027,6 +1030,8 @@ type
function IsShortcut(var Message: TLMKey): boolean;
procedure IntfQueryEndSession(var Cancel : Boolean);
procedure IntfEndSession;
procedure IntfAppMinimize;
procedure IntfAppRestore;
public
procedure DoEscapeKey(AControl: TWinControl; var Key: Word;
Shift: TShiftState);
@ -1056,6 +1061,8 @@ type
property OnIdleEnd: TNotifyEvent read FOnIdleEnd write FOnIdleEnd;
property OnEndSession: TNotifyEvent read FOnEndSession write FOnEndSession;
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 OnHint: TNotifyEvent read FOnHint write FOnHint;
property OnShortcut: TShortcutEvent read FOnShortcut write FOnShortcut;
@ -1094,6 +1101,8 @@ type
FOnUserInput: TOnUserInputEvent;
FOnEndSession : TNotifyEvent;
FOnQueryEndSession : TQueryEndSessionEvent;
FOnMinimize : TNotifyEvent;
FOnRestore : TNotifyEvent;
procedure SetShowMainForm(const AValue: Boolean);
protected
Procedure SetCaptureExceptions(Const AValue : boolean);
@ -1112,6 +1121,8 @@ type
Procedure SetOnIdleEnd(Const AValue : TNotifyEvent);
Procedure SetOnEndSession(Const AValue : TNotifyEvent);
Procedure SetOnQueryEndSession(Const AValue : TQueryEndSessionEvent);
Procedure SetOnMinimize(Const AValue : TNotifyEvent);
Procedure SetOnRestore(Const AValue : TNotifyEvent);
Procedure SetOnHelp(Const AValue : THelpEvent);
Procedure SetOnHint(Const AValue : TNotifyEvent);
Procedure SetOnShowHint(Const AValue : TShowHintEvent);
@ -1137,6 +1148,8 @@ type
property OnIdleEnd: TNotifyEvent read FOnIdleEnd write SetOnIdleEnd;
property OnEndSession : TNotifyEvent read FOnEndSession write SetOnEndSession;
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 OnHint: TNotifyEvent read FOnHint write SetOnHint;
property OnShowHint: TShowHintEvent read FOnShowHint write SetOnShowHint;

View File

@ -243,6 +243,19 @@ begin
WidgetSet.AppMinimize;
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"
------------------------------------------------------------------------------}
@ -1394,6 +1407,24 @@ begin
if Assigned(FOnQueryEndSession) then FOnQueryEndSession(Cancel);
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);
------------------------------------------------------------------------------}

View File

@ -147,6 +147,22 @@ begin
Application.OnQueryEndSession := AValue;
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);
begin

View File

@ -65,6 +65,7 @@ type
procedure AppProcessMessages; virtual; abstract;
procedure AppTerminate; virtual; abstract;
procedure AppMinimize; virtual; abstract;
procedure AppRestore; virtual; abstract;
procedure AppBringToFront; virtual; abstract;
procedure AppSetTitle(const ATitle: string); virtual;

View File

@ -733,9 +733,42 @@ Var
end;
end;
end;
SC_MINIMIZE:
if (Application <> nil) and (Application.MainForm = lWinControl) then
Window := TWin32WidgetSet(WidgetSet).AppHandle;
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_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;

View File

@ -181,6 +181,7 @@ Type
{ Initialize the API }
procedure AppInit(var ScreenInfo: TScreenInfo); override;
procedure AppMinimize; override;
procedure AppRestore; override;
procedure AppBringToFront; override;
procedure AppProcessMessages; override;
procedure AppWaitMessage; override;

View File

@ -216,6 +216,19 @@ begin
Windows.SendMessage(FAppHandle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
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
Params: None