paranoiac |
30.03.2011 21:48 |
Delphi, объясните принцип рисования StringGrid1. Canvas
Вложений: 1
Ребят, не могу понять как доделать программу.
Имеется календарь на один месяц.
требуется чтобы по активации рамка(окружность) двигалась по датам с заданным интервалом, а по отмене - рамка вставала на первое число в календаре.
Работает почти всё, только когда рамка доходит до 6-го числа - она начинает цикл в той же строке, а на след. не переходит.
Подправьте, если вам не трудно или объясните принцип пожалуйста.
Ссылка удалена
код:
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, ComCtrls, ExtCtrls, Menus;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Timer1: TTimer;
Label8: TLabel;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
mm1: TMainMenu;
N2: TMenuItem;
N3: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
i,j,k:byte;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[1,0]:='1';
StringGrid1.Cells[2,0]:='2';
StringGrid1.Cells[3,0]:='3';
StringGrid1.Cells[4,0]:='4';
StringGrid1.Cells[5,0]:='5';
StringGrid1.Cells[6,0]:='6';
StringGrid1.Cells[0,1]:='7';
StringGrid1.Cells[1,1]:='8';
StringGrid1.Cells[2,1]:='9';
StringGrid1.Cells[3,1]:='10';
StringGrid1.Cells[4,1]:='11';
StringGrid1.Cells[5,1]:='12';
StringGrid1.Cells[6,1]:='13';
StringGrid1.Cells[0,2]:='14';
StringGrid1.Cells[1,2]:='15';
StringGrid1.Cells[2,2]:='16';
StringGrid1.Cells[3,2]:='17';
StringGrid1.Cells[4,2]:='18';
StringGrid1.Cells[5,2]:='19';
StringGrid1.Cells[6,2]:='20';
StringGrid1.Cells[0,3]:='21';
StringGrid1.Cells[1,3]:='22';
StringGrid1.Cells[2,3]:='23';
StringGrid1.Cells[3,3]:='24';
StringGrid1.Cells[4,3]:='25';
StringGrid1.Cells[5,3]:='26';
StringGrid1.Cells[6,3]:='27';
StringGrid1.Cells[0,4]:='28';
StringGrid1.Cells[1,4]:='29';
StringGrid1.Cells[2,4]:='30';
StringGrid1.Cells[3,4]:='31';
i:=20*2;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if i=287 then begin i:=0; j:=j+41; end;
StringGrid1.Repaint;
StringGrid1.Canvas.Brush.Style:=bsClear;
StringGrid1.Canvas.Pen.Width:=1;
StringGrid1.Canvas.Pen.Color:=clGreen;
StringGrid1.Canvas.Ellipse(0+i,0+j,41+i,41+j);
i:=i+41; k:=k+1;
if k=50 then begin i:=20*2; j:=0; k:=50 end;
end;
procedure TForm1.N1Click(Sender: TObject);
begin
Timer1.Enabled:=true;
end;
procedure TForm1.N3Click(Sender: TObject);
begin
Timer1.Enabled:=false;
StringGrid1.Repaint;
StringGrid1.Canvas.Brush.Style:=bsClear;
StringGrid1.Canvas.Pen.Width:=1;
StringGrid1.Canvas.Pen.Color:=clGreen;
i:=20*2; j:=0; k:=0;
StringGrid1.Canvas.Ellipse(0+i,0+j,40+i,40+j);
end;
end.
Исходник во вложении!
Вложение 34048
|