Código
//Função para pegar a posição do subitem
function TForm2.GetSubItemRect(const Item: TListItem; const SubItem: integer; Code: TDisplayCode = drBounds): TRect;
var
ARect: TRect;
const
Codes: array[TDisplayCode] of Longint = (LVIR_BOUNDS, LVIR_ICON, LVIR_LABEL, LVIR_SELECTBOUNDS);
begin
// Adicione em Uses CommCtrl
ListView_GetSubItemRect(Item.ListView.Handle, Item.Index, SubItem, Codes[Code], @ARect);
Result := ARect;
end;
//no evendo OnCustomDrawItem, adicione:
procedure TForm2.ListView1CustomDrawSubItem(Sender: TCustomListView;
Item: TListItem; SubItem: Integer; State: TCustomDrawState;
var DefaultDraw: Boolean);
var
SubItemRect : TRect;
begin
// Coloque aqui o número da última coluna
if SubItem = 2 then
begin //1 é o número do subitem onde será pintada a imagem
SubItemRect := GetSubItemRect(Item, 1);
Sender.Canvas.Draw(SubItemRect.left + 10, SubItemRect.top, Image1.Picture.Graphic);
end
end;
Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009