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 51 52 53 54 55 56 57 58 59 60
| uses DateUtils;
procedure RemplieCheckListBox(DateDebut,DateFin:TDateTime;CheckListBox:TCheckListBox);
var i:integer;
UneDate:TDate;
Debut,Fin:integer;
begin
Debut:=Trunc(DateDebut);
Fin:=Trunc(DateFin);
if Fin>=Debut
then begin
//Remplie la CheckBox
CheckListBox.Clear;
CheckListBox.Style:=lbOwnerDrawFixed;
for i:=Debut to Fin do
CheckListBox.AddItem(IntToStr(i),nil);
end;
end;
procedure DessineItem(CheckListBox: TCheckListBox;
Index: Integer; Rect: TRect);
var UneDateString,Affichage:string;
UneDate:TDate;
OffSet:Integer;
begin
{Le dessin se fait sur le canevas du contrôle,
pas dans la fiche }
with CheckListBox.Canvas do
begin
//Récupère les données
UneDateString:=CheckListBox.Items[Index];
UneDate:=StrToInt(UneDateString);
Affichage:=DateToStr(UneDate);
{efface le rectangle }
FillRect(Rect);
{fournit le décalage par défaut }
Offset :=2;
{Attention, on utilise DayOfTheWeek et non pas DayOfWeek}
case DayOfTheWeek(UneDate) of
6:Brush.Color:=clBlue; //Utliser Font au lieu de Brush, si on c'est le texte que l'on veux colorier
7:Brush.Color:=clred;
end;
{efface le rectangle }
FillRect(Rect);
{affiche le texte }
TextOut(Rect.Left,Rect.Top,Affichage);
end;
end;
function CalculeNbredeDatesCochees(CheckListBox: TCheckListBox):integer;
var i:integer;
begin
Result:=0;
for i:=0 to CheckListBox.Count-1 do
if CheckListBox.Checked[i] then inc(result);
end;
function CheckBoxItemToDate(CheckListBox: TCheckListBox; Index:Integer):TDateTime;
begin
Result:=StrToInt(CheckListBox.Items[Index]);
end; |
Partager