
30.09.2011, 12:26
|
Прохожий
|
|
Регистрация: 30.09.2011
Сообщения: 7
Репутация: 10
|
|
Нарисовать сеть координат. Delphi
Код практически полностью переписал с учебника. Событие onpaint есть. Ошибок не найдено. Но после запуска программы форма все равно остается пустой.. аналогично пробывал через image и paintbox, результат тот же ..нужна добрая помощь!
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ComCtrls, Mask;
type
TForm1 = class(TForm)
Panel3: TPanel;
Panel4: TPanel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
ud1: TUpDown;
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormPaint(Sender: TObject);
var
x0, y0: integer;
dx, dy: integer;
h, w: integer;
x, y: integer;
lx, ly: real;
dlx, dly: real;
cross: integer;
dcross: integer;
begin
x0 := 30;
y0 := 220;
dx := 40;
dy := 40;
dcross := 1;
dlx := 1.0;
dly := 1.0;
h := 200;
w := 300;
with form1.Canvas do
begin
cross := dcross;
MoveTo(x0, y0);
LineTo(x0, y0 - h);
MoveTo(x0, y0);
LineTo(x0 + w, y0);
x := x0 + dx;
lx := dlx;
repeat
MoveTo(x, y0 - 3);
LineTo(x, y0 + 3);
cross := cross - 1;
if cross = 0 then
begin
TextOut(x - 8, y0 + 5, FloatToStr(lx));
cross := dcross;
end;
Pen.Style := psDot;
MoveTo(x, y0 - 3);
LineTo(x, y0 - h);
Pen.Style := psSolid;
lx := lx + dlx;
x := x + dx;
until (x > x0 + w);
y := y0 - dy;
ly := dly;
repeat
MoveTo(x0 - 3, y);
LineTo(x0 + 3, y);
TextOut(x0 - 20, y, FloatToStr(ly));
Pen.Style := psDot;
MoveTo(x0 + 3, y);
LineTo(x0 + w, y);
Pen.Style := psSolid;
y := y - dy;
ly := ly + dly;
until (y < y0 - h);
end;
end;
end.
Админ: Пользуемся тегами для оформления кода!
Последний раз редактировалось Admin, 30.09.2011 в 12:35.
|