user1580348
user1580348

Reputation: 6061

Shifting the erroneous horizontal position of SubItemImages in a Delphi TListView?

In a Delphi TListView, is it possible to shift the erroneous horizontal position of SubItemImages, as they are drawn too far left? Something like this, for example (pseudo-code, which just shows the intention):

x := MyListView.Items[i].SubItemImages[2].HorizontalPosition;
MyListView.Items[i].SubItemImages[2].HorizontalPosition := x + 2;

This screenshot which shows the bug:

enter image description here

Upvotes: 3

Views: 2080

Answers (1)

Ken White
Ken White

Reputation: 125748

No. TListItem.SubItemImages is an integer, and integers don't have horizontal positions.

property SubItemImages[Index: Integer]: Integer read GetSubItemImage 
  write SetSubItemImage;

You can find this out by looking at the VCL source code, in this case in the ComCtrls unit. The relevant code is in TListItem.GetSubItemImage (code from XE3 shown below, but it's the same as the code in previous versions of Delphi).

function TListItem.GetSubItemImage(Index: Integer): Integer;
begin
  Result := TSubItems(FSubItems).ImageIndex[Index];
end;

As far as I can see from the MSDN documentation, there's no way to change that image's location. The columns are created by sending the underlying Windows ListView control an LVCOLUMN record (structure) for each column's definition, which has no location information available to assign. It has a flag to set the image right-aligned (LVCFMT_BITMAP_ON_RIGHT), but nothing else to allow you to actually position the image to a specific location in the column.

Upvotes: 3

Related Questions