Instead of IntToStr
, which accepts a signed integer, you can treat the handle as a pointer and therefore represent the numeric value as hex:
popupname := Format('XYZ%p', [Pointer(Handle)]);
This makes sense because the handle on Windows, as defined in the header files, is an untyped pointer, void*
.
As an added benefit, your code will now be correct on both 32 and 64-bit platforms.
Thinking outside the field, the component may not need a name at all. If so, delete this code, leave it unmanned and thus pose your problem.
source share