procedure TForm1.FormCreate(Sender: TObject);
var lauf: Integer;
count,Zaehler: Integer;
row: Integer;
year: Word;
month: Word;
firstMonday: Word;
day: Word;
begin
Zaehler:=0;
row:=1;
count:=0;
Tage:=DaysInMonth(date);
DecodeDate(date,year,month,firstMonday);
DecodeDate(LastDayOfWeekOfMonth(year,month,1),year,month,firstMonday);
while firstMonday > 7
do
begin
firstMonday:=firstMonday-7;
end;
if not firstMonday > 7
then
begin
With Kalender
do
begin
dec(firstMonday);
Cells[firstMonday,0]:='
Montag';
inc(firstMonday);
if not (firstMonday >= 7)
then
begin
Cells[firstMonday,0]:='
Dienstag';
inc(firstMonday);
end
else
begin
ShowMessage('
ELSE-HANDLER GREIFT BEI FALL: '+IntToStr(firstMonday)+'
!');
firstMonday:=0;
Cells[firstMonday,0]:='
Dienstag';
inc(firstMonday);
end;
if not (firstMonday >= 7)
then
begin
Cells[firstMonday,0]:='
Mittwoch';
inc(firstMonday);
end
else
begin
ShowMessage('
ELSE-HANDLER GREIFT BEI FALL: '+IntToStr(firstMonday)+'
!');
firstMonday:=0;
Cells[firstMonday,0]:='
Mittwoch';
inc(firstMonday);
end;
if not (firstMonday >= 7)
then
begin
Cells[firstMonday,0]:='
Donnerstag';
inc(firstMonday);
end
else
begin
ShowMessage('
ELSE-HANDLER GREIFT BEI FALL: '+IntToStr(firstMonday)+'
!');
firstMonday:=0;
Cells[firstMonday,0]:='
Donnerstag';
inc(firstMonday);
end;
if not (firstMonday >= 7)
then
begin
Cells[firstMonday,0]:='
Freitag';
inc(firstMonday);
end
else
begin
ShowMessage('
ELSE-HANDLER GREIFT BEI FALL: '+IntToStr(firstMonday)+'
!');
firstMonday:=0;
Cells[firstMonday,0]:='
Freitag';
inc(firstMonday);
end;
if not (firstMonday >= 7)
then
begin
Cells[firstMonday,0]:='
Samstag';
inc(firstMonday);
end
else
begin
ShowMessage('
ELSE-HANDLER GREIFT BEI FALL: '+IntToStr(firstMonday)+'
!');
firstMonday:=0;
Cells[firstMonday,0]:='
Samstag';
inc(firstMonday);
end;
if not (firstMonday >= 7)
then
begin
Cells[firstMonday,0]:='
Sonntag';
end
else
begin
ShowMessage('
ELSE-HANDLER GREIFT BEI FALL: '+IntToStr(firstMonday)+'
!');
firstMonday:=0;
Cells[firstMonday,0]:='
Sonntag';
end;
end;
end;
DecodeDate(date,year,month,day);
for lauf := 1
to Tage
do
begin
Inc(Zaehler);
if count = 7
then
begin
count:=0;
inc(row);
Kalender.Cells[count,row]:=IntToStr(lauf);
inc(count);
end
else
begin
Kalender.Cells[count,row]:=IntToStr(lauf);
inc(count);
end;
if EncodeDate(year,month,zaehler)=date
then
begin
Kalender.objects[count,row]:=TObject(1);
//<-Das Tuts nicht
end;
end;
//DecodeDate(date,year,month,day); //<-Das war meine erste Idee funzt auch nicht
//Kalender.objects[day mod 7,day div 7]:=TObject(1); // da wird immer (gestern und heute) der 22te eingefärbt
end;