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

📄 mainfrm.~pas

📁 关于利用DELPHI来进行企业级方案解决的著作的附书源码
💻 ~PAS
字号:
unit MainFrm;

interface

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

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

var
  Form1: TForm1;
  Pic1,Pic2,Pic3,Pic4,Pic5:TBitmap;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
 Pic1:=TBitmap.Create;
 Pic1.LoadFromFile('floppy.bmp');
 Pic2:=TBitmap.Create;
 Pic2.LoadFromFile('harddisk.bmp');
 Pic3:=TBitmap.Create;
 Pic3.LoadFromFile('cdrom.bmp');
 Pic4:=TBitmap.Create;
 Pic4.LoadFromFile('net.bmp');
 Pic5:=TBitmap.Create;
 Pic5.LoadFromFile('ram.bmp');
 ComboBox1.Items.AddObject('这是软盘的图形符号',Pic1);
 ComboBox1.Items.AddObject('这是硬盘的图形符号',Pic2);
 ComboBox1.Items.AddObject('这是光盘的图形符号',Pic3);
 ComboBox1.Items.AddObject('这是网络存储器的图形符号',Pic4);
 ComboBox1.Items.AddObject('这是RAM存储器的图像符号',Pic5);
end;

procedure TForm1.FormDestroy(Sender: TObject);
var i:Integer;
begin
 for i:=1 to 5 do
  FindComponent('Pic'+ IntToStr(i)).Free;
end;

procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
 Pic:TBitmap;
 Offset:Integer;
begin
 with TComboBox(Control).Canvas do
  begin
   FillRect(Rect);
   Pic:=TBitmap(ComboBox1.Items.Objects[Index]);
   if Pic<>nil then
    begin
     BrushCopy(Bounds(Rect.Left+2,Rect.Top+2,Pic.Width,Pic.Height),
     Pic,Bounds(0,0,Pic.Width,Pic.Height),clRed);
     Offset:=Pic.Width+8;
    end;
    TextOut(Rect.Left+Offset,Rect.Top,ComboBox1.Items[Index])
  end;
end;

procedure TForm1.ComboBox1MeasureItem(Control: TWinControl; Index: Integer;
  var Height: Integer);
begin
 Height:=40;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var i:Integer;
begin
 for i:=1 to 5 do
 TBitmap(FindComponent('Pic'+ IntToStr(i))).Free;
end;

end.

⌨️ 快捷键说明

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