LCL: Fix window RestoredLeft/Top values. Issue #8576, patch from Yuichiro Takahashi.

git-svn-id: trunk@46292 -
This commit is contained in:
juha 2014-09-22 17:19:14 +00:00
parent c93ed74ee4
commit d186f4212a
2 changed files with 20 additions and 23 deletions

View File

@ -454,14 +454,13 @@ type
function GetEffectiveShowInTaskBar: TShowInTaskBar;
function GetMonitor: TMonitor;
function GetPixelsPerInch: Longint;
function GetRestoredLeft: integer;
function GetRestoredTop: integer;
function IsAutoScrollStored: Boolean;
function IsForm: Boolean;
function IsIconStored: Boolean;
procedure CloseModal;
procedure FreeIconHandles;
procedure IconChanged(Sender: TObject);
procedure Moved(Data: PtrInt);
procedure SetActive(AValue: Boolean);
procedure SetActiveControl(AWinControl: TWinControl);
procedure SetActiveDefaultControl(AControl: TControl);
@ -485,6 +484,7 @@ type
procedure WMActivate(var Message : TLMActivate); message LM_ACTIVATE;
procedure WMCloseQuery(var message: TLMessage); message LM_CLOSEQUERY;
procedure WMHelp(var Message: TLMHelp); message LM_HELP;
procedure WMMove(var Message: TLMMove); message LM_MOVE;
procedure WMShowWindow(var message: TLMShowWindow); message LM_SHOWWINDOW;
procedure WMSize(var message: TLMSize); message LM_Size;
procedure WMWindowPosChanged(var Message: TLMWindowPosChanged); message LM_WINDOWPOSCHANGED;
@ -685,8 +685,8 @@ type
property ParentFont default False;
property PixelsPerInch: Longint read GetPixelsPerInch write FPixelsPerInch stored False;
property Position: TPosition read FPosition write SetPosition default poDesigned;
property RestoredLeft: integer read GetRestoredLeft;
property RestoredTop: integer read GetRestoredTop;
property RestoredLeft: integer read FRestoredLeft;
property RestoredTop: integer read FRestoredTop;
property RestoredWidth: integer read FRestoredWidth;
property RestoredHeight: integer read FRestoredHeight;
property ShowInTaskBar: TShowInTaskbar read FShowInTaskbar write SetShowInTaskBar

View File

@ -730,16 +730,29 @@ begin
inherited WMSize(Message);
if (Message.SizeType and SIZE_RESTORED) > 0 then
if (Message.SizeType and not SIZE_SourceIsInterface) = SIZE_RESTORED then
begin
FRestoredLeft := Left;
FRestoredTop := Top;
FRestoredWidth := Width;
FRestoredHeight := Height;
//DebugLn('[TCustomForm.WMSize] saving restored bounds ',DbgSName(Self),' ',dbgs(FRestoredWidth),'x',dbgs(FRestoredHeight));
end;
end;
procedure TCustomForm.WMMove(var Message: TLMMove);
begin
inherited WMMove(Message);
Application.QueueAsyncCall(@Moved, 0)
end;
procedure TCustomForm.Moved(Data: PtrInt);
begin
if WindowState = wsNormal then
begin
FRestoredLeft := Left;
FRestoredTop := Top;
end;
end;
procedure TCustomForm.WMWindowPosChanged(var Message: TLMWindowPosChanged);
begin
if (Parent = nil) and Assigned(Message.WindowPos) and ((Message.WindowPos^.flags and SWP_SourceIsInterface)>0) then
@ -2275,22 +2288,6 @@ begin
Result := Screen.MonitorFromWindow(Handle, mdNearest);
end;
function TCustomForm.GetRestoredLeft: integer;
begin
if WindowState=wsNormal then
Result := Left
else
Result := FRestoredLeft;
end;
function TCustomForm.GetRestoredTop: integer;
begin
if WindowState=wsNormal then
Result := Top
else
Result := FRestoredTop;
end;
{------------------------------------------------------------------------------
TCustomForm Method SetFocusedControl