Zitat von Benito van der Zander <benito@benibela.de>:

>
> >> 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.

Handles are destroyed/created all the time.
When the Handle is destroyed its value could appear 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));

Bad idea.
Think about summer/winter time change or when the user/ntp adjusts time.


Mattias


