zoukankan      html  css  js  c++  java
  • combox添加图标代码节选

    首先: 这有现成的控件: TComboBoxEx, 没必要使用 TComboBox; 非要在 TComboBox 基础上添加, 也可以.

    var
      Bits: array[0..3] of TBitmap;

    procedure TForm1.FormCreate(Sender: TObject);
    var
      i: Integer;
    begin
      for i := 0 to Length(Bits)-1 do
      begin
        Bits[i] := TBitmap.Create;
        il1 .GetBitmap(i, Bits[i]);
        cbb1 .Items.Add(Format('Item %d', [i]));
      end;

      cbb1.Style := csOwnerDrawVariable;
      cbb1.ItemHeight := Bits[0].Height + 4;
      cbb1.ItemIndex :=2;
    end;


    procedure TForm1.FormDestroy(Sender: TObject);
    var
      i: Integer;
    begin
      for i := 0 to Length(Bits)-1 do
        Bits[i].Free;
    end;

    procedure TForm1.cbb1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    begin
      cbb1 .Canvas.FillRect(Rect);
      cbb1 .Canvas.BrushCopy(Bounds(Rect.Left+2, Rect.Top+2, Bits[Index].Width, Bits[Index].Height),
                                 Bits[Index],
                                 Bounds(0, 0, Bits[Index].Width, Bits[Index].Height),
                                 clBlack);
      cbb1.Canvas.TextOut(Rect.Left + 24, Rect.Top + 3, cbb1 .Items[Index]);

    end;

    end.

  • 相关阅读:
    循环移位算法
    关于Java中2.0-1.1!=0.9的问题
    Java基础语法(三)
    Java基础语法(二)
    Java基础语法(一)
    关于Java运行机制
    Java从零开始(前篇)
    关于.ssh目录下的known_hosts文件的补充
    解决 bash cd too many arguments 报错
    Markdown学习笔记(一)
  • 原文地址:https://www.cnblogs.com/feng801/p/1286760.html
Copyright © 2011-2022 走看看