rt

解决方案 »

  1.   

    procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    var
      Bitmap: TBitmap;
      Offset: Integer;
      begin
      with (Control as TListBox).Canvas do
      begin
        FillRect(Rect);
        Offset := 2;
        //在这里取得图片,例子从TListBox.Items中取(如果添加项的时候指定了图片),也可以从一个
        //TImageList中取得
        Bitmap := TBitmap((Control as TListBox).Items.Objects[Index]);
        if Bitmap <> nil then
        begin
          BrushCopy(Bounds(Rect.Left + Offset, Rect.Top, Bitmap.Width, Bitmap.Height),
                  Bitmap, Bounds(0, 0, Bitmap.Width, Bitmap.Height), clRed);
          Offset := Bitmap.width + 6;
        end;
        TextOut(Rect.Left + Offset, Rect.Top, (Control as TListBox).Items[Index])
      end;
    end;————————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    ————————————————————————————————————