I made a program like :
 
var
   bmp1, bmp2, bmp3, bmp3, bmp4, bmp5, bmp6 : TBitmap;
 
procedure TForm1.FormCreate(Sender: TObject);
// =====================================================================
  begin
// Criate the bitmaps
    Bmp1 := TBitmap.Create;
    Bmp2 := TBitmap.Create;
    Bmp3 := TBitmap.Create;
    Bmp4 := TBitmap.Create;
    Bmp5 := TBitmap.Create;
    Bmp6 := TBitmap.Create;
// Load the bitmaps
    Bmp1.LoadFromFile('bitmap1.bmp');
    Bmp2.LoadFromFile('bitmap2.bmp');
    Bmp3.LoadFromFile('bitmap3.bmp');
    Bmp4.LoadFromFile('bitmap4.bmp');
    Bmp5.LoadFromFile('bitmap5.bmp');
    Bmp6.LoadFromFile('bitmap6.bmp');
// Add text to the ComboBox object item
    CB_Modelo.Items.AddObject('Text1',Bmp1);
    CB_Modelo.Items.AddObject('Text2',Bmp2);
    CB_Modelo.Items.AddObject('Text3',Bmp3);
    CB_Modelo.Items.AddObject('Text4',Bmp4);
    CB_Modelo.Items.AddObject('Text5',Bmp5);
    CB_Modelo.Items.AddObject('Text6',Bmp6);
  end;
procedure TForm1.FormClose(Sender: TObject;var Action: TCloseAction);
  begin
    Bmp1.Free;
    Bmp2.Free;
    Bmp3.Free;
    Bmp4.Free;
    Bmp5.Free;
    Bmp6.Free;
  end;

procedure TFrm_OrcamentoBandos.CB_ModeloDrawItem
          (Control: TWinControl; Index: Integer; Rect: TRect;State: TOwnerDrawState);
  var
      Bitmap : TBitmap;
      Offset : Integer;
  begin
    With (Control as TComboBox).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;
        // Show the text
        TextOut(Rect.Left + Offset, Rect.Top, ComboBos1.Items[Index])
       end;
  end;
procedure TForm1.CB_ModeloMeasureItem(Control: TWinControl;Index: Integer;         var Height: Integer);
  begin
    height := 64;
  end;

and it worked very well, but now i have to put in the same form, another ComboBox and add new bitmaps and new texts. When the program runs, only one of the ComboBoxes display it's content (bitmap and text) and the other one only shows the text (why ?????)
 
Other question (sorry my ignorance !!) is How to Wrap lines in ComboBoxes Items ???
 
Thanks in advance.
 
Joćo Alberto Licht Teixeira
 
 

Reply via email to