ITPub博客

首页 > 应用开发 > IT综合 > OICQ中用户图标选择的实现 (转)

OICQ中用户图标选择的实现 (转)

原创 IT综合 作者:worldblog 时间:2007-12-02 15:29:24 0 删除 编辑
OICQ中用户图标选择的实现 (转)[@more@]

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
  List1: TComboBox;
  Button1: TButton;
  procedure Button1Click(Sender: Tobject);
  procedure FormCreate(Sender: TObject);
  procedure List1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
  private
  { Private declarations }
  public
  { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
  var
s: String;
begin
 Randomize;
 s:= intTostr(Random(100));//LAST HERE!
 CreateDir(s);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Bit1,Bit2,Bit3,Bit4,Bit5,Bit6: TBitmap;
begin
  List1.Style := csOwnerDrawVariable;
  List1.ItemHeight := 30;
  Bit1 := TBitmap.Create;
  Bit1.LoadFromFile('C:Program FilesOicqface1-1.bmp');
  Bit2 := TBitmap.Create;
  Bit2.LoadFromFile('C:Program FilesOicqface2-1.bmp');
  Bit3 := TBitmap.Create;
  Bit3.LoadFromFile('C:Program FilesOicqface3-1.bmp');
  Bit4 := TBitmap.Create;
  Bit4.LoadFromFile('C:Program FilesOicqface4-1.bmp');
  Bit5 := TBitmap.Create;
  Bit5.LoadFromFile('C:Program FilesOicqface5-1.bmp');
  Bit6 := TBitmap.Create;
  Bit6.LoadFromFile('C:Program FilesOicqface6-1.bmp');
  List1.Items.AddObject('图标1',Bit1);
  List1.Items.AddObject('图标2',Bit2);
  List1.Items.AddObject('图标3', Bit3);
  List1.Items.AddObject('图标4', Bit4);
  List1.Items.AddObject('图标5', Bit5);
  List1.Items.AddObject('图标6', Bit6);
  List1.ItemIndex :=0;
end;

procedure TForm1.List1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
Bitmap: TBitmap;
Offset: Integer;
begin
  with(Control as TCombobox).Canvas do
  begin
  FillRect(Rect);
  Bitmap := TBitmap(List1.Items.Objects[Index]);
  //Bitmap := TBitmap.Create;
  //ImageList1.GetBitmap(Index,Bitmap);
  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),clRed);
  Offset := Bitmap.Width + 8;
  TextOut(Rect.Left+OffSet,Rect.Top,List1.Items[Index]);
  end;

  end;


end;

end.


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-987429/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    6241
  • 访问量
    2405700