请问,delphi 那个控件象 ie 地址显示图标输入框控件呢?

解决方案 »

  1.   

    procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    var
      Bitmap: TBitmap;
      Offset: integer;
    begin
      Offset := 0;
      with (Control as TComboBox).Canvas do
      begin
        FillRect(Rect);
        Bitmap := TBitmap(SelectPort.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), clOlive);
          Offset := Bitmap.Width + 8;
        end;
        //     display the text
        TextOut(Rect.Left + Offset, Rect.Top, SelectPort.items[Index])
      end;
    end;
      

  2.   

    procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    var
      Bitmap: TBitmap;
      Offset: integer;
    begin
      Offset := 0;
      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), clOlive);
          Offset := Bitmap.Width + 8;
        end;
        //     display the text
        TextOut(Rect.Left + Offset, Rect.Top, ComboBox1.items[Index])
      end;
    end;