move TRectangle with mouse (FMX, Win32)


I have an FMX form with a TLayout on it aligned to client. On the TLayout I have a TRectangle. I can move the TRectangle easily with the following code in a button click event:

Rectangle1->Position->X = Rectangle1->Position->X + 10;

Is there a clean way for me to do this (move the rectangle) with the mouse? Like click on the Rectangle and move it around to a new location? I’m just playing around trying to make a little drawing program to learn….

Using C++Builder 10.2 Version 25.0.29899.2631 and building in Win32.

UPDATE: I took Hans approach and ended up making it work nicely. I’ve added the full code as an answer below. Yay!

Comments are closed.