这个代码那里出了错误呀???

li3807 2003-09-14 09:29:29
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;

type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
abutton:array [1..100] of TButton;
procedure ButtonAllClick(sender:Tobject);
public
{ Public declarations }
end;

procedure TForm1.ButtonAllClick(sender:Tobject);
begin
application.MessageBox(TButton(sender).caption,'对话框',MB_OK);
end;
var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
var
i,j:integer;
begin
for i:=0 to 9 do
begin
for j:=1 to 10 do
begin
abutton[i*10+j]:=Tbutton.Create(self);
abutton[i*10+j].Parent:=Self;
abutton[i*10+j].Width:=100;
abutton[i*10+j].Height:=30;
abutton[i*10+j].Left:=i*abutton[i*10+j].Width+20;
abutton[i*10+j].Top:=j*abutton[i*10+j].Height+20;
abutton[i*10+j].Caption:=inttostr(i*10+j);
abutton[i*10+j].OnClick:=ButtonAllClick;
end;
end;
end;

end.
...全文
32 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
killme2008 2003-09-15
  • 打赏
  • 举报
回复
按gx(gx)运行没错!!
qiume 2003-09-15
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;

type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
abutton:array [1..100] of TButton;
procedure ButtonAllClick(sender:Tobject);
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
var
i,j:integer;
begin
for i:=0 to 9 do
begin
for j:=1 to 10 do
begin
abutton[i*10+j]:=Tbutton.Create(self);
abutton[i*10+j].Parent:=Self;
abutton[i*10+j].Width:=100;
abutton[i*10+j].Height:=30;
abutton[i*10+j].Left:=i*abutton[i*10+j].Width+20;
abutton[i*10+j].Top:=j*abutton[i*10+j].Height+20;
abutton[i*10+j].Caption:=inttostr(i*10+j);
abutton[i*10+j].OnClick:=ButtonAllClick;
end;
end;
end;

procedure TForm1.ButtonAllClick(Sender: Tobject);
begin
Application.MessageBox(PChar(TButton(Sender).Caption),'对话框',MB_OK);
end;

end.
zousoft 2003-09-14
  • 打赏
  • 举报
回复

procedure TForm1.ButtonAllClick(sender:Tobject);
begin
application.MessageBox(TButton(sender).caption,'对话框',MB_OK);
end;

放到implementation后面去。
li3807 2003-09-14
  • 打赏
  • 举报
回复
[Error] Unit1.pas(21): Identifier redeclared: 'TForm1.ButtonAllClick'
[Error] Unit1.pas(22): Undeclared identifier: 'sender'
[Error] Unit1.pas(15): Unsatisfied forward or external declaration: 'TForm1.ButtonAllClick'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
还是出这个错误,我用的是Delphi7.0
gx 2003-09-14
  • 打赏
  • 举报
回复
请注意以下代码的位置和Pchar()转化函数:
procedure TForm1.ButtonAllClick(sender:Tobject);
begin
application.MessageBox(TButton(sender).caption,'对话框',MB_OK);
end;


----------------------------------

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;

type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
abutton:array [1..100] of TButton;
procedure ButtonAllClick(sender:Tobject);
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.ButtonAllClick(sender:Tobject);
begin
application.MessageBox(Pchar(TButton(sender).caption),'对话框',MB_OK);
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
var
i,j:integer;
begin
for i:=0 to 9 do
begin
for j:=1 to 10 do
begin
abutton[i*10+j]:=Tbutton.Create(self);
abutton[i*10+j].Parent:=Self;
abutton[i*10+j].Width:=100;
abutton[i*10+j].Height:=30;
abutton[i*10+j].Left:=i*abutton[i*10+j].Width+20;
abutton[i*10+j].Top:=j*abutton[i*10+j].Height+20;
abutton[i*10+j].Caption:=inttostr(i*10+j);
abutton[i*10+j].OnClick:=ButtonAllClick;
end;
end;
end;

end.
lxpbuaa 2003-09-14
  • 打赏
  • 举报
回复
application.MessageBox(TButton(sender).caption,'对话框',MB_OK);
改为:
application.MessageBox(PChar(TButton(sender).caption), '对话框', MB_OK);

—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
VR(Virtual Reality)即虚拟现实,是一种可以创建和体验虚拟世界的计算机技术。它利用计算机生成一种模拟环境,是一种多源信息融合的、交互式的三维动态视景和实体行为的系统仿真,使用户沉浸到该环境中。VR技术通过模拟人的视觉、听觉、触觉等感觉器官功能,使人能够沉浸在计算机生成的虚拟境界中,并能够通过语言、手势等自然的方式与之进行实时交互,创建了一种适人化的多维信息空间。 VR技术具有以下主要特点: 沉浸感:用户感到作为主角存在于模拟环境中的真实程度。理想的模拟环境应该使用户难以分辨真假,使用户全身心地投入到计算机创建的三维虚拟环境中,该环境中的一切看上去是真的,听上去是真的,动起来是真的,甚至闻起来、尝起来等一切感觉都是真的,如同在现实世界中的感觉一样。 交互性:用户对模拟环境内物体的可操作程度和从环境得到反馈的自然程度(包括实时性)。例如,用户可以用手去直接抓取模拟环境中虚拟的物体,这时手有握着东西的感觉,并可以感觉物体的重量,视野中被抓的物体也能立刻随着手的移动而移动。 构想性:也称想象性,指用户沉浸在多维信息空间中,依靠自己的感知和认知能力获取知识,发挥主观能动性,寻求解答,形成新的概念。此概念不仅是指观念上或语言上的创意,而且可以是指对某些客观存在事物的创造性设想和安排。 VR技术可以应用于各个领域,如游戏、娱乐、教育、医疗、军事、房地产、工业仿真等。随着VR技术的不断发展,它正在改变人们的生活和工作方式,为人们带来全新的体验。

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧