Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-03

TListView.SelCount bug

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Roland Turcan

Hello General mailing list!

I have on a form TListView and I found TListView doesn't report correct value in SelCount in the case, that the owner form is not shown.

When I ask for SelCount before I close the Windows then it reports

0, but after ShowModal reports =0;

After closing the windows HandleAllocated results FALSE.

function TCustomListView.GetSelCount: Integer;
begin
  if HandleAllocated
  then Result := TWSCustomListViewClass(WidgetSetClass).GetSelCount(Self)
  else Result := 0;
end;

I can make a workaround for this, that I will save the value before windows is closed, but I think, that it is bug.

Is it purpose or bug?

----------------------------------------
Example:
----------------------------------------

FUNCTION Unit2Execute (MVisible:BOOLEAN):BOOLEAN;
var i:integer;
BEGIN
  WITH TForm2.Create (Application) DO begin
    ShowModal;
    i := ListView1.SelCount;
    ShowMessage (Inttostr (i));
    Free;
  END;
END;

{ TForm2 }

procedure TForm2.Button1Click(Sender: TObject);
var i:integer;
begin
  i := ListView1.SelCount;
  ShowMessage (Inttostr (i));
  ModalResult := mrOK;
end;

Reply by email

Mattias Gaertner
to Roland Turcan
Show quoted text 23 lines
Hello General mailing list! I have on a form TListView and I found TListView doesn't report correct value in SelCount in the case, that the owner form is not shown. When I ask for SelCount before I close the Windows then it reports >0, but after ShowModal reports =0; After closing the windows HandleAllocated results FALSE. function TCustomListView.GetSelCount: Integer; begin if HandleAllocated then Result := TWSCustomListViewClass(WidgetSetClass).GetSelCount(Self) else Result := 0; end; I can make a workaround for this, that I will save the value before windows is closed, but I think, that it is bug. Is it purpose or bug? [...]

Please create a bug report.

Mattias

Reply by email