Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Начинающим";
Текущий архив: 2010.08.27;
Скачать: [xml.tar.bz2];

Вниз

найдите пожалуйста ошибку   Найти похожие ветки 

 
Мурад Севзиханов   (2010-04-15 21:45) [0]

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls, ExtCtrls, Menus, XPMan;

type
 TForm1 = class(TForm)
   RadioGroup1: TRadioGroup;
   SaveDialog1: TSaveDialog;
   OpenDialog1: TOpenDialog;
   MainMenu1: TMainMenu;
   file1: TMenuItem;
   N1: TMenuItem;
   N2: TMenuItem;
   N3: TMenuItem;
   XPManifest1: TXPManifest;

   procedure FormCreate(Sender: TObject);
   procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
     Shift: TShiftState; X, Y: Integer);
   procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
     Shift: TShiftState; X, Y: Integer);
   procedure FormPaint(Sender: TObject);

   procedure FormResize(Sender: TObject);
   procedure N1Click(Sender: TObject);
   procedure N2Click(Sender: TObject);
   procedure N3Click(Sender: TObject);
   procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
     Y: Integer);

 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;
var
e:array of record e1,e2:integer; end;
v:array of record vx,vy:integer; end;
f1,f2:textfile;
r,o,x1,y1,x2,y2,b:integer;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
o:=1;
canvas.Brush.Color:=RGB(0,255,255);
canvas.Pen.Color:= RGB(0,255,255);

end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
 Shift: TShiftState; X, Y: Integer);
 var
 i:integer;
begin
b:=-1;
for i:=o to length(v)-1 do

if (x>v[i].vx-10) and (x<v[i].vx+10) and (y>v[i].vy-10)
and (y<v[i].vy+10) and (radiogroup1.ItemIndex=2) and (ssleft in shift) then b:=i;

if radiogroup1.ItemIndex=0 then
begin
canvas.Ellipse(x+10,y+10,x-10,y-10);
canvas.TextOut(x-3,y-5,inttostr(o));
inc(o);
 setlength(v,length(v)+1);
    v[length(v)-1].vx:=x;
    v[length(v)-1].vy:=y;
end;

if radiogroup1.ItemIndex=1 then
for i:=0 to length(v)-1 do
if (x>v[i].vx-10) and (x<v[i].vx+10) and (y>v[i].vy-10) and (y<v[i].vy+10) then
begin
  setlength(e,length(e)+1);
  e[length(e)-1].e2:=i;
  canvas.MoveTo(v[i].vx,v[i].vy);
end;
if radiogroup1.ItemIndex=3 then
for i:=0 to length(v)-1 do
if (x>v[i].vx-10) and (x<v[i].vx+10) and (y>v[i].vy-10) and (y<v[i].vy+10) then
begin
x1:=v[i].vx;
y1:=v[i].vy;
end;

end;

procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
 Shift: TShiftState; X, Y: Integer);
   var
 i:integer;
   begin
b:=-1;
 if radiogroup1.ItemIndex=1  then
   begin
 for i:=0 to length(v)-1 do
 if (x>v[i].vx-10) and (x<v[i].vx+10) and (y>v[i].vy-10) and (y<v[i].vy+10) then
   begin
 canvas.LineTo(v[i].vx,v[i].vy);
 e[length(e)-1].e1:=i;

end;
end;

if radiogroup1.ItemIndex=3 then
begin
  for i:=0 to length(v)-1 do
   if (x>v[i].vx-10) and (x<v[i].vx+10) and (y>v[i].vy-10) and (y<v[i].vy+10) then
 begin
   x2:=v[i].vx;
   y2:=v[i].vy;
 end;
   for i:=0 to length(e)-1 do
    if (v[e[i].e1].vx>x2-10) and (v[e[i].e1].vx<x2+10) and
       (v[e[i].e1].vy>y2-10) and (v[e[i].e1].vy<y2+10) and
       (v[e[i].e2].vx>x1-10) and (v[e[i].e2].vx<x1+10) and
       (v[e[i].e2].vy>y1-10) and (v[e[i].e2].vy<y1+10) then
  begin
   e[i].e1:=0;
   e[i].e2:=0;
  end;
   for i:=0 to length(e)-1 do
    if (v[e[i].e2].vx>x2-10) and (v[e[i].e2].vx<x2+10) and
       (v[e[i].e2].vy>y2-10) and (v[e[i].e2].vy<y2+10) and
       (v[e[i].e1].vx>x1-10) and (v[e[i].e1].vx<x1+10) and
       (v[e[i].e1].vy>y1-10) and (v[e[i].e1].vy<y1+10) then
  begin
   e[i].e1:=0;
   e[i].e2:=0;
  end;
begin
   for i:=0 to length(v)-1 do
 begin
   repaint;
   canvas.Ellipse(v[i].vx-10,v[i].vy-10,v[i].vx+10,v[i].vy+10);
   canvas.TextOut(v[i].vx-3,v[i].vy-5,inttostr(i+1));
 end;
   for i:=0 to length(e)-1 do
 begin
   canvas.MoveTo(v[e[i].e2].vx,v[e[i].e2].vy);
   canvas.LineTo(v[e[i].e1].vx,v[e[i].e1].vy);
 end;
end;
end;
end;

procedure TForm1.FormPaint(Sender: TObject);
var
 i:integer;
begin
  for i:=0 to length(v)-1 do
 begin
   canvas.Ellipse(v[i].vx-10,v[i].vy-10,v[i].vx+10,v[i].vy+10);
   canvas.TextOut(v[i].vx-3,v[i].vy-5,inttostr(i+1));
 end;
  for i:=0 to length(e)-1 do
 begin
   canvas.MoveTo(v[e[i].e2].vx,v[e[i].e2].vy);
   canvas.LineTo(v[e[i].e1].vx,v[e[i].e1].vy);
 end;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
 radiogroup1.Left:=form1.ClientWidth-radiogroup1.Width-5;
end;

procedure TForm1.N1Click(Sender: TObject);
var
i:integer;
begin
 if savedialog1.Execute then
begin
 assignfile(f1,savedialog1.FileName+".grf");
 rewrite(f1);
   for i:=0 to length(v)-1 do
 begin
 write(f1, inttostr(v[i].vx)+" "+inttostr(v[i].vy)+" ");
 end;
 writeln(f1);
  for i:=0 to length(e)-1 do
 begin
 write(f1, inttostr(e[i].e1)+" "+inttostr(e[i].e2)+" ");
 end;
 closefile(f1);
end;
end;

procedure TForm1.N2Click(Sender: TObject);
var
i:integer;
begin
i:=0;
if opendialog1.Execute then
begin
canvas.Brush.Color:=RGB(255,255,255);
canvas.Rectangle(0,0,width,height);
canvas.Brush.Color:=RGB(0,255,255);
assignfile(f2,opendialog1.FileName);
reset(f2);
setlength(v,0);
 begin
 repeat
  begin
   setlength(v,length(v)+1);
   read(f2, v[i].vx, v[i].vy);
   inc(i);
  end;
  until eoln(f2);
   setlength(v,length(v)-1);
end;
  reset(f2);
  i:=0;
  setlength(e,0);
  readln(f2);
  begin
 repeat
  begin
   setlength(e,length(e)+1);
   read(f2, e[i].e1, e[i].e2);
   inc(i);
  end;
  until eoln(f2);
   setlength(e,length(e)-1);
end;
 setlength(v,length(v)-length(e));
 for i:=0 to length(e)-1 do
 begin
   canvas.MoveTo(v[e[i].e2].vx,v[e[i].e2].vy);
   canvas.LineTo(v[e[i].e1].vx,v[e[i].e1].vy);
 end;
   for i:=0 to length(v)-1 do
 begin
   canvas.Ellipse(v[i].vx-10,v[i].vy-10,v[i].vx+10,v[i].vy+10);
   canvas.TextOut(v[i].vx-3,v[i].vy-5,inttostr(i+1));
 end;

end;
end;

procedure TForm1.N3Click(Sender: TObject);
begin
setlength(v,0);
setlength(e,0);
canvas.Brush.Color:=RGB(255,255,255);
canvas.Rectangle(0,0,width,height);
canvas.Brush.Color:=RGB(0,255,255);
o:=1;

end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
 Y: Integer);
 var
 j:integer;
 begin
if (ssleft in shift) and (b<>-1)  then
begin
v[b].vx:=x;
v[b].vy:=y;
canvas.Brush.Color:=RGB(255,255,255);
canvas.Rectangle(0,0,width,height);
canvas.Brush.Color:=RGB(0,255,255);
   for j:=0 to length(e)-1 do
 begin
   canvas.MoveTo(v[e[j].e2].vx,v[e[j].e2].vy);
   canvas.LineTo(v[e[j].e1].vx,v[e[j].e1].vy);
 end;
   for j:=0 to length(v)-1 do
 begin
   canvas.Ellipse(v[j].vx-10,v[j].vy-10,v[j].vx+10,v[j].vy+10);
   canvas.TextOut(v[j].vx-3,v[j].vy-5,inttostr(j+1));
 end;

end;

end;
end.


 
Ega23 ©   (2010-04-15 21:47) [1]

344 рубля.


 
Мурад Севзиханов   (2010-04-15 21:47) [2]

в процедурах TForm1.FormMouseMove, TForm1.FormMouseUp, TForm1.FormMousedown где участвует переменная b есть ошибка только не пойму какая, пожалуйста если кто видет скажите


 
Игорь Шевченко ©   (2010-04-15 21:58) [3]

я вижу только неуважение к отвечающим



Страницы: 1 вся ветка

Форум: "Начинающим";
Текущий архив: 2010.08.27;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.064 c
3-1221825053
Антон
2008-09-19 15:50
2010.08.27
Настройка доступа из Delphi к Access через ADO


15-1267727911
GDI+
2010-03-04 21:38
2010.08.27
Непрямое стимулирование перехода на Висту?


2-1272487277
Wadimka
2010-04-29 00:41
2010.08.27
Можно ли сделать?


3-1221580413
wipr
2008-09-16 19:53
2010.08.27
не удается открыть таблицу XML


2-1265901983
Дмитрий
2010-02-11 18:26
2010.08.27
Проблемы с FB 2.1





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский