怎样把SpeedButton的OnClick事件连接到一个procedure上?

cxl_langchao 2000-06-06 11:21:00
我是这样写的:
interface
procedure SpeedButtonClick(Sender:TObject);
.
.
.
SpeedButton.OnClick:=SpeedButtonClick;
.
.
.
procedure SpeedButtonClick(Sender:TObject);
begin
.
.
.
end;
但是编译时告诉我:
incompatible types: method pointer and regular procedure
请指教!
...全文
165 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxl_langchao 2000-06-10
  • 打赏
  • 举报
回复
对不起,大家,我前几天有事,没有来给分,我看了一下答复,认为kxy得答复是我要问的问题的答案,可能是我问题的说明不准确,大家没有理解我的意思,谢谢大家的回答,在这里小弟深表感谢!^_^
我的e_mail :cxl_langchao@263.net 希望大家互相切磋。
hhzh426 2000-06-10
  • 打赏
  • 举报
回复
在tform1中声明:
procedure tform1.xxx(sender:tobject);
在主体部分写函数:
procedure tform1.xxx(sender:tobject);
begin
......
end;
选择speedbutton的onclick事件中的下拉列表,选择xxx即可;
如果要在程序中指定可用:
speedbutton.onclick:=xxx;
ymxxm 2000-06-07
  • 打赏
  • 举报
回复
在Object Inspector窗口中直接将其它物件的过程经SpeedButton的click事件
shylsz 2000-06-07
  • 打赏
  • 举报
回复
procedure Tform1.xx;
begin
speedbutton.click;

end;
Sachow 2000-06-06
  • 打赏
  • 举报
回复
那样不行,看这里:
比如说要把SpeedButton的OnClick事件与ComboBox的OnClick事件过程相关:
procedure TForm1.ComboBox1Click(Sender: TObject);
begin
ShowMessage('Hello, Guy!');
end;

//SpeedButton的OnClick事件过程
procedure TForm1.SpeedButton1Click(Sender: TObject); begin
ComboBox1Click(Self);
end;
kxy 2000-06-06
  • 打赏
  • 举报
回复
就是你的procedure要是类的一个成员.
这样就可以把它赋值给类的其他成员的相同类型的东西.
SpeedButton OnClick的类型定义是 TNotifyEvent

type TNotifyEvent = procedure (Sender: TObject) of object;
kxy 2000-06-06
  • 打赏
  • 举报
回复
把 procedure SpeedButtonClick(Sender:TObject); 放到TForm1的类中
TForm1 = class(TForm)
private
procedure SpeedButtonClick(Sender:TObject);
end;

wx_zhang 2000-06-06
  • 打赏
  • 举报
回复
button的onclick事件需要参数的,在调用函数时将参数赋上,self或nil。
zxh1972 2000-06-06
  • 打赏
  • 举报
回复
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
xx; //调用过程xx;
end;
procedure TForm1.xx;
begin
end;

5,388

社区成员

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

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