procedure TForm7.FormCreate(Sender: TObject);
begin
bmp:=Tbitmap.Create;
bmp.Transparent:=True;
bmp.TransparentMode:=tmauto;
bmp.LoadFromFile(ExtractFilePath(Application.ExeName)+''user.bmp'');
end;
procedure TForm7.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
int,int2,int3:integer;
OldBkMode: integer;
myrect,Myrect2:Trect;
oldbs:TbrushStyle;
Fcolor:Tcolor;
Begin
myrect.Top:=rect.top;
myrect.Bottom:=rect.Bottom;
myrect.Left :=Rect.Left;
Myrect.Right:=Rect.Left+Bmp.Width+2;
Myrect2.Top:=rect.bottom;
Myrect2.Left:=Myrect.Left;
Myrect2.Right:=Myrect.Right;
Myrect2.Bottom:=ListBox1.Height;
if index=ListBox1.Count-1 then
DrawGradient(Listbox1.Canvas,Myrect2,true,[$00FDF6F6,$00D9C9C9]);
if (index <> 0) and (index <> 6)then
begin
ListBox1.Canvas.TextRect(rect,rect.left+bmp.width+3,rect.top+3,ListBox1.Items[Index]);
int:= index mod 2;
if int = 0 then
begin
ListBox1.Canvas.Brush.Color:=RGB(242,245,253);
ListBox1.Canvas.pen.Style :=psclear;
ListBox1.Canvas.RoundRect(Rect.Left+bmp.Width,Rect.Top,rect.Right,
rect.bottom,0,0);
OldBkMode := SetBkMode(ListBox1.Canvas.Handle, TRANSPARENT);
ListBox1.Canvas.TextRect(rect,rect.left+bmp.Width+3,rect.top+3,
ListBox1.Items[Index]);
SetBkMode(ListBox1.Canvas.Handle, OldBkMode);
end;
end;
if (index <> 0) and (index <> 6) then
begin
DrawGradient(Listbox1.Canvas,Myrect,true,[$00FDF6F6,$00D9C9C9]);
end;
if (index=0) or (index = 6) then
begin
ListBox1.Canvas.Font.Style:=[fsBold];
DrawGradient(Listbox1.Canvas,Rect,false,[$00FDF6F6,$00D9C9C9]);
ListBox1.Canvas.Brush.Color:=$00947C7C;
ListBox1.Canvas.FrameRect(Rect);
oldbs:=ListBox1.Canvas.Brush.Style;
Listbox1.Canvas.Brush.Style:=bsclear;
Fcolor:=ListBox1.Canvas.Font.Color;
ListBox1.Canvas.Font.Color:=clMedGray;
DrawText(ListBox1.Canvas.Handle,Pchar(ListBox1.Items[Index]),
length(ListBox1.Items[Index]),rect,
DT_SINGLELINE or DT_CENTER or DT_VCENTER);
ListBox1.Canvas.Font.Color:=Fcolor;
ListBox1.Canvas.Brush.Style:=oldbs;
end;
if (index <> 0) and (index <> 6) then
begin
if odselected in state then
begin
ListBox1.Canvas.pen.Width:=1;
ListBox1.Canvas.pen.Color :=$00947C7C;
ListBox1.Canvas.pen.Style :=pssolid;
ListBox1.Canvas.Brush.Color:=$00C2EEFF;
ListBox1.Canvas.Rectangle(rect.Left,rect.Top,rect.Right,rect.bottom);
oldbs:=ListBox1.Canvas.Brush.Style;
ListBox1.Canvas.Brush.Style:=bsclear;
ListBox1.Canvas.TextRect(rect,rect.left+bmp.Width+3,rect.top+3,
ListBox1.Items[Index]);
ListBox1.Canvas.Brush.Style:=oldbs;
end;
end;
if index = 5 then
ListBox1.Canvas.Draw(rect.Left,Rect.Top,bmp);
if odFocused in State then
ListBox1.Canvas.DrawFocusRect(Rect);
end;
|