1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
TCanvas* pCanvas = ((TListBox *)Control)->Canvas; //pointeur canvas
TListBox* pListBox = (TListBox *)Control;//pointeur listbox
AnsiString Valeur = pListBox->Items->Strings[Index];//récup valeur sélectionnée
if ((Index%2)==0)
pCanvas->Font->Color = clRed; // met 1 texte sur 2 en rouge
if (State.Contains(odSelected))//si objet sélectionné
{
pCanvas->Brush->Color = clBlue;//
pCanvas->FillRect(Rect); //couleur de sélection
pCanvas->Font->Color = clWhite;//
}
else//sinon
{
pCanvas->FillRect(Rect); //couleur choisie
}
pCanvas->TextOut(Rect.Left+5,Rect.Top+2,pListBox->Items->Strings[Index]);//texte |