C
chf
Unregistered / Unconfirmed
GUEST, unregistred user!
向高手请教,以下程序为何不能正常运行?
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
btnSeconForm: TButton;
btnEnd: TButton;
procedure btnEndClick(Sender: TObject);
procedure btnSeconFormClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
uses unit2;
procedure TForm1.btnEndClick(Sender: TObject);
begin
Close;
end;
procedure TForm1.btnSeconFormClick(Sender: TObject);
begin
TForm2.Create(self);
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,mmSystem;
type
TForm2 = class(TForm)
btnDraw: TButton;
btnStop: TButton;
procedure btnDrawClick(Sender: TObject);
procedure btnStopClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
uses unit1;
var
timeindex : int64;
procedure timecallback1(uTimerID, uMessage: UINT;dwUser, dw1, dw2: DWORD);stdcall;
begin
Form2.Canvas.MoveTo(80,90);
Form2.Canvas.LineTo(Random(Form2.Width),Random(Form2.Height));
end;
procedure TForm2.btnDrawClick(Sender: TObject);
begin
timebeginperiod(10);
timeindex := timesetevent(10,10,Addr(timecallback1),0,TIME_periodic);
timeendperiod(10);
end;
procedure TForm2.btnStopClick(Sender: TObject);
begin
timekillevent(timeindex);
close;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
Form1.Enabled := False;
end;
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Form1.Enabled := True;
end;
end.
如何使之正常运行?
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
btnSeconForm: TButton;
btnEnd: TButton;
procedure btnEndClick(Sender: TObject);
procedure btnSeconFormClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
uses unit2;
procedure TForm1.btnEndClick(Sender: TObject);
begin
Close;
end;
procedure TForm1.btnSeconFormClick(Sender: TObject);
begin
TForm2.Create(self);
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,mmSystem;
type
TForm2 = class(TForm)
btnDraw: TButton;
btnStop: TButton;
procedure btnDrawClick(Sender: TObject);
procedure btnStopClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
uses unit1;
var
timeindex : int64;
procedure timecallback1(uTimerID, uMessage: UINT;dwUser, dw1, dw2: DWORD);stdcall;
begin
Form2.Canvas.MoveTo(80,90);
Form2.Canvas.LineTo(Random(Form2.Width),Random(Form2.Height));
end;
procedure TForm2.btnDrawClick(Sender: TObject);
begin
timebeginperiod(10);
timeindex := timesetevent(10,10,Addr(timecallback1),0,TIME_periodic);
timeendperiod(10);
end;
procedure TForm2.btnStopClick(Sender: TObject);
begin
timekillevent(timeindex);
close;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
Form1.Enabled := False;
end;
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Form1.Enabled := True;
end;
end.
如何使之正常运行?