steinonline
asked on
Delphi Listbox.Perform gives invalid typecast error when target platform is 64Bit Windows in Delphi XE2
Hello Experts, My problem is that I do a lookup of items in a listbox using code like this. This has worked for me for many years. However when I set the target platform to be 64Bit Windows, I am not able to successfully use this technique. I'm assuming that this is because an integer is something different in the 64 Bit World. Here's the code.
The Error I'm getting is "Invalid Typecast"
var i:integer;
var str:string;
// assume there is an edit box named edit1, and a listbox named ListBox1
begin
str:=edit1.text;
i:=listbox1.perform(LB_SEL ECTSTRING, -1, integer(str);
end;
This will work just fine when target platform is set to 32bit Windows.
I have not been able to find any material on this matter anywhere.
The Error I'm getting is "Invalid Typecast"
var i:integer;
var str:string;
// assume there is an edit box named edit1, and a listbox named ListBox1
begin
str:=edit1.text;
i:=listbox1.perform(LB_SEL
end;
This will work just fine when target platform is set to 32bit Windows.
I have not been able to find any material on this matter anywhere.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I simply forgot to type the ) when I wrote the code down. I did find however that the first parameter would not compile as 64bit with -1 as value. Must be 0. Then it all works fine.
Cheers
Cheers
Anyway why don't you use simply Listbox1.items.indexof(str