请问:两个按钮的点击事件处理为什么不能相互调用?(30分)

  • 主题发起人 主题发起人 pluszt
  • 开始时间 开始时间
P

pluszt

Unregistered / Unconfirmed
GUEST, unregistred user!
代码:
unit do
moform;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons, StdCtrls, ExtCtrls, Mask;
type
TForm1 = class(TForm)
Shape1: TShape;
Button1: TButton;
Button2: TButton;
Button3: TButton;
BitBtn1: TBitBtn;
ColorDialog1: TColorDialog;
Panel1: TPanel;
Button4: TButton;
Button5: TButton;
Panel2: TPanel;
Button6: TButton;
Button7: TButton;
BitBtn2: TBitBtn;
Panel3: TPanel;
Button8: TButton;
Button9: TButton;
Edit1: TEdit;
Button10: TButton;
Edit2: TEdit;
Button11: TButton;
Button12: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
shape1.Shape:=stRectangle;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
shape1.Shape:=stCircle;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
shape1.Shape:=stEllipse;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
colordialog1.Execute;
shape1.Brush.Color:=colordialog1.Color;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
shape1.Width:=shape1.Width+10;
shape1.Left:=shape1.Left-5;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
shape1.Width:=shape1.Width-10;
shape1.Left:=shape1.Left+5;
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
shape1.Height:=shape1.Height+10;
shape1.Top:=shape1.Top-5;
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
shape1.Height:=shape1.Height-10;
shape1.Top:=shape1.Top+5;
end;

procedure TForm1.Button8Click(Sender: TObject);
begin
shape1.Width:=shape1.Width+10;
shape1.Left:=shape1.Left-5;
shape1.Height:=shape1.Height+10;
shape1.Top:=shape1.Top-5;
end;

procedure TForm1.Button9Click(Sender: TObject);
begin
shape1.Width:=shape1.Width-10;
shape1.Left:=shape1.Left+5;
shape1.Height:=shape1.Height-10;
shape1.Top:=shape1.Top+5;
end;

procedure TForm1.Button10Click(Sender: TObject);
begin
edit1.Text:=inttostr(shape1.width);
form1.button11click(sender);
end;

procedure TForm1.Button11Click(Sender: TObject);
begin
edit2.Text:=inttostr(shape1.height);
//form1.Button10click(sender);
end;

procedure TForm1.Button12Click(Sender: TObject);
begin
shape1.Width:=shape1.Height;
end;

end.
中的procedure TForm1.Button10Click(Sender: TObject);
begin
edit1.Text:=inttostr(shape1.width);
form1.button11click(sender);
end;

procedure TForm1.Button11Click(Sender: TObject);
begin
edit2.Text:=inttostr(shape1.height);
//form1.Button10click(sender);
end;
这两个过程为什么不能相互调用呢?
 
可以run 不过会成为死循环!!!!!!
 
有两种方法。
1。直接调用过程Button10click(nil);
2。触发按钮事件Button10.Click;(推荐)
 
可以,会造死循环!调用方法:
form1.button10click(button10);
 
以上的回答都不能通过啊!
 
直接调用Button1.Click就可以了。
 
用这种方法可以的。
Button10Click(nil);
 
Button10.click;
 
当然是死循环了:
procedure TForm1.Button10Click(Sender: TObject);
begin
edit1.Text:=inttostr(shape1.width);
form1.button11click(sender);
end;

procedure TForm1.Button11Click(Sender: TObject);
begin
edit2.Text:=inttostr(shape1.height);
form1.Button10click(sender);
end;

button10的调用button11的,button11的又调用button10的,
 
procedure TForm1.Button10Click(Sender: TObject);
begin
edit1.Text:=inttostr(shape1.width);
if edit2.Text='' then
form1.button11click(sender);
if not edit2.Text='' then
sender:=nil;
end;
这样写可以吗?
怎么直接调用Button10.Click ,是不是在程序中写呢,还是在事件调用Event中选择呢?
 
你的代码好啰嗦。用个else
不就可以了。
要调Button10.Click 直接程序里面调哦!
面板里面调用也可以的
我不明白你为什么说你的第一个帖子里面的程序不能互相调,明明可以嘛!只不过是个
是循环而已.能说明白点嘛?
 
ok,I have not fen to fen le!
 
后退
顶部