Модеры извенить заранее незнаю куда расместить тему=)
Тут задачку накаталв делфи но не могу вкл кнопку финиш....
подскажите что как написать или исправить...
Сяп зарание..=)
PHP код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, unit2;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
PaintBox2: TPaintBox;
PaintBox3: TPaintBox;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
procedure VivodFigur1;
procedure VivodFigur2;
procedure VivodFigur3;
procedure VivodFigur(VF: TCanvas);
end;
var
Form1: TForm1;
P1,P2,P3: Potok;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
// создание первого потока
P1:=Potok.Create(true);
P1.Priority:=tpHighest;
P1.NPotoka:=1;
// создание второго потока
P2:=Potok.Create(true);
P2.Priority:=tpNormal;
P2.NPotoka:=2;
// создание третьего потока
P3:=Potok.Create(true);
P3.Priority:=tpHigher;
P3.NPotoka:=3;
// запуск трех потоков
P1.Resume; P2.Resume; P3.Resume;
end;
procedure TForm1.VivodFigur(VF: TCanvas);
var F: Trect;
begin
VF.Brush.Style:=bsSolid;
VF.Brush.Color:=rgb(random(256),random(256),random(256));
F.Left:=random(90);
F.Top:=random(90);
F.Right:=F.Left+10;
F.Bottom:=F.Top+10;
VF.Rectangle(F);
end;
procedure TForm1.VivodFigur1;
begin
VivodFigur(PaintBox1.Canvas);
end;
procedure TForm1.VivodFigur2;
begin
VivodFigur(PaintBox2.Canvas);
end;
procedure TForm1.VivodFigur3;
begin
VivodFigur(PaintBox3.Canvas);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
end.
PHP код:
unit Unit2;
interface
uses
Classes;
type
Potok = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
NPotoka: byte;
end;
implementation
uses unit1;
{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure Potok.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ Potok }
procedure Potok.Execute;
begin
while not terminated do
begin
case NPotoka of
1: synchronize(form1.VivodFigur1);
2: synchronize(form1.VivodFigur2);
3: synchronize(form1.VivodFigur3);
end; // case
end; // while
end;
end.
PHP код:
object Form1: TForm1
Left = 192
Top = 114
Width = 708
Height = 340
Caption = #1053#1080#1090#1080
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object PaintBox1: TPaintBox
Left = 72
Top = 40
Width = 100
Height = 100
end
object PaintBox2: TPaintBox
Left = 216
Top = 40
Width = 100
Height = 100
end
object PaintBox3: TPaintBox
Left = 360
Top = 40
Width = 100
Height = 100
end
object Button1: TButton
Left = 512
Top = 40
Width = 75
Height = 25
Caption = #1057#1090#1072#1088#1090
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 512
Top = 88
Width = 75
Height = 25
Caption = #1060#1080#1085#1080#1096
TabOrder = 1
OnClick = Button2Click
end
end