Commit 54661a2a authored by Juha Manninen's avatar Juha Manninen
Browse files

LCL: Fix changing TForm's bounds and WindowState etc. Issue #36127, patch from Joeny Ang.

git-svn-id: trunk@63888 -
parent b3cbbc62
......@@ -493,6 +493,7 @@ type
FDelayedEventCtr: Integer;
FDelayedOnChangeBounds, FDelayedOnResize: Boolean;
FIsFirstOnShow, FIsFirstOnActivate: Boolean;
FIsFirstRestore, FWindowStateChanged: Boolean;
function GetClientHandle: HWND;
function GetEffectiveShowInTaskBar: TShowInTaskBar;
function GetMonitor: TMonitor;
......
......@@ -706,7 +706,7 @@ begin
end;
{ call onShow() or onActivate() for the first time,
after first OnResize() and OnChangeBounds() }
if FDelayedOnResize or FDelayedOnChangeBounds then
if (FDelayedOnResize or FDelayedOnChangeBounds) and FActive then
begin
if FIsFirstOnShow then
begin
......@@ -716,18 +716,20 @@ begin
if FIsFirstOnActivate then
begin
FIsFirstOnActivate := False;
if FActive then
Activate;
Activate;
end;
end;
{ delayed onResize() }
if FDelayedOnResize then
inherited DoOnResize;
{ delayed onChangeBounds() }
if FDelayedOnResize or FDelayedOnChangeBounds then
inherited DoOnChangeBounds;
FDelayedOnChangeBounds := False;
FDelayedOnResize := False;
if not (FIsFirstOnShow or FIsFirstOnActivate) then
begin
{ delayed onResize() }
if FDelayedOnResize then
inherited DoOnResize;
{ delayed onChangeBounds() }
if FDelayedOnResize or FDelayedOnChangeBounds then
inherited DoOnChangeBounds;
FDelayedOnChangeBounds := False;
FDelayedOnResize := False;
end;
end;
procedure TCustomForm.WMWindowPosChanged(var Message: TLMWindowPosChanged);
......@@ -1001,6 +1003,7 @@ begin
if FIsFirstOnShow and (WindowState in [wsMaximized, wsFullScreen]) then
Exit;
FIsFirstOnShow := False;
FIsFirstRestore := WindowState in [wsMaximized, wsFullScreen];
if Assigned(FOnShow) then FOnShow(Self);
end;
......@@ -1148,8 +1151,28 @@ begin
if (OldState = wsMinimized) and (Application.MainForm = Self) and
(WidgetSet.GetLCLCapability(lcNeedMininimizeAppWithMainForm) <> LCL_CAPABILITY_NO) then
Application.Restore;
if Assigned(OnWindowStateChange) then
OnWindowStateChange(Self);
end;
if (OldState <> State) or FWindowStateChanged then
begin
{ honor Position property on first restore when form was designed maximized }
if not (FIsFirstOnShow or FIsFirstOnActivate) then
begin
if FIsFirstRestore and (State = wsNormal) then
begin
{ Need to check width/height before calling MoveToDefaultPosition.
QT5 triggers Resizing() twice: one for position change, and
another for size change. This check should not affect other
widgetsets. }
if (Width <> RestoredWidth) or (Height <> RestoredHeight) then
Exit;
MoveToDefaultPosition;
FIsFirstRestore := False;
end;
if Assigned(OnWindowStateChange) then
OnWindowStateChange(Self);
end;
FWindowStateChanged := False;
end;
end;
end;
......@@ -1830,7 +1853,10 @@ begin
FWindowState := Value;
//DebugLn(['TCustomForm.SetWindowState ',DbgSName(Self),' ',ord(FWindowState),' csDesigning=',csDesigning in ComponentState,' Showing=',Showing]);
if (not (csDesigning in ComponentState)) and Showing then
begin
FWindowStateChanged := True;
ShowWindow(Handle, ShowCommands[Value]);
end;
end;
end;
......@@ -2030,6 +2056,8 @@ begin
FDelayedOnResize := False;
FIsFirstOnShow := True;
FIsFirstOnActivate := True;
FIsFirstRestore := False;
FWindowStateChanged := False;
GlobalNameSpace.BeginWrite;
try
CreateNew(AOwner, 1); // this calls BeginFormUpdate, which is ended in AfterConstruction
......
......@@ -1121,6 +1121,8 @@ begin
{$ENDIF}
SizeMsg.SizeType := SIZE_MINIMIZED;
end
else if (GDK_WINDOW_STATE_FULLSCREEN and state^.new_window_state)>0 then
SizeMsg.SizeType := SIZE_FULLSCREEN
else if (GDK_WINDOW_STATE_MAXIMIZED and state^.new_window_state)>0 then
begin
// it can be both maximized + iconified and just loose iconified state
......@@ -1133,7 +1135,8 @@ begin
// don't bother the LCL if nothing changed
case SizeMsg.SizeType of
SIZE_RESTORED: if TheForm.WindowState=wsNormal then exit;
SIZE_MINIMIZED: if TheForm.WindowState=wsMinimized then exit;
// Need to send LM_SIZE message to LCL if wsMinimized to trigger onWindowStateChange()
//SIZE_MINIMIZED: if TheForm.WindowState=wsMinimized then exit;
SIZE_MAXIMIZED: if TheForm.WindowState=wsMaximized then exit;
SIZE_FULLSCREEN: if TheForm.WindowState=wsFullScreen then exit;
end;
......
......@@ -15,6 +15,7 @@
{$ENDIF}
type
TWinControlAccess = class(TWinControl);
TApplicationAccess = class(TApplication);
{*************************************************************}
{ callback routines }
{*************************************************************}
......@@ -2054,6 +2055,8 @@ begin
begin
CheckSynchronize;
TWin32Widgetset(Widgetset).CheckPipeEvents;
if Assigned(Application) then
TApplicationAccess(Application).ProcessAsyncCallQueue;
end;
WM_ENTERIDLE: Application.Idle(False);
WM_ACTIVATE: SetLMessageAndParams(LM_ACTIVATE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment