>I expected for a mouse event on a menu the following would work:
>procedure TMainForm.Menu1Click(Sender: TObject);
>begin
> sender:=nil;
>end;
>But in fact it doesnt!
>So the hook would have to be something like:
>procedure TMainForm.Menu1Click(Sender: TObject);
>begin
> sender:=nil;
> Menu1.Enabled:=false;
>end;
non VAR parameters are exactly like local variables in the procedure.
And setting Sender to nil has NO effect on the program at all...
Think of an event procedure like a message. The Sender is just telling
who is responsible for the message not the sender themselves. If you
delete this message just because I am the sender I will not be effected.
It is exactly the same with the event. Var parameters are different in
this respect and will change the value of the variable used to call the
event. However this would not remove the object from memory, merely
remove one reference to it.
procedure Test(obj :TObject);
begin
obj := nil;
end;
var
O :TMyobject;
begin
O := TMyObject.Create;
Test(O);
if O<>nil then Showmessage('See it didn't do anything to O at all')
else Showmessage('Egg on my face');
end;
I'm confident my face will remain egg free.
--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz