散分了.......一个很简单的问题。

tongdings 2002-09-03 09:24:33
小弟在作界面设计时碰到点麻烦。
就是说,在一个父窗体中有两个按钮,分别按此两按钮共同弹出一个子窗体。
而在子窗体中,其中某按钮有自己一套不同的触发事件。
具体说,怎么指定此事件是由先前父窗体的哪个按钮所触发的呢?

以下是测试代码:

if TFrmInf.Create(FrmLanlog.BBtn_Add) <> nil then
BBtn_Ent.Action := self.Action_AddInf;
if TFrmInf.Create(FrmLanlog.BBtn_Mod) <> nil then
BBtn_Ent.Action := self.Action_ModInf;

上面Create()中的参数明显不对,里边是AOwner型别的,搞不定呢。

请大侠指教,可以加分。
...全文
30 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhuazhi 2002-09-03
  • 打赏
  • 举报
回复
up
tongdings 2002-09-03
  • 打赏
  • 举报
回复
to bigysw(大花脸)

其实用Public就OK了。
我用了个公用Proc,然后给父窗体调用。
子窗体处理具体业务逻辑。

谢谢各位了
//the end
bigysw 2002-09-03
  • 打赏
  • 举报
回复
有点错误。重载构造函数,如下,调试过的,当然你还得找你自己的改一下

Constructor Create(B:TButton);
.
.
.
.
constructor TFrmInf.Create(B:TButton);
begin
inherited Create(Nil);
//以下根据B的属性指定 BBtn_Ent的Action属性
..........
end;
tongdings 2002-09-03
  • 打赏
  • 举报
回复
to zhxfzhxf1(zhxfzhxf1)
请问:procedure SetEvent(mode:integer);
怎么写?
tongdings 2002-09-03
  • 打赏
  • 举报
回复
to bigysw(大花脸)
好像不行阿,你实践过了么?
提示好多错误:

[Warning] Unit2.pas(20): Method 'Create' hides virtual method of base type 'TCustomForm'
[Error] Unit2.pas(31): Undeclared identifier: 'create'
[Error] Unit2.pas(33): This form of method call only allowed in methods of derived types
[Error] Unit2.pas(34): Operator not applicable to this operand type
[Error] Unit2.pas(35): Undeclared identifier: 'BBtn'
[Error] Unit2.pas(35): Undeclared identifier: 'ActionList1'
[Error] Unit2.pas(35): Missing operator or semicolon
[Error] Unit2.pas(36): Operator not applicable to this operand type
[Error] Unit2.pas(37): Missing operator or semicolon
[Error] Unit2.pas(37): Missing operator or semicolon
[Error] Unit2.pas(20): Unsatisfied forward or external declaration: 'TForm2.Create'
[Fatal Error] Unit1.pas(78): Could not compile used unit 'Unit2.pas'
zhxfzhxf1 2002-09-03
  • 打赏
  • 举报
回复
子窗体中增加一个public过程setEvent(nmode:integer);
在父窗体中点击不同BUTTON时穿给不同的数值如1、2;
子窗体根据传入值执行不同的操作,此处为设置事件。
父窗体中
button1点击事件
form2.setevent(1);
form2.show
bigysw 2002-09-03
  • 打赏
  • 举报
回复
重载 TFrmInf的构造函数:

Constructor Create(B:TButton); overload;
.
.
.
.
constructor TFrmInf.Create(B:TButton);
begin
inherited;
//以下根据B的属性指定 BBtn_Ent的Action属性
..........
end;
tongdings 2002-09-03
  • 打赏
  • 举报
回复
to dreamfan(★★★★★)

怎么判断呢?
就是调用那个产生子窗体的按钮的触发事件,对吧
具体调用那个方法阿?
dreamfan 2002-09-03
  • 打赏
  • 举报
回复
加一个全局变量做判断

5,388

社区成员

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

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