title: TListView in virtual mode limited to 100,000,000 items?
body: <p>Setting Items.Count in a ListView to any number over 100,000,000 has the same result as setting the count to 0 - is this a limitation of the underlying windows control, or Delphi specific? I expected the limit to be ~2 billion, since Delphi XE4's documentation says the limit is the size of a (signed) DWORD (ie: 2^31 - 1).</p>
  
  <p>Simple Example:</p>
  
  <pre><code>unit Unit1;
  
  interface
  
  uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls;
  
  type
    TForm1 = class(TForm)
      ListView1: TListView;
      procedure ListView1Data(Sender: TObject; Item: TListItem);
      procedure FormCreate(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  
  var
    Form1: TForm1;
  
  implementation
  
  {$R *.dfm}
  
  procedure TForm1.FormCreate(Sender: TObject);
  begin
    // Assumes ListView1.OwnerData := True;
    ListView1.Items.Count := 100000001; // Works if 100000000 is used instead
  end;
  
  procedure TForm1.ListView1Data(Sender: TObject; Item: TListItem);
  begin
    Item.Caption := Item.Index.ToString();
  end;
  
  end.
  </code></pre>
  
  <p>I did some poking around, sending LVM_SETITEMCOUNT directly to the underlying control, but it returns an error with any LPARAM over 100,000,000 and sets the internal count to 0, leading me to believe it's a limitation of the underlying control. I can't find this documented anywhere - although I assume that having that many items isn't common. Assuming this is a limitation of the control, should probably file a Delphi bug report since no exception gets thrown by TListView when the call fails - it just breaks everything silently.</p>
  
  <p>For now, I'm working around this by keeping the listview out of virtual mode, keeping exactly the number of items that are visible depending on the size of the control (ie: VisibleRowCount property) added to the list, maintaining an offset into my data, and looping over the items in the list to fill the list in essentially the same way as a virtual mode list, using my own scrollbar to control the offset to actually make the limit ~2 billion.</p>
  
  <p>Is there a way around this behavior? Any insight from anyone experienced with working with large amounts of data and a ListView?</p>