anithegregorian
anithegregorian

Reputation: 25

delphi string to handle type casting

Is there anyway to safely convert/typecast a string inside TEdit (an actual window handle for eg. 00010C10) into a handle LONGWORD data type I presume in Delphi/Lazarus.

Recommended method here Pascal - String to LongWord is IntToStr but compiler throws following error:

Exception class EConvertError with message '00010C10' is not a valid integer value

Also tried IntToStr64 but no luck....

Upvotes: 1

Views: 2212

Answers (1)

ain
ain

Reputation: 22749

It's because by default the StrToInt expects the string to be in decimal notation. To convert an hex notation string to integer prefix it with $, ie

intVal := StrToInt('$'+Edit1.Text);

Upvotes: 8

Related Questions