mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-23 17:08:11 +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 }
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------}
|
||||||
function TCustomListBox.GetSelCount: integer;
|
function TCustomListBox.GetSelCount: integer;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
if HandleAllocated then
|
if HandleAllocated then
|
||||||
Result := TWSCustomListBoxClass(WidgetSetClass).GetSelCount(Self)
|
Result := TWSCustomListBoxClass(WidgetSetClass).GetSelCount(Self)
|
||||||
else
|
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;
|
end;
|
||||||
|
|
||||||
function TCustomListBox.GetItemHeight: Integer;
|
function TCustomListBox.GetItemHeight: Integer;
|
||||||
|
Loading…
Reference in New Issue
Block a user