1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
TRect gRect, dRect;
//
gRect.top = Rect.top;
gRect.left = Rect.left;
gRect.bottom = Rect.bottom;
gRect.right = ((Rect.right - Rect.left)/2) - 12;
//
dRect.top = Rect.top;
dRect.bottom = dRect.bottom;
dRect.right = Rect.right;
dRect.left = ((Rect.right - Rect.left)/2) - 12;
////
ComboBox1->Canvas->FillRect(Rect);
if (State.Contains(odSelected) || State.Contains(odFocused))
{
ComboBox1->Canvas->Brush->Color = clMoneyGreen;
ComboBox1->Canvas->Font->Color = clBlack;
ComboBox1->Canvas->Font->Style = TFontStyles() << fsBold;
ComboBox1->Canvas->DrawFocusRect(Rect);
}
else
{
ComboBox1->Canvas->Brush->Color = clWindow;
ComboBox1->Canvas->Font->Color = clNavy;
ComboBox1->Canvas->Font->Style = TFontStyles();
}
////
String S, gTexte, dTexte, coche;
S = ComboBox1->Items->Strings[Index];
int sep = S.AnsiPos("/");
//texte gauche
gTexte = S.SubString(0, (sep-1));
//texte droite
dTexte = S.SubString((sep+1), (S.Length()- gTexte.Length() - 3));
//coche
coche = S.SubString(S.Length(), 1);
//
int gw, gl, dw, dl;
//position texte gauche
gw = ComboBox1->Canvas->TextExtent(gTexte).cx;
gl = (gRect.Width() - gw)/2;
//position texte droite
dw = ComboBox1->Canvas->TextExtent(dTexte).cx;
dl = gRect.Width() + ((dRect.Width() - dw)/2);
//restitution
ComboBox1->Canvas->TextRect(gRect, gl, gRect.top, gTexte);
ComboBox1->Canvas->TextRect(dRect, dl, dRect.top, dTexte);
IML->Draw(ComboBox1->Canvas, (Rect.right - IML->Width), Rect.top, StrToInt(coche), true); |
Partager