mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-22 16:28:15 +02:00
TListBox: fix SelCount in case HandleAllocated = False. Issue #40361.
This commit is contained in:
parent
7a5eda3a4a
commit
a4c9080f10
@ -450,11 +450,23 @@ end;
|
||||
{ function TCustomListBox.GetSelCount }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TCustomListBox.GetSelCount: integer;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if HandleAllocated then
|
||||
Result := TWSCustomListBoxClass(WidgetSetClass).GetSelCount(Self)
|
||||
else
|
||||
begin
|
||||
if not MultiSelect then
|
||||
Result := Ord(FItemIndex >- 1) //use FItemIndex since HandleAllocated = False
|
||||
else
|
||||
begin
|
||||
Result := 0;
|
||||
if FCacheValid then //otherwise GetSelectedCache raises an exception
|
||||
for i := 0 to Items.Count - 1 do
|
||||
if GetSelectedCache(i) then Inc(Result);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCustomListBox.GetItemHeight: Integer;
|
||||
|
Loading…
Reference in New Issue
Block a user