| 发表于:2007-07-31 09:44:121楼 得分:0 |
procedure tform4.listbox1drawitem(control: twincontrol; index: integer; rect: trect; state: townerdrawstate); var frect: trect; begin frect := listbox1.itemrect(index); if odhotlight in state then begin listbox1.canvas.brush.color := cllime; listbox1.canvas.fillrect(frect); listbox1.canvas.textout(frect.left, frect.top, listbox1.items[index]); end else if odselected in state then begin listbox1.canvas.brush.color := clblue; listbox1.canvas.fillrect(frect); listbox1.canvas.drawfocusrect(frect); listbox1.canvas.textout(frect.left, frect.top, listbox1.items[index]); end else begin listbox1.canvas.brush.color := clwhite; listbox1.canvas.fillrect(frect); listbox1.canvas.textout(frect.left, frect.top, listbox1.items[index]); end; end; procedure tform4.listbox1mousemove(sender: tobject; shift: tshiftstate; x, y: integer); var frect: trect; i, fitem: integer; state: townerdrawstate; begin fitem := listbox1.itematpos(point(x, y), true); if fitem > -1 then begin frect := listbox1.itemrect(fitem); for i := 0 to listbox1.count - 1 do begin state := [oddefault]; if i = fitem then include(state, odhotlight); if listbox1.itemindex = i then include(state, odselected); listbox1drawitem(listbox1, i, frect, state) end; end; end; | | |
|