mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-27 13:09:22 +02:00
Win32: fix MDIChild form not updating Top/Left. Issue #40232.
This commit is contained in:
parent
fda1f35008
commit
e95cadd095
@ -2408,6 +2408,7 @@ var
|
|||||||
R: TRect;
|
R: TRect;
|
||||||
WindowPlacement: TWINDOWPLACEMENT;
|
WindowPlacement: TWINDOWPLACEMENT;
|
||||||
ParentHandle: THandle;
|
ParentHandle: THandle;
|
||||||
|
lclControl, lclParent: TWinControl;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
@ -2425,6 +2426,24 @@ begin
|
|||||||
if ParentHandle <> 0 then
|
if ParentHandle <> 0 then
|
||||||
begin
|
begin
|
||||||
if not Windows.ScreenToClient(ParentHandle, @LeftTop) then Exit;
|
if not Windows.ScreenToClient(ParentHandle, @LeftTop) then Exit;
|
||||||
|
lclControl := GetWin32WindowInfo(Handle)^.WinControl;
|
||||||
|
//Is this an MDIChild?
|
||||||
|
//Note: doing a more simple comparison: (ParentHandle = Win32WidgetSet.MDIClientHandle) has side effects, hence this more elaborate version
|
||||||
|
if (lclControl is TCustomForm) and
|
||||||
|
(TCustomForm(lclControl).FormStyle = fsMDIChild) and
|
||||||
|
(TCustomForm(lclControl).Parent = nil) and
|
||||||
|
Assigned(Application.MainForm) and
|
||||||
|
(Application.MainForm.FormStyle=fsMDIForm)
|
||||||
|
then
|
||||||
|
begin
|
||||||
|
//for a MDI ChildForm do not use ParentHandle
|
||||||
|
//because in this case ParentHandle = Win32WidgetSet.MDIClientHandle
|
||||||
|
//which is not a TWinControl, but a custom window created with the CreateWindowW API directly
|
||||||
|
//and GetLCLClientBoundsOffset() then returns False.
|
||||||
|
//Issue #40232
|
||||||
|
//ToDo: fix this in a better place?
|
||||||
|
ParentHandle := Handle;
|
||||||
|
end;
|
||||||
if not GetLCLClientBoundsOffset(ParentHandle, R) then
|
if not GetLCLClientBoundsOffset(ParentHandle, R) then
|
||||||
Exit;
|
Exit;
|
||||||
Dec(LeftTop.X, R.Left);
|
Dec(LeftTop.X, R.Left);
|
||||||
|
Loading…
Reference in New Issue
Block a user