lcl: ensure SnapOptions are streamed

This commit is contained in:
Martok 2022-08-19 23:20:40 +02:00 committed by Maxim Ganetsky
parent b83838139d
commit 0b50d7cfc2
2 changed files with 20 additions and 1 deletions

View File

@ -426,6 +426,7 @@ type
FDistance: integer;
public
constructor Create;
procedure AssignTo(Dest: TPersistent); override;
published
property SnapToMonitor: boolean read FSnapMonitor write FSnapMonitor default false;
property SnapToForms: boolean read FSnapForms write FSnapForms default false;
@ -609,6 +610,7 @@ type
procedure SetScreenSnap(aValue: boolean);
function GetSnapBuffer: integer;
procedure SetSnapBuffer(aValue: integer);
procedure SetSnapOptions(aValue: TWindowMagnetOptions);
protected
procedure WMActivate(var Message : TLMActivate); message LM_ACTIVATE;
procedure WMCloseQuery(var message: TLMessage); message LM_CLOSEQUERY;
@ -795,7 +797,7 @@ type
property LastActiveControl: TWinControl read FLastActiveControl;
property PopupMode: TPopupMode read FPopupMode write SetPopupMode default pmNone;
property PopupParent: TCustomForm read FPopupParent write SetPopupParent;
property SnapOptions: TWindowMagnetOptions read FSnapOptions;
property SnapOptions: TWindowMagnetOptions read FSnapOptions write SetSnapOptions;
property ScreenSnap: boolean read GetScreenSnap write SetScreenSnap stored false;
property SnapBuffer: integer read GetSnapBuffer write SetSnapBuffer stored false;

View File

@ -21,6 +21,17 @@ begin
FDistance:= 10;
end;
procedure TWindowMagnetOptions.AssignTo(Dest: TPersistent);
begin
if Dest is TWindowMagnetOptions then
with TWindowMagnetOptions(Dest) do begin
Distance:= Self.Distance;
SnapToMonitor:= Self.SnapToMonitor;
SnapToForms:= Self.SnapToForms;
SnapFormTarget:= Self.SnapFormTarget;
end;
end;
{ TWindowMagnetManager }
function PosToRect(wp: TWindowPos): TRect;
@ -220,6 +231,12 @@ begin
FSnapOptions.Distance:= aValue;
end;
procedure TCustomForm.SetSnapOptions(aValue: TWindowMagnetOptions);
begin
if FSnapOptions=aValue then Exit;
FSnapOptions.Assign(aValue);
end;
procedure TCustomForm.WMWindowPosChanging(var Message: TLMWindowPosChanging);
begin
Screen.MagnetManager.SnapForm(Self, Message.WindowPos^);