I want the derived TImage to follow the cursor when it is clicked and stop following when it is clicked again. To do this, I created a pointer called "Attached" that points to a TImage or derivation.
var Attached: ^TImage;
I also set up a derivative of Timage to call the ChangeAttachState procedure when I clicked it.
Now, in the ChangeAttachState procedure, I want to change the pointer that it points to the pressed image, or indicate zero when the image was already attached. In code:
procedure TForm1.ChangeAttachState(Sender:TObject); begin if Attached = nil then Attached := @Sender else Attached := nil; end;
However, the string "Attached: = @Sender" does not work, causing an access violation when I want to use the pointer to move the image to the right.
I think the pointer points to the wrong location. How can I make a pointer point in the correct saved address or make the image click with the mouse in other ways?
(I hope I used the correct technical terms as English is not my first language)
source share