DelphiFAQ Home Search:
General :: Programming :: Delphi :: VCL
About the Delphi VCL (Visual Component Library)

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

Change text in a OnChange event without stack overflow

If you change a TEdit text in its OnChange event, e.g. to do some adjustments, it will fire the event recursively until stack exhausts.
You can temporarily disable the event handler just by setting the internal method pointer to nil. Don't forget to set it back to the right procedure - this sample shows how to do it:

 procedure Form1.Edit1Change(Sender : TObject); 
 begin
   { temporarily disable the event handler }
   Edit1.OnChange := NIL; 
   if Edit1.Text = 'Some Text' then 
     Edit1.Text := 'New Text'; 
   { enable the event handler again }
   Edit1.OnChange := Edit1Change; 
 end;
 

Generated 0:01:36 on Apr 23, 2017