Смекни!
smekni.com

Программирование 3 (стр. 2 из 5)

SRect.Right := c;

Selection :=SRect;

end;

end;

{=== Процедура сохранения данных в текстовый фаил ===================}

{==================================================================}

procedureSaveStringGrid(StringGrid: TStringGrid; constFileName: TFileName);

var f:TextFile;

i, k:Integer;

begin

AssignFile(f, FileName);

Rewrite(f);

withStringGriddo

begin

// Читаем номер колонки и столбца

Writeln(f, ColCount);

Writeln(f, RowCount);

// цикл по ячейкам

for i := 0 to ColCount - 1 do

for k := 0 to RowCount - 1 do

Writeln(F, Cells[i, k]);

end;

CloseFile(F);

end;

{=== Процедура загрузки данных из текстового фаила =====================}

{===================================================================}

procedureLoadStringGrid(StringGrid: TStringGrid; constFileName: TFileName);

var f:TextFile;

iTmp, i, k:Integer;

strTemp:String;

begin

AssignFile(f, FileName);

Reset(f);

withStringGrid do

begin

// Получаемколичествоколонок

Readln(f, iTmp);

ColCount:= iTmp;

// Получаем количество колонок строк

Readln(f, iTmp);

RowCount:=iTmp;

// Цикл по ячейкам и заполнению значений

for i := 0 to ColCount - 1 do

for k := 0 to RowCount - 1 do

begin

Readln(f, strTemp);

Cells[i, k] := strTemp;

end;

end;

CloseFile(f);

end;

{=== Процедура отрисовки осей и фона =================================}

{===================================================================}

procedure OSI;

begin

with form1.PaintBox1,canvas do

begin

PBx0:=width div 2;

PBy0:=height div 2;

brush.Color:=clwhite;

rectangle(0,0,width,height);

pen.Color:=clblack;

pen.style:=pssolid;

moveto(PBx0,0); lineto(PBx0,height);

moveto(0,PBy0); lineto(width,PBy0);

end;

end;

{===================================================================}

procedure TForm1.FormCreate(Sender: TObject);

vari,j:integer;

begin

PageControl1.ActivePage:=TabSheet1;

StringGrid2.Cells[0,0]:='Фамилия';

StringGrid2.Cells[1,0]:='Имя';

StringGrid2.Cells[2,0]:='Отчество';

StringGrid2.Cells[3,0]:='Пол';

StringGrid2.Cells[4,0]:='Возраст';

StringGrid2.Cells[5,0]:='Ищет (пол)';

StringGrid2.Cells[6,0]:='Сколькилет';

StringGrid2.Cells[7,0]:='Сцелью';

StringGrid3.Cells[0,0]:=' t';

StringGrid3.Cells[1,0]:=' X=R*Cos(t)';

StringGrid3.Cells[2,0]:=' Y=R*Sin(t)';

KSim:=0;

Form1.Width:=598; Form1.Height:=484;

PageControl1.Top:=0; PageControl1.Height:=409;

PageControl1.Left:=0; PageControl1.Width:=595;

Panel1.Visible:=False; Panel4.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel6.Visible:=False;

Panel1.Top:=0; Panel2.Top:=0; Panel3.Top:=0;

Panel1.Left:=0; Panel2.Left:=0; Panel3.Left:=0;

Panel1.Height:=409; Panel2.Height:=409; Panel3.Height:=409;

Panel1.Width:=595; Panel2.Width:=595; Panel3.Width:=595;

Panel4.Top:=0; Panel5.Top:=0; Panel6.Top:=0;

Panel4.Left:=0; Panel5.Left:=0; Panel6.Left:=0;

Panel4.Height:=409; Panel5.Height:=409; Panel6.Height:=409;

Panel4.Width:=595; Panel5.Width:=595; Panel6.Width:=595;

{=== Созданиетаблицы ===============================================}

StringGrid1.Font.Size:=8;

StringGrid1.Cells[0,0]:='Сумма "-"';

StringGrid1.Cells[0,1]:='Кол-во. "-"';

StringGrid1.Cells[0,2]:='Сумма "+"';

StringGrid1.Cells[0,3]:='Кол-во. "+"';

StringGrid1.Cells[0,4]:=' №';

StringGrid1.ColWidths[0]:=65;

StringGrid1.RowCount:=11;

StringGrid1.ColCount:=11;

for i:=1 to 11 do StringGrid1.Cells[i,4]:=IntToStr(i);

for i:=1 to 11 do begin

StringGrid1.Cells[0,i+4]:=' '+IntToStr(i);

// StringGrid1.Canvas.TextOut(Rect.Left, Rect.Top, StringGrid1.Cells[5,5);

end;

{====================================================================}

end;

procedure TForm1.N5Click(Sender: TObject);

begin

Close;

end;

procedure TForm1.N6Click(Sender: TObject);

begin

PageControl1.ActivePage:=TabSheet1;

PageControl1.Visible:=True;

Panel1.Visible:=False; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=False;

Form1.Height:=484;

N8.Visible:=False;

N9.Visible:=False;

end;

procedure TForm1.N11Click(Sender: TObject);

begin

PageControl1.Visible:=true;

PageControl1.ActivePage:=TabSheet2;

PageControl2.ActivePage:=TabSheet8;

Panel1.Visible:=False; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=False;

N8.Visible:=True;

N9.Visible:=True;

end;

procedure TForm1.N31Click(Sender: TObject);

begin

PageControl1.Visible:=true;

Panel1.Visible:=false; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=False;

PageControl1.ActivePage:=TabSheet4;

PageControl2.ActivePage:=TabSheet10;

N8.Visible:=True;

N9.Visible:=True;

end;

procedure TForm1.N41Click(Sender: TObject);

begin

PageControl1.Visible:=true;

Panel1.Visible:=false;

Panel2.Visible:=False;

Panel3.Visible:=False;

PageControl1.ActivePage:=TabSheet5;

PageControl2.ActivePage:=TabSheet11;

N8.Visible:=True;

N9.Visible:=True;

end;

procedure TForm1.N51Click(Sender: TObject);

begin

PageControl1.Visible:=true;

Panel1.Visible:=false; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=False;

PageControl1.ActivePage:=TabSheet6;

PageControl2.ActivePage:=TabSheet12;

N8.Visible:=True;

N9.Visible:=True;

end;

procedure TForm1.N61Click(Sender: TObject);

begin

PageControl1.Visible:=true;

Panel1.Visible:=false; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=False;

PageControl1.ActivePage:=TabSheet7;

PageControl2.ActivePage:=TabSheet13;

N8.Visible:=True;

N9.Visible:=True;

end;

procedure TForm1.N21Click(Sender: TObject);

begin

PageControl1.Visible:=true;

Panel1.Visible:=false; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=False;

PageControl1.ActivePage:=TabSheet3;

PageControl2.ActivePage:=TabSheet9;

N8.Visible:=True;

N9.Visible:=True;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

Panel1.Visible:=true;

PageControl1.Visible:=false;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.N12Click(Sender: TObject);

begin

PageControl1.Visible:=False;

Panel1.Visible:=True; Panel6.Visible:=False;

Panel2.Visible:=false; Panel5.Visible:=False;

Panel3.Visible:=false; Panel4.Visible:=False;

Form1.Height:=484;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

Panel1.Visible:=False; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=False;

PageControl1.Visible:=True;

PageControl1.ActivePage:=TabSheet2;

PageControl2.ActivePage:=TabSheet8;

N8.Visible:=true;

N9.Visible:=true;

end;

procedure TForm1.N22Click(Sender: TObject);

begin

PageControl1.Visible:=False;

Panel1.Visible:=false; Panel6.Visible:=False;

Panel2.Visible:=true; Panel5.Visible:=False;

Panel3.Visible:=false; Panel4.Visible:=False;

Form1.Height:=484;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.Button3Click(Sender: TObject);

begin

PageControl1.Visible:=false;

Panel1.Visible:=false; Panel6.Visible:=false;

Panel2.Visible:=true; Panel5.Visible:=false;

Panel3.Visible:=false; Panel4.Visible:=false;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.Button6Click(Sender: TObject);

begin

PageControl1.Visible:=false;

Panel1.Visible:=true; Panel4.Visible:=False;

Panel2.Visible:=false; Panel6.Visible:=False;

Panel3.Visible:=false; Panel5.Visible:=False;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.Button4Click(Sender: TObject);

begin

Panel1.Visible:=False; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=False;

PageControl1.Visible:=True;

PageControl1.ActivePage:=TabSheet3;

PageControl2.ActivePage:=TabSheet9;

N8.Visible:=true;

N9.Visible:=true;

end;

procedure TForm1.N23Click(Sender: TObject);

begin

PageControl1.Visible:=False;

Panel1.Visible:=false; Panel6.Visible:=False;

Panel2.Visible:=false; Panel5.Visible:=False;

Panel3.Visible:=true; Panel4.Visible:=False;

Form1.Height:=484;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.Button7Click(Sender: TObject);

begin

Panel1.Visible:=False; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=False;

PageControl1.Visible:=True;

PageControl1.ActivePage:=TabSheet4;

PageControl2.ActivePage:=TabSheet10;

N8.Visible:=true;

N9.Visible:=true;

end;

procedure TForm1.Button5Click(Sender: TObject);

begin

PageControl1.Visible:=false;

Panel1.Visible:=false; Panel6.Visible:=false;

Panel2.Visible:=false; Panel5.Visible:=false;

Panel3.Visible:=true; Panel4.Visible:=false;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.Button9Click(Sender: TObject);

begin

PageControl1.Visible:=false;

Panel1.Visible:=false; Panel6.Visible:=False;

Panel2.Visible:=true; Panel5.Visible:=False;

Panel3.Visible:=false; Panel4.Visible:=False;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.N24Click(Sender: TObject);

begin

Panel1.Visible:=False; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=true;

PageControl1.Visible:=False;

Form1.Height:=484;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.N52Click(Sender: TObject);

begin

Panel1.Visible:=False; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=true;

Panel3.Visible:=False; Panel4.Visible:=false;

PageControl1.Visible:=False;

Form1.Height:=484;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.N62Click(Sender: TObject);

begin

Panel1.Visible:=False; Panel6.Visible:=true;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=false;

PageControl1.Visible:=False;

Form1.Height:=484;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.Button8Click(Sender: TObject);

begin

PageControl1.Visible:=false;

Panel1.Visible:=false; Panel6.Visible:=false;

Panel2.Visible:=false; Panel5.Visible:=false;

Panel3.Visible:=false; Panel4.Visible:=true;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.Button16Click(Sender: TObject);

begin

PageControl1.Visible:=false;

Panel1.Visible:=false; Panel6.Visible:=false;

Panel2.Visible:=false; Panel5.Visible:=true;

Panel3.Visible:=false; Panel4.Visible:=false;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.Button14Click(Sender: TObject);

begin

PageControl1.Visible:=false;

Panel1.Visible:=false; Panel6.Visible:=true;

Panel2.Visible:=false; Panel5.Visible:=false;

Panel3.Visible:=false; Panel4.Visible:=false;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.Button17Click(Sender: TObject);

begin

PageControl1.Visible:=false;

Panel1.Visible:=false; Panel6.Visible:=False;

Panel2.Visible:=false; Panel5.Visible:=False;

Panel3.Visible:=true; Panel4.Visible:=False;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.Button13Click(Sender: TObject);

begin

PageControl1.Visible:=false;

Panel1.Visible:=false; Panel6.Visible:=False;

Panel2.Visible:=false; Panel5.Visible:=False;

Panel3.Visible:=false; Panel4.Visible:=true;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.Button11Click(Sender: TObject);

begin

PageControl1.Visible:=false;

Panel1.Visible:=false; Panel6.Visible:=False;

Panel2.Visible:=false; Panel5.Visible:=true;

Panel3.Visible:=false; Panel4.Visible:=False;

N8.Visible:=false;

N9.Visible:=false;

end;

procedure TForm1.Button15Click(Sender: TObject);

begin

Panel1.Visible:=False; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=False;

PageControl1.Visible:=True;

PageControl1.ActivePage:=TabSheet5;

PageControl2.ActivePage:=TabSheet11;

Memo1.SetFocus;

N8.Visible:=true;

N9.Visible:=true;

end;

procedure TForm1.Button12Click(Sender: TObject);

begin

Panel1.Visible:=False; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=False;

PageControl1.Visible:=True;

PageControl1.ActivePage:=TabSheet6;

PageControl2.ActivePage:=TabSheet12;

N8.Visible:=true;

N9.Visible:=true;

end;

procedure TForm1.Button10Click(Sender: TObject);

begin

Panel1.Visible:=False; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=False;

PageControl1.Visible:=True;

PageControl1.ActivePage:=TabSheet7;

PageControl2.ActivePage:=TabSheet13;

N8.Visible:=true;

N9.Visible:=true;

end;

procedure TForm1.Button18Click(Sender: TObject);

begin

Panel1.Visible:=False; Panel6.Visible:=False;

Panel2.Visible:=False; Panel5.Visible:=False;

Panel3.Visible:=False; Panel4.Visible:=true;

PageControl1.Visible:=False;

end;

procedure TForm1.Button21Click(Sender: TObject);

vari,j:integer;

begin

Button20.Caption:='Показатьтекстсгласными';

Button19.Enabled:=true;

Button21.Enabled:=false;

Memo2.Visible:=False;

Memo1.Visible:=True;

Memo1.Text:='';

Memo1.SetFocus;

Edit1.Text:=''; Edit6.Text:=''; Edit11.Text:=''; Edit18.Text:='';

Edit2.Text:=''; Edit7.Text:=''; Edit12.Text:=''; Edit17.Text:='';

Edit3.Text:=''; Edit8.Text:=''; Edit13.Text:=''; Edit10.Text:='';

Edit4.Text:=''; Edit9.Text:=''; Edit16.Text:=''; Edit5.Text:='';

Button20.Enabled:=False;

Edit1.Enabled:=False;

Label63.Enabled:=False;

for i:=1 to Ks do

for j:=1 to 91 do

Mas[i,j]:='';

KSim:=0;

Memo2.Text:='';

end;

procedure TForm1.Button19Click(Sender: TObject);

vari,j,iGlas:integer; // Переменные для циклов

Y:integer; // Переменная для кол-ва строк

LinesX:ShortString; // Переменная для собирания элементов строки массива

DLinX:integer; // Длина строки в переменной LinesX

S:ShortString; // Переменная для копирования в нее символа из текста

Glas:array [1..32] of ShortString; // Массивгласных

begin

Button20.Caption:='Показать текст с гласными';

Button20.Enabled:=true;

Button19.Enabled:=False;