lcl: don't return incorrent ItemIndex (valid values are from -1 to Count - 1)

git-svn-id: trunk@17628 -
This commit is contained in:
paul 2008-11-29 10:41:48 +00:00
parent 1aca8c88b8
commit 7fad68ae28
2 changed files with 6 additions and 8 deletions

View File

@ -551,9 +551,12 @@ begin
if HandleAllocated then
begin
Result := TWSCustomListBoxClass(WidgetSetClass).GetItemIndex(Self);
FItemIndex:=Result;
end else
Result:=FItemIndex;
if (Result < 0) or (Result >= Count) then
Result := -1;
FItemIndex := Result;
end
else
Result := FItemIndex;
//DebugLn('[TCustomListBox.GetItemIndex] END ');
end;

View File

@ -586,11 +586,6 @@ begin
else
// LB_GETCURSEL is only for single select listbox
Result := SendMessage(ACustomListBox.Handle, LB_GETCURSEL, 0, 0);
if Result = LB_ERR then
begin
Assert(false, 'Trace:[TWin32WSCustomListBox.GetItemIndex] could not retrieve itemindex, try selecting an item first');
Result := -1;
end;
end;
class function TWin32WSCustomListBox.GetItemRect(