关于在TListBox中加入色块的问题?请高手详细解答?

mhkk 2003-10-16 06:12:23
先谢了!
正在学习制作一个取色软件,想在TListBox中显示选取的颜色,但是每次选取后前面的颜色块都被换成了最后选取的颜色。应该如何解决?我的代码如下:
procedure TfrmCPicker.LBCjDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
tmpOldColor: TColor;
tmpShape:TShape;
begin
with (Control as TListBox) do
begin
tmpOldColor:=Canvas.Brush.Color;
Canvas.FillRect(Rect);
Canvas.Brush.Color:=RGBToColor(strtoint(EdRed.Text),strtoint(EdGreen.Text),strtoint(EdBlue.Text));
Canvas.Rectangle(Rect.Left+4,Rect.Top+1,(Rect.Right+Rect.Left)div 3,Rect.Bottom-1);
Canvas.Brush.Color:=tmpOldColor;
Canvas.TextOut((Rect.Left+Rect.Right)div 2,Rect.Top+4,(Control as TListBox).Items[Index]);
end;
end;

procedure TfrmCPicker.btnPickClick(Sender: TObject);
begin
LBCj.Items.Append(EdColor.Text);
end;
...全文
62 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dickeybird888 2003-11-03
  • 打赏
  • 举报
回复
lbcj.Items.Insert(0,EdColor.Text);
mhkk 2003-10-30
  • 打赏
  • 举报
回复
期待中
mhkk 2003-10-20
  • 打赏
  • 举报
回复
继续求教
mhkk 2003-10-17
  • 打赏
  • 举报
回复
怎么没有啊?
dickeybird888 2003-10-16
  • 打赏
  • 举报
回复
我下班了明天我来给你回答!
(·¥·)

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧