본문 바로가기

카테고리 없음

[일반/컴포넌트] ListView 의 column header 오른쪽에 이미지 넣기

>    When I set ImageIndex of TListColumn to 1, an image appears to the left
> side of the column header.  But I wish the image appears to the right side
> of the column header,as commonly seen. I don't know how.

You can specify the HDF_BITMAP_ON_RIGHT format (requires comctl32.dll version
4.70+ IE3+) by using the Header_GetItem() and Header_SetItem() macros...

const
  HDF_BITMAP_ON_RIGHT = $1000;

var
  hdi: THDItem;
  HeaderHandle: THandle;

begin
  HeaderHandle := GetDlgItem(ListView1.Handle, 0);
  for i := 0 to ListView1.Columns.Count - 1 do
  begin
    Header_GetItem(HeaderHandle, i, hdi);
    hdi.mask := HDI_FORMAT;
    hdi.fmt := HDF_STRING or HDF_BITMAP or HDF_BITMAP_ON_RIGHT;
    Header_SetItem(HeaderHandle, i, hdi);
  end;
end;