⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 Delphi高级界面特效制作百例源代码,这是随书源代码部分,不知可否
💻 PAS
字号:
unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.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 TForm1.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.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -