Drummer1972 0 Posted April 7, 2023 (edited) I have one THorzScrollBox with three TGridLayouts (c++ Builder 11): ¿Can I move it around with the mouse (ShowScrollBars=false)? Any ideas.. THANKS Edited April 7, 2023 by Drummer1972 Share this post Link to post
programmerdelphi2k 237 Posted April 7, 2023 (edited) hi @Drummer1972 here a Guitarman +/- try some like this: my sample is in Delphi ... sorry Im not CBuilder ! type TForm1 = class(TForm) HorzScrollBox1: THorzScrollBox; rectGreen: TRectangle; rectRed: TRectangle; rectBlue: TRectangle; Memo1: TMemo; rectOrchid: TRectangle; procedure HorzScrollBox1DragOver(Sender: TObject; const Data: TDragObject; const Point: TPointF; var Operation: TDragOperation); procedure HorzScrollBox1DragDrop(Sender: TObject; const Data: TDragObject; const Point: TPointF); procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.fmx} type TArrRectangles = TArray<TRectangle>; var LArrRectangles: TArrRectangles; procedure TForm1.FormCreate(Sender: TObject); var j : single; LText : string; LRectangle: TRectangle; begin LArrRectangles := []; // j := 0; // for var X: integer := 0 to (HorzScrollBox1.Content.ChildrenCount - 1) do if (HorzScrollBox1.Content.Children.Items[X] is TRectangle) then // rectangles in HorzScrollBox1 begin LRectangle := TRectangle(HorzScrollBox1.Content.Children.Items[X]); LRectangle.Margins.Left := 5; // space to working with Drag...Drop it! LRectangle.DragMode := TDragMode.dmAutomatic; LRectangle.Tag := X; LRectangle.Position.X := j; LRectangle.Align := TAlignLayout.Left; // all to left... LArrRectangles := LArrRectangles + [LRectangle]; j := j + LRectangle.Width + 1; // next rectangle position LText := LText + LRectangle.Name + ' ' + LRectangle.Position.X.ToString + ' ' + LRectangle.Tag.ToString + slinebreak; end; // Memo1.Lines.Add(LText); // if (length(LArrRectangles) > 0) then // else there is no rectangles on HorzScrollBolx1 HorzScrollBox1.DragMode := TDragMode.dmAutomatic; end; procedure TForm1.HorzScrollBox1DragDrop(Sender: TObject; const Data: TDragObject; const Point: TPointF); begin if (Data.Source is TRectangle) then LArrRectangles[TRectangle(Data.Source).Tag].Position.X := Application.MainForm.ScreenToClient(Screen.MousePos).X; // rect in new position... end; procedure TForm1.HorzScrollBox1DragOver(Sender: TObject; const Data: TDragObject; const Point: TPointF; var Operation: TDragOperation); begin if (Data.Source is TRectangle) then Operation := TDragOperation.Move; end; end. Edited April 7, 2023 by programmerdelphi2k Share this post Link to post
Drummer1972 0 Posted April 7, 2023 (edited) 12 hours ago, Drummer1972 said: Thank you very much for your time, it was just what I was looking for... you are a crack "Guitarman" Edited April 7, 2023 by Drummer1972 Share this post Link to post