Pointer Problems with TComponentList - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Pointer Problems with TComponentList

ockiejvsockiejvs Posts: 3Member
I have the following pointer problem:
The shape was created dynamically, and was accessable through a pointer pointing to the object in a componentlist.


procedure Tfrm_tyd.OnMouseDownEvent(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
ManyShape: TManyShape;
//pointer: Integer;
begin
if (Sender is TManyShape) then
begin
pointer := ComponentList1.IndexOf(ManyShape);
ManyShape:= TManyShape(ComponentList1[pointer]);
ManyShape.BeginDrag(True);
end
else
begin
BeginDrag(False);
ShowMessage('False');
end;

end;


procedure Tfrm_tyd.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
var
ManyShape: TManyShape;
pointer: Integer;

begin
if Source is TManyShape then
begin

pointer := ComponentList1.IndexOf(ManyShape);
//ComponentList1.
ShowMessage(inttostr(pointer));

///////////////////////////////////////////////////////////
//Asblik
else if ((X > 416 + 120) and (X < 416 + 120+ 30)) and ((Y > 144) and (Y < 144 + 120)) then
begin
//ManyShape.Destroy;
end

The problem is that the valua of the pointer in the next procedure does not correspond to the value of the pointer in the OnMouseDown event. I suspect it has something to do with dereferencing, something I worked with many years ago briefly. Can anyone help? Am I on the right track? I basically want to destroy the object with the FormDragDrop event by dropping it in a 'recycle bin area' (top, left, width, height) on the canvas.

Comments

Sign In or Register to comment.