From afd634b785e765e3f3e4ec8d11067be7486fde08 Mon Sep 17 00:00:00 2001 From: albireo77 Date: Mon, 6 Jan 2025 09:18:10 +0100 Subject: [PATCH] Updates --- Blocks/Base_Block.pas | 38 ++++++++++++++++++-------------------- Blocks/Main_Block.pas | 25 +++++++------------------ 2 files changed, 25 insertions(+), 38 deletions(-) diff --git a/Blocks/Base_Block.pas b/Blocks/Base_Block.pas index b84fde6f..341c0de1 100644 --- a/Blocks/Base_Block.pas +++ b/Blocks/Base_Block.pas @@ -104,7 +104,7 @@ TBlock = class(TCustomControl, IWithId, IWithFocus, IExportable, IMemoEx) procedure SetPage(APage: TBlockTabSheet); virtual; function GetPage: TBlockTabSheet; virtual; procedure CreateParams(var Params: TCreateParams); override; - procedure OnWindowPosChanging(AWindowPos: PWindowPos); virtual; + procedure OnCommentPosChanging(AComment: TComment; dx, dy: integer); virtual; function ProcessComments: boolean; function IsAncestor(AParent: TObject): boolean; function GetErrorMsg(AEdit: TCustomEdit): string; @@ -1069,7 +1069,16 @@ function TBlock.IsInFront(AControl: TWinControl): boolean; procedure TBlock.WMWindowPosChanging(var Msg: TWMWindowPosChanging); begin - OnWindowPosChanging(Msg.WindowPos); + if FPosChanged and ((Msg.WindowPos.flags and SWP_NOMOVE) = 0) then + begin + var dx := Msg.WindowPos.x - Left; + var dy := Msg.WindowPos.y - Top; + if (dx <> 0) or (dy <> 0) then + begin + for var comment in GetComments(True) do + OnCommentPosChanging(comment, dx, dy); + end; + end; inherited; end; @@ -1080,25 +1089,14 @@ procedure TBlock.WMWindowPosChanged(var Msg: TWMWindowPosChanged); inherited; end; -procedure TBlock.OnWindowPosChanging(AWindowPos: PWindowPos); +procedure TBlock.OnCommentPosChanging(AComment: TComment; dx, dy: integer); begin - if FPosChanged and ((AWindowPos.flags and SWP_NOMOVE) = 0) then - begin - var dx := AWindowPos.x - Left; - var dy := AWindowPos.y - Top; - if (dx <> 0) or (dy <> 0) then - begin - for var comment in GetComments(True) do - begin - if not comment.Moved then - begin - if comment.Visible then - TInfra.MoveWinTopZ(comment, comment.Left+dx, comment.Top+dy); - comment.Moved := True; - end; - end; - end; - end; + if not AComment.Moved then + begin + if AComment.Visible then + TInfra.MoveWinTopZ(AComment, AComment.Left+dx, AComment.Top+dy); + AComment.Moved := True; + end; end; function TBlock.GetPinComments: IEnumerable; diff --git a/Blocks/Main_Block.pas b/Blocks/Main_Block.pas index 715e0f78..d850418c 100644 --- a/Blocks/Main_Block.pas +++ b/Blocks/Main_Block.pas @@ -24,8 +24,8 @@ interface uses - WinApi.Windows, WinApi.Messages, Vcl.Graphics, Vcl.ComCtrls, System.Classes, - System.Math, Base_Block, OmniXML, Interfaces, Types, BlockTabSheet; + WinApi.Windows, Vcl.Graphics, Vcl.ComCtrls, System.Classes, System.Math, Base_Block, + OmniXML, Interfaces, Types, BlockTabSheet, Comment; type @@ -58,7 +58,7 @@ TMainBlock = class(TGroupBlock, IWinControl) FStopLabel: string; procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; procedure Paint; override; - procedure OnWindowPosChanging(AWindowPos: PWindowPos); override; + procedure OnCommentPosChanging(AComment: TComment; dx, dy: integer); override; procedure SetPage(APage: TBlockTabSheet); override; function GetFunctionLabel(var ARect: TRect): string; function GetPage: TBlockTabSheet; override; @@ -73,7 +73,7 @@ implementation uses Vcl.Forms, System.SysUtils, System.StrUtils, Infrastructure, XMLProcessor, OmniXMLUtils, - Navigator_Form, UserFunction, Comment, Constants; + Navigator_Form, UserFunction, Constants; constructor TMainBlock.Create(APage: TBlockTabSheet; const ABlockParms: TBlockParms); begin @@ -466,21 +466,10 @@ function TMainBlock.IsBoldDesc: boolean; result := True; end; -procedure TMainBlock.OnWindowPosChanging(AWindowPos: PWindowPos); +procedure TMainBlock.OnCommentPosChanging(AComment: TComment; dx, dy: integer); begin - if FPosChanged and ((AWindowPos.flags and SWP_NOMOVE) = 0) then - begin - var dx := AWindowPos.x - Left; - var dy := AWindowPos.y - Top; - if (dx <> 0) or (dy <> 0) then - begin - for var comment in GetComments(True) do - begin - if comment.Visible then - TInfra.MoveWinTopZ(comment, comment.Left+dx, comment.Top+dy); - end; - end; - end; + if AComment.Visible then + TInfra.MoveWinTopZ(AComment, AComment.Left+dx, AComment.Top+dy); end; function TMainBlock.GetUndoObject: TObject;