| 12
 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
 51
 52
 53
 54
 
 | __fastcall jListBox::jListBox(TComponent *Owner)
    : TCustomControl(Owner)
{
if(Owner->InheritsFrom(__classid(TWinControl))) Parent = (TWinControl*)Owner;
Bitmap = new Graphics::TBitmap;
Items = new TStringList;
SetBounds(20,20,200,200);
}
 
__fastcall jListBox::~jListBox()
{
delete Bitmap; Bitmap = NULL;
Items->Clear(); delete Items;
}
 
void __fastcall jListBox::Paint()
{
if(Bitmap != NULL)
    {
    //Ajuster les dimensions du bitmap sur celles de l'objet
    int we = Width;
    int he = Height;
    if(Bitmap->Width != we) Bitmap->Width = we;
    if(Bitmap->Height != he) Bitmap->Height = he;
    //Le dessin se fait sur le bitmap
    TCanvas *C = Bitmap->Canvas;
    //Effacer avec la couleur de fond du parent
    C->Brush->Color = Parent->Brush->Color;
    C->Brush->Style = bsSolid;
    C->FillRect(Rect(0, 0, we, he));
    //Dessiner le rectangle arrondi de la listbox
    C->Brush->Color = (TColor)0x00FFDFBF;
    C->Pen->Color = clSilver;
    C->Pen->Style = psSolid;
    C->Pen->Mode = pmCopy;
    C->RoundRect(4,4,Width - 20, Height - 20, 8,8);
    //Dessiner le texte...
    //...
    //...
    //Dessiner le corps du slider vertical
    C->RoundRect(Width-16, 4, Width-4, Height-20, 8,8);
    //dessiner le corps du slider horizotal
    C->RoundRect(4, Height-16, Width - 20, Height-4, 8,8);
    C->Brush->Color = (TColor)0x00FF8306;
    //dessiner le bouton du slider vertical
    C->RoundRect(Width-16, 4, Width-4, 24, 8,8);
    //dessiner le bouton du slider horizontal
    C->RoundRect(4, Height-16, 24, Height-4, 8,8);
    //S'il faut rajouter des bords 3D, ce serait ici...
    //...
    //Dessiner le bitmap dans la zone client de l'objet
    Canvas->Draw(0, 0, Bitmap);
    }
} | 
Partager