Autor Beitrag
NOS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 183
Erhaltene Danke: 2

Win XP, Win Vista Ultimate, Win 7 Ultimate
Delphi 19.4 - Sydney
BeitragVerfasst: Di 28.09.10 13:05 
Hallo zusammen,

ich suche eine Möglichkeit ein bild / icon vor jedem eintrag in einer combobox zu platzieren oder eine entsprechende componente die das schon kann per imagelist oder so ..

Weiß jemand rat ?

LG und Danke,

Andreas
Pepp3r
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82



BeitragVerfasst: Di 28.09.10 13:29 
Etwa so:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
procedure FormCreate(Sender: TObject);
var
  bitmap: TBitmap;
begin
  ComboBox1.Sytle := csOwnerDrawVariable;
  bitmap := TBitmap.Create;
  bitmap.LoadFromFile(bildpfad);
  ComboBox1.Items.AddObject('ein Bild', bitmap);
end;

procedure 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
      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;
    end;
    TextOut(Rect.Left + Offset, Rect.Top, Combobox1.Items[Index]);
  end;
end;


...und nicht vergessen die bitmaps wieder frei zu geben ;)