From 7fad68ae282f11740044e24ea8f42ea0690ba462 Mon Sep 17 00:00:00 2001 From: paul Date: Sat, 29 Nov 2008 10:41:48 +0000 Subject: [PATCH] lcl: don't return incorrent ItemIndex (valid values are from -1 to Count - 1) git-svn-id: trunk@17628 - --- lcl/include/customlistbox.inc | 9 ++++++--- lcl/interfaces/win32/win32wsstdctrls.pp | 5 ----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lcl/include/customlistbox.inc b/lcl/include/customlistbox.inc index 36a9b192fe..de56837741 100644 --- a/lcl/include/customlistbox.inc +++ b/lcl/include/customlistbox.inc @@ -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; diff --git a/lcl/interfaces/win32/win32wsstdctrls.pp b/lcl/interfaces/win32/win32wsstdctrls.pp index 4598c979a1..538474a154 100644 --- a/lcl/interfaces/win32/win32wsstdctrls.pp +++ b/lcl/interfaces/win32/win32wsstdctrls.pp @@ -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(