I want a derivate of TImage follow the Cursor when it has been clicked and stop following when it gets clicked again. For this, I created a pointer, named 'Attached', that points to a TImage or a derivate.
var Attached: ^TImage;
I also set the derivate of Timage to call the procedure ChangeAttachState when its clicked.
Now, in the ChangeAttachState procedure I want to change the pointer that it points on the clicked Image or point to nil when an Image was already attached. In Code:
procedure TForm1.ChangeAttachState(Sender:TObject);
begin
if Attached = nil then
Attached := @Sender
else
Attached := nil;
end;
However, the line 'Attached := @Sender' does not seem to work, causing an Access violation when I want to use the pointer to i.e. move the Image to the Right.
I think the pointer points at a wrong location. How can I make the pointer point at the correct save adress or make the clicked Image follow the mouse with other methods?
(I hope I used the right technical terms, as English is not my native language)