mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 07:39:26 +02:00
TListBox: fix SelCount in case HandleAllocated = False. Issue #40361.
(cherry picked from commit a4c9080f10
)
This commit is contained in:
parent
719d3a2a7c
commit
33d3ac5e05
@ -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
|
||||
Result := 0;
|
||||
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