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 files\oicq\face\1-1.bmp'');
bit2 := tbitmap.create;
bit2.loadfromfile(''c:\program files\oicq\face\2-1.bmp'');
bit3 := tbitmap.create;
bit3.loadfromfile(''c:\program files\oicq\face\3-1.bmp'');
bit4 := tbitmap.create;
bit4.loadfromfile(''c:\program files\oicq\face\4-1.bmp'');
bit5 := tbitmap.create;
bit5.loadfromfile(''c:\program files\oicq\face\5-1.bmp'');
bit6 := tbitmap.create;
bit6.loadfromfile(''c:\program files\oicq\face\6-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.