LCL: fix showing empty filelistbox (bug #7465)

git-svn-id: trunk@10399 -
This commit is contained in:
vincents 2007-01-08 21:19:52 +00:00
parent 71de954bd0
commit d082e56c6d
2 changed files with 8 additions and 2 deletions

View File

@ -256,7 +256,8 @@ var
i: Integer;
begin
i:=ItemIndex;
if i<0 then
// in a multiselect listbox, the itemindex can be 0 in an empty list
if (i<0) or (i>=Items.Count) then
FFileName := ''
else begin
FFileName := FDirectory+DirectorySeparator+Items[i];

View File

@ -471,7 +471,12 @@ end;
class function TWin32WSCustomListBox.GetItemIndex(const ACustomListBox: TCustomListBox): integer;
begin
Result := SendMessage(ACustomListBox.Handle, LB_GETCURSEL, 0, 0);
if ACustomListBox.MultiSelect then
// Return focused item for multiselect listbox
Result := SendMessage(ACustomListBox.Handle, LB_GETCARETINDEX, 0, 0)
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');