Re: Re: please help...


Posted by Bjoern Rebesky on November 16, 2000 at 17:52:40:

In Reply to: Re: please help... posted by Ulrich Becker on November 15, 2000 at 17:03:52:

Thx Ulrich!

...but unfortunately it isn't working..I still get a memory violation. Please have a look at my code:

var
Node : pointer;
NodeSender: string;

procedure TF_MainForm.NodeClick(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
with (Sender As TShape) do begin
Pen.Width := 1;
Pen.Color := clBlack;
end;

NodeSender := (Sender As TShape).Name;

if (Button = mbRight) then begin
M_Node.Popup((Sender As TShape).Left, (Sender As TShape).Top);
end;
// If I do a right click on a shape in my form a popup window will appear...
end;

procedure TF_MainForm.M_NodePopup(Sender: TObject);
begin
Node := @Sender; // when the popup window appears I point to the shape I just right-clicked on...
end;

procedure TF_MainForm.M_Node_DeleteClick(Sender: TObject);
begin
if (MessageDlg('Do you want to delete ' + NodeSender + ' ?',
mtConfirmation, [mbYes, mbNo], 0) = mrYes) th en
TShape(Node^).Free;
//If I now click on Delete in my popup window I have to confirm it and then I want to free the shape I pointed to in the above procedure...
end;

I get no error with this source code but at runtime I get a memory violation in the moment I confirm to delete the node.
Do you have any idea how to free this Shape after right clicking on it and choose 'delete' in the popup window? The problem is that the popup window has the shape as sender but the deleteclick in the popup window has the popup window as sender..so I can't use the sender parameter...I AM LOST!
Please help..any ideas are welcome...

thx in advance
Bjoern


Related Articles and Replies: