Listbox diferente
24/09/2004
0
como eu faço para que quando o meu mouse passar por um dos itens de um listbox mudar de cor
Anicetojunior
Curtir tópico
+ 0
Responder
Posts
24/09/2004
Beppe
Isto vai em public: ItemCorrente: Integer;
ListBox1.Style := lbsOwnerDrawFixed; // ou lbsOwnerDrawVariable
E configure estes eventos:
ListBox1.Style := lbsOwnerDrawFixed; // ou lbsOwnerDrawVariable
E configure estes eventos:
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); begin with TListBox(Control), Canvas do begin if Index = ItemCorrente then Brush.Color := clGreen; FillRect(Rect); TextOut(Rect.Left, Rect.Top, Items[Index]); end; end; procedure TForm1.ListBox1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var NovoItem: Integer; begin with TListBox(Sender) do begin NovoItem := ItemAtPos(ScreenToClient(Mouse.CursorPos), True); if NovoItem <> ItemCorrente then begin ItemCorrente := NovoItem; TListBox(Sender).Invalidate; end; end; end;
Responder
Clique aqui para fazer login e interagir na Comunidade :)