How to increase row height of listview in report style?

maxfax picture maxfax · Aug 15, 2011 · Viewed 9.3k times · Source

I need to add just 2px :) to a height of a row in a list view (a custom drawn progress bar is too narrow now).

There are two good answers Change Listview item height, http://www.delphipages.com/forum/showthread.php?t=49939, but I couldn't do it.

I know that it is possible to do with an image list, but I have already 16x16 images :)

Can anybody help me? I'll appreciate it.

Answer

NGLN picture NGLN · Aug 15, 2011

Respond to the CN_MEASUREITEM control notification message, as follows:

type
  TListView = class(ComCtrls.TListView)
  private
    procedure CNMeasureItem(var Message: TWMMeasureItem); message CN_MEASUREITEM;
  end;

  TForm1 = class(TForm)
    ...

procedure TListView.CNMeasureItem(var Message: TWMMeasureItem);
begin
  inherited;
  Inc(Message.MeasureItemStruct.itemHeight, 2);
end;

Note: this message will only be send if the OwnerDraw property is true.