DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: saulojb_b1975xxx
今日帖子: 64
在线用户: 9
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
女 matchbox (matchbox) ★☆☆☆☆ -
普通会员
2004/8/3 9:56:28
标题:
请教各位DELPHI朋友 浏览:1126
加入我的收藏
楼主: procedure TFm_Main.Action_BeginUpdate(Sender: TObject);
begin
  (Sender as TAction).Enabled:=(not gFlag);  
end;

procedure TFm_Main.Action_EndUpdate(Sender: TObject);
begin
  (Sender as TAction).Enabled:=gFlag;
end;

我不懂这里的Sender怎么用,在这里是一种什么用法,Sender as TAction是什么意思呢?其中gFlag是一个boolean变量,Action_Begin,Action_end是Actionlist中的两个Actions;小弟在这里不耻下问,希望各位大侠能够多多指教.
----------------------------------------------
DELPHI朋友,大家好
作者:
男 superyoyonc (ExSystem) ★☆☆☆☆ -
盒子活跃会员
2004/8/3 10:04:35
1楼: eg:
如果在Button1的事件里调用它,那么Sender就是Button1...
----------------------------------------------
许子健
作者:
男 gemouzhi2 (gemouzhi2) ★☆☆☆☆ -
盒子活跃会员
2004/8/3 10:14:25
2楼: 不耻下问?,好,呵呵
----------------------------------------------
-
作者:
女 matchbox (matchbox) ★☆☆☆☆ -
普通会员
2004/8/3 11:02:37
3楼: 幽幽,我还是不太明白,Sender是一个过程中的形式参数名吧,那么Sender as TAction就是把它强制转换成一个TAction类型吧,那你说的
"如果在Button1的事件里调用它,那么Sender就是Button1..."
是什么意思呀

----------------------------------------------
DELPHI朋友,大家好
作者:
男 allen_wgq (yuren) ★☆☆☆☆ -
普通会员
2004/8/3 12:30:07
4楼: In an event handler, the Sender parameter indicates which component received the event and therefore called the handler. Sometimes it is useful to have several components share an event handler that behaves differently depending on which component calls it. You can do this by using the Sender parameter in an if...then...else statement. For example, the following code displays the title of the application in the caption of a dialog box only if the OnClick event was received by Button1.

procedure TMainForm.Button1Click(Sender: TObject);

begin
if Sender = Button1 then  
  AboutBox.Caption := 'About ' + Application.Title  
else 
  AboutBox.Caption := '';  
AboutBox.ShowModal;
end;

上面的文字是来自在先帮助的,它告诉我们Sender是时间的接受者,所以。。。。

和is操作符比较一下:)
----------------------------------------------
 [ Impossible is nothing ]
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行78.125毫秒 RSS