1,183
社区成员
发帖
与我相关
我的任务
分享
procedure TFrmSaveBmp.fontcolorDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
TempColor:TColor; //自画颜色
TempBrushColor:TColor; //临时颜色
begin
with(fontcolor)do
begin
TempBrushColor:=Canvas.Brush.Color;
//保存原来的的颜色
Canvas.FillRect(Rect);
case Index of//根据Index 的不同,定义不同自画的颜色
0://红色
TempColor:=clRed;
1://黄色
TempColor:=clyellow;
2://鲜绿
TempColor:=clLime;
//可以在此加入对其它颜色的响应
end;
Canvas.Brush.Color:=TempColor;
//自画颜色矩形
Canvas.Rectangle(Rect.Left+2,Rect.Top+1,(Rect.Right+Rect.Left) div 3, Rect.Bottom-1);
Canvas.Brush.Color:=TempBrushColor;
//显示与颜色对应的字符串
Canvas.TextOut((Rect.Left+Rect.Right) div 2-6,Rect.Top+1,Items[Index]);
end;
end;