How to free control inside its event handler?

Posted by lyborko on Stack Overflow See other posts from Stack Overflow or by lyborko
Published on 2010-03-23T18:24:40Z Indexed on 2010/03/23 18:43 UTC
Read the original article Hit count: 180

Filed under:

Hi,

Does anybody know the trick, how to free control inside its event handler ? According delphi help it is not possible...

I want to free dynamicaly created TEdit, when Self.Text=''.

TAmountEdit = class (TEdit)
.
.
public
  procedure KeyUp(var Key: Word; Shift :TShiftState);
end;

procedure TAmountEdit.KeyUp(var Key: Word; Shift :TShiftState);
begin
inherited;
if Text='' then Free; // after calling free, an exception arises
end;

How should do to achieve the same effect?

Thanx

© Stack Overflow or respective owner

Related posts about delphi