unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls, ExtCtrls, Calendar, ColorGrd;
type
TForm1 =
class(TForm)
StringGrid1: TStringGrid;
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Panel3Click(Sender: TObject);
procedure Panel4Click(Sender: TObject);
procedure Monat_plus;
procedure Monat_minus;
procedure StringGrid1DblClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Monat :
array[1..12]
of String;
Monata: integer;
Jahr: integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
I: Integer;
Vorm: Integer;
Norm: Integer;
begin
StringGrid1.Cells[0,0] :='
...';
StringGrid1.ColWidths[0] := 70;
for I := 1
to 31
do begin
StringGrid1.Cells[I,0] :='
'+ inttostr(I);
end;
StringGrid1.Cells[32,0] :='
...';
StringGrid1.ColWidths[32] := 70;
for I := 1
to 5
do begin
StringGrid1.RowHeights[I] := 100;
end;
StringGrid1.LeftCol:=1;
Monat[1]:='
Januar';
Monat[2]:='
Februar';
Monat[3]:='
März';
Monat[4]:='
April';
Monat[5]:='
Mai';
Monat[6]:='
Juni';
Monat[7]:='
Juli';
Monat[8]:='
August';
Monat[9]:='
September';
Monat[10]:='
Oktober';
Monat[11]:='
November';
Monat[12]:='
Dezember';
Jahr:=strtoint(FormatDateTime('
yyyy', Now));
Panel2.Caption:=FormatDateTime('
yyyy', Now);
Vorm:=strtoint(FormatDateTime('
m', Now));
if Vorm = 1
then begin Vorm:=12;
end else Vorm:=Vorm-1;
Panel3.Caption:=Monat[Vorm];
Monata:=strtoint(FormatDateTime('
m', Now));
Panel1.Caption:=Monat[strtoint(FormatDateTime('
m', Now))];
Norm:=strtoint(FormatDateTime('
m', Now));
if Norm = 12
then begin Norm:=1;
end else Norm:=Norm+1;
Panel4.Caption:=Monat[Norm];
end;
procedure TForm1.Panel3Click(Sender: TObject);
begin
Monat_minus;
StringGrid1.LeftCol := 1;
end;
procedure TForm1.Panel4Click(Sender: TObject);
begin
Monat_plus;
end;
procedure TForm1.StringGrid1DblClick(Sender: TObject);
begin
showmessage(inttostr(StringGrid1.Row)+'
'+inttostr(StringGrid1.Col));
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if StringGrid1.LeftCol = 0
then Monat_minus;
if StringGrid1.LeftCol = 25
then Monat_plus;
end;
procedure TForm1.Monat_plus;
var
Vorm: Integer;
Norm: Integer;
begin
StringGrid1.Enabled:=false;
Panel3.Caption := Monat[Monata];
Norm := Monata;
if Norm = 12
then
begin
Norm := 1;
Jahr := Jahr + 1;
Panel2.Caption := inttostr(Jahr);
end
else
Norm := Norm + 1;
Monata := Norm;
Panel1.Caption := Monat[Norm];
Vorm := Norm;
if Vorm = 12
then
begin
Vorm := 1;
end
else
Vorm := Vorm + 1;
Panel4.Caption := Monat[Vorm];
StringGrid1.LeftCol := 1;
StringGrid1.Enabled:=true;
end;
procedure TForm1.Monat_minus;
var
Norm: Integer;
Vorm: Integer;
begin
StringGrid1.Enabled:=false;
Panel4.Caption := Monat[Monata];
Norm := Monata;
if Norm = 1
then
begin
Norm := 12;
Jahr := Jahr - 1;
Panel2.Caption := inttostr(Jahr);
end
else
Norm := Norm - 1;
Monata := Norm;
Panel1.Caption := Monat[Norm];
Vorm := Norm;
if Vorm = 1
then
begin
Vorm := 12;
end
else
Vorm := Vorm - 1;
Panel3.Caption := Monat[Vorm];
StringGrid1.LeftCol := 24;
StringGrid1.Enabled:=true;
end;
end.