diff --git a/lcl/forms.pp b/lcl/forms.pp index 43e8b5f682..ee2882bb30 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -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; diff --git a/lcl/include/windowmagnet.inc b/lcl/include/windowmagnet.inc index 4ee53a6fba..07576db5cd 100644 --- a/lcl/include/windowmagnet.inc +++ b/lcl/include/windowmagnet.inc @@ -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^);