Thema: Delphi Combobox mit Bitmaps

Einzelnen Beitrag anzeigen

Bomberbb

Registriert seit: 23. Sep 2003
227 Beiträge
 
#1

Combobox mit Bitmaps

  Alt 30. Nov 2007, 11:33
Hallo,

Ich will eine Combobox erweitern. Es sollten Bilder vor die Einträge gezeichnet werden. Das wird auch schon gemacht.
Delphi-Quellcode:
Procedure TForm4.TntComboBox1DrawItem(Control : TWinControl;Index : Integer;
  Rect : TRect;State : TOwnerDrawState);
Var
  Bitmap : TBitmap;
  Offset : Integer;
  Colorloc : TColor;
Begin
  offset := 0;
  With TNTComboBox1.Canvas Do
  Begin
    Colorloc := Color;
    FillRect(Rect);
    If tLayer(TNTComboBox1.Items.Objects[index]).IsVisible Then
      Bitmap := Layerlist.BmpLayerOn
    Else
      Bitmap := Layerlist.BmpLayerOff;
    //copy bitmap to combobox coordinate
    BrushCopy(Bounds(Rect.Left +2, Rect.Top , 16, 16), Bitmap, Bounds(0, 0, 16, 16), clred);

    //Set a caption to each item
    Font.size := 10;
    TextOut(Rect.Left + 40, Rect.Top, TNTCombobox1.Items[Index]);

    Brush.Color := tLayer(TNTComboBox1.Items.Objects[index]).GetColor;
    FillRect(Bounds(Rect.Left + 20, Rect.Top + 1, 14, 14));
  End;
End;
Allerdings möchte ich bei einem Klick auf die verschiedenen Elemente eines Items unterschiedliche Sachen ausführen.
Leider habe ich keine Ahnung wie ich herausfinden kann auf welchen Bereich geklickt wurde...

Hat jemand eine Idee???
  Mit Zitat antworten Zitat