zoukankan      html  css  js  c++  java
  • 五彩下拉框

    unit Unit4;

    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;

    type
      TForm4 = class(TForm)
        ComboBox1: TComboBox;
        procedure ComboBox1DrawItem(Control: TWinControl; Index: Integer;
          Rect: TRect; State: TOwnerDrawState);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form4: TForm4;

    implementation

    {$R *.dfm}

    procedure TForm4.FormCreate(Sender: TObject);
    begin
      with ComboBox1.Items do
      begin
        Add(IntToStr(clRed));
        Add(IntToStr(clFuchsia));
        Add(IntToStr(clBlue));
        Add(IntToStr(clGreen));
        Add(IntToStr(clYellow));

      end;
    end;

    procedure TForm4.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    var
      R: TRect;
    begin
      R:=Rect;
      with Control as TComboBox,Canvas do
      begin
        Brush.Color:=clWhite;
        FillRect(R);
        InflateRect(R,-2,-2);
        Brush.Color:=StrToInt(Items[Index]);
        FillRect(R);
      end;

    end;

    end.

  • 相关阅读:
    别样JAVA学习(六)继承下(2.3)异常下
    Reverse Integer
    Win10易升-在线升级工具
    yum实现仅仅下载不安装包
    redis对key的基本操作
    Win一键查看用户密码
    Linux常用基本命令
    mysql用户管理
    Linux下grub.cnf详解
    图片MassiGra045 简体中文|MG
  • 原文地址:https://www.cnblogs.com/huking/p/1693335.html
Copyright © 2011-2022 走看看