[Lazarus] Invalid component names

Benito van der Zander benito at benibela.de
Mon Apr 27 13:05:47 CEST 2009


>> So the remaining question is: How to assign unique names to
>> dynamically created components? Does there exist an immediately
>> usable method or function?
>>     
For wincontrols you could use this:
control.name:='handle_is_'+inttostr(control.handle);

Handle is system-wide unique (at least on Win32)

However, some properties can change the handle imho,
than you should either set the new name or hope the handle will not be 
used again.


Or you could use this: (name depending on the current time and a random 
number if several controls are created in one milli-second)
component.name:='created_at_'+inttostr(trunc(date))+'_'+inttostr(trunc(time*24*60*60*3600))+'_'+inttostr(random(100000));


Benito



More information about the Lazarus mailing list