有这样的控件包, lmd. abc里头都有。

解决方案 »

  1.   

    下面是我的一段程序
    在listbox和combobox中加入图片unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, ExtCtrls;type
      TForm1 = class(TForm)
        Panel1: TPanel;
        Label2: TLabel;
        ListBox1: TListBox;
        ComboBox1: TComboBox;
        Label1: TLabel;
        procedure FormCreate(Sender: TObject);
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
        procedure ComboBox1DrawItem(Control: TWinControl; Index: Integer;
          Rect: TRect; State: TOwnerDrawState);
        procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
          Rect: TRect; State: TOwnerDrawState);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      MyBitmap1, MyBitmap2, MyBitmap3, MyBitmap4: TBitmap; 
    implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
    begin
    MyBitmap1 := TBitmap.Create;
     MyBitmap1.LoadFromFile('.\1.bmp');
     MyBitmap2 := TBitmap.Create;
     MyBitmap2.LoadFromFile('.\2.bmp');
       MyBitmap3 := TBitmap.Create;
     MyBitmap3.LoadFromFile('.\3.bmp');
     MyBitmap4 := TBitmap.Create;
     MyBitmap4.LoadFromFile('.\4.bmp');
       ComboBox1.Items.AddObject('Bitmap1', MyBitmap1);
     ComboBox1.Items.AddObject('Bitmap2', MyBitmap2);
     ComboBox1.Items.AddObject('Bitmap3', MyBitmap3);
     ComboBox1.Items.AddObject('Bitmap4', MyBitmap4);
     ListBox1.Items.AddObject('Bitmap1', MyBitmap1);
     ListBox1.Items.AddObject('Bitmap2', MyBitmap2);
     ListBox1.Items.AddObject('Bitmap3', MyBitmap3);
     ListBox1.Items.AddObject('Bitmap4', MyBitmap4);
    end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
         MyBitmap1.Free; 
     MyBitmap2.Free;
     MyBitmap3.Free;
     MyBitmap4.Free;
    end;procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    var Bitmap: TBitmap; Offset: Integer; 
    begin
     offset:=0;
     with ComboBox1.Canvas do
     begin
     FillRect(Rect);
     Bitmap := TBitmap(ComboBox1.Items.Objects[Index]);
     if Bitmap <> nil then {粘贴图片}
     begin{适当的空档使图片关系分明,clred为透明色}
     BrushCopy(Bounds(Rect.Left + 2, Rect.Top + 2, Bitmap.Width,
     Bitmap.Height), Bitmap, Bounds(0, 0, Bitmap.Width,
     Bitmap.Height), clred);
     Offset := Bitmap.width + 8; {图片与文字的间隔,以组件的Left属性计算}
     end;
     TextOut(Rect.Left + Offset, Rect.Top, ComboBox1.Items[Index]); {显示文字}
    end;
    end;procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    var Bitmap: TBitmap; Offset: Integer; 
    begin
     offset:=0;
     with ListBox1.Canvas do
     begin
       FillRect(Rect);
       Bitmap := TBitmap(ListBox1.Items.Objects[Index]);
       if Bitmap <> nil then{粘贴图片}
       begin
         BrushCopy(Bounds(Rect.Left + 2, Rect.Top + 2, Bitmap.Width,
         Bitmap.Height), Bitmap, Bounds(0, 0, Bitmap.Width,
         Bitmap.Height), clRed);
         Offset := Bitmap.width + 8; {图片与文字的间隔,以组件的Left属性计算}
       end;
       TextOut(Rect.Left + Offset, Rect.Top, ListBox1.Items[Index]); {显示文字}
     end;
    end;end.