子窗体间事件调用

hackerlyf 2009-02-12 08:44:26
我建了一个MDI窗体,这个窗体包含了几个子窗体,其中每个子窗体都会调用其它子窗体的事件
比如:父窗体打开一个子窗体A
子窗体A上的一个按钮又打开了一个子窗体B
子窗体B上的一个按钮现在想要调用子窗体A上的事件来执行一段代码,子窗体A和子窗体B上的事件应该怎么来定义和调用?

我是新手,请尽量写详细些!谢了
...全文
218 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
hackerlyf 2009-02-13
  • 打赏
  • 举报
回复
楼上的,听你说的好像很有道理,我是新手,还没听懂,能不能说得更通俗更详细些
AFIC 2009-02-13
  • 打赏
  • 举报
回复
如果B窗体的类型是RESPONSE的,你可以用OPENWITHPAM,closewithreturn
如果b窗体类型不是response的,通常的设计是给b添加一个窗口类型的事例变量
在增加一个参数为window的of_setreserver的方法,方法就一句话
事例变量=参数
等到b想法消息的时候,事例变量.event dynamic 消息名(参数)
即可。
hackerlyf 2009-02-13
  • 打赏
  • 举报
回复
我要的效果:
A子窗体是一张单据,在做的时候要查询另一个B子窗体单据的数据,所以要在子窗体A调用子窗体B,B子窗体查询完后选择其中的某条数据,然后把选择的结果返馈给B子窗体,并且要调用A子窗体的事件,更新A子窗体上的数据显示内容
hackerlyf 2009-02-13
  • 打赏
  • 举报
回复
可以了,刚才窗口太多搞错了!
谢谢楼上的各位了!呵呵
mmbest 2009-02-13
  • 打赏
  • 举报
回复
这年头一定要把代码写完整才可以哦

A中某按钮代码:

w_sheet_class lw_parent
string ls_test
ls_test='w_sheet_3'//你的B窗口名字
OpenWithParm(lw_parent,parent,ls_test)

B中调用A事件
string lu_test
w_sheet_1 lw_sheet //你的A窗口
lw_sheet = Message.PowerObjectParm
lu_test="ue_test"//A中事件名字
lw_sheet.triggerevent(lu_test)//触发A中的事件
liubocy 2009-02-13
  • 打赏
  • 举报
回复
那只是个参考,列名什么的自己代入就是了,照葫芦画瓢也不会吗。

要传多个参数,你可以拼接字符串啊,比如你要传“aa”和“1”这2个数据,你可以传“aa,1”过去,然后在拆分就是了
hackerlyf 2009-02-13
  • 打赏
  • 举报
回复
楼上的,点击B窗口的按钮后提示 :Error:Null object reference at line 2 in clicked event of object cb_2 of b.

这种方式是不是只能返回一个参数?如果返回多个怎么办?
liubocy 2009-02-13
  • 打赏
  • 举报
回复
A中某按钮或事件中代码:

string ls_ret
open(B)
ls_ret = message.stringparm
...


B窗口选择某条数据后:
string ls_ret

ls_ret = dw_1.getitemstring(dw_1.getrow(), '列名')
closewithreturn(parent, ls_ret)

b窗口的类型为response

-----------
A中接收的ls_ret就是B窗口中要传的ls_ret
mmbest 2009-02-13
  • 打赏
  • 举报
回复
通俗一点就是,
你A打开B的时候,同时把A作为一个对象传过去。然后B可以调用A的函数,事件了。
liubocy 2009-02-12
  • 打赏
  • 举报
回复
A打开B:open(B)或者用opensheet

B调用A的时间,如ue_aa:

if isvalid(A) then A.dynamic trigger event ue_aa()
jdsnhan 2009-02-12
  • 打赏
  • 举报
回复
1、TriggerEvent 可以实现
2、怎样打开的窗口
3、最关键的,需求来源,为何B要调用A的事件。
LamarChen 2009-02-12
  • 打赏
  • 举报
回复
TriggerEvent
个人觉得 应该尽量少这样调用
dawugui 2009-02-12
  • 打赏
  • 举报
回复
TriggerEvent

Description

Triggers an event associated with the specified object, which executes the script for that event immediately.

Controls

Any object

Syntax

objectname.TriggerEvent ( event {, word, long } )

Argument Description
objectname The name of any PowerBuilder object or control that has events associated with it.
event A value of the TrigEvent enumerated datatype that identifies a PowerBuilder event (for example, Clicked!, Modified!, or DoubleClicked!) or a string whose value is the name of an event. The event must be a valid event for objectname and a script must exist for the event in objectname.
word (optional) A long value to be stored in the WordParm property of the system's Message object. If you want to specify a value for long, but not word, enter 0. (For cross-platform compatibility, WordParm and LongParm are both longs.)
long
(optional) A long value or a string that you want to store in the LongParm property of the system's Message object. When you specify a string, a pointer to the string is stored in the LongParm property, which you can access with the String function (see Usage).
Return value

Integer. Returns 1 if it is successful and the event script runs and -1 if the event is not a valid event for objectname, or no script exists for the event in objectname. If any argument's value is NULL, TriggerEvent returns NULL.

Usage

If you specify the name of an event instead of a value of the TrigEvent enumerated datatype, enclose the name in double quotation marks.
Check return code It is a good idea to check the return code to determine whether TriggerEvent succeeded and, based on the result, perform the appropriate processing.
You can pass information to the event script with the word and long arguments. The information is stored in the Message object. In your script, you can reference the WordParm and LongParm fields of the Message object to access the information.

If you have specified a string for long, you can access it in the triggered event by using the String function with the keyword "address" as the format parameter. Your event script might begin as follows:

string PassedString

PassedString = String(Message.LongParm, "address")

Caution Do not use this syntax unless you are certain the long argument contains a valid string value.
For more information about events and when to use PostEvent and TriggerEvent, see PostEvent.
To trigger system events that are not PowerBuilder-defined events, use Post or Send, instead of PostEvent and TriggerEvent. Although Send can send messages that trigger PowerBuilder events, as shown below, you have to know the codes for a particular message. It is easier to use the PowerBuilder functions that trigger the desired events.

Equivalent syntax
Both of the following statements click the CheckBox cb_OK. The following call to the Send function:

Send(Handle(Parent), 273, 0, Long(Handle(cb_OK), 0))

is equivalent to:

cb_OK.TriggerEvent(Clicked!)


This statement executes the script for the Clicked event in the CommandButton cb_OK immediately:

cb_OK.TriggerEvent(Clicked!)

This statement executes the script for the user-defined event cb_exit_request in the parent window:

Parent.TriggerEvent("cb_exit_request")

This statement executes the script for the Clicked event in the menu selection m_File on the menu m_Appl:

m_Appl.m_File.TriggerEvent(Clicked!)
dawugui 2009-02-12
  • 打赏
  • 举报
回复
TriggerEvent

Description

Triggers an event associated with the specified object, which executes the script for that event immediately.

Controls

Any object

Syntax

objectname.TriggerEvent ( event {, word, long } )

Argument Description
objectname The name of any PowerBuilder object or control that has events associated with it.
event A value of the TrigEvent enumerated datatype that identifies a PowerBuilder event (for example, Clicked!, Modified!, or DoubleClicked!) or a string whose value is the name of an event. The event must be a valid event for objectname and a script must exist for the event in objectname.
word (optional) A long value to be stored in the WordParm property of the system's Message object. If you want to specify a value for long, but not word, enter 0. (For cross-platform compatibility, WordParm and LongParm are both longs.)
long
(optional) A long value or a string that you want to store in the LongParm property of the system's Message object. When you specify a string, a pointer to the string is stored in the LongParm property, which you can access with the String function (see Usage).
Return value

Integer. Returns 1 if it is successful and the event script runs and -1 if the event is not a valid event for objectname, or no script exists for the event in objectname. If any argument's value is NULL, TriggerEvent returns NULL.

Usage

If you specify the name of an event instead of a value of the TrigEvent enumerated datatype, enclose the name in double quotation marks.
Check return code It is a good idea to check the return code to determine whether TriggerEvent succeeded and, based on the result, perform the appropriate processing.
You can pass information to the event script with the word and long arguments. The information is stored in the Message object. In your script, you can reference the WordParm and LongParm fields of the Message object to access the information.

If you have specified a string for long, you can access it in the triggered event by using the String function with the keyword "address" as the format parameter. Your event script might begin as follows:

string PassedString

PassedString = String(Message.LongParm, "address")

Caution Do not use this syntax unless you are certain the long argument contains a valid string value.
For more information about events and when to use PostEvent and TriggerEvent, see PostEvent.
To trigger system events that are not PowerBuilder-defined events, use Post or Send, instead of PostEvent and TriggerEvent. Although Send can send messages that trigger PowerBuilder events, as shown below, you have to know the codes for a particular message. It is easier to use the PowerBuilder functions that trigger the desired events.

Equivalent syntax
Both of the following statements click the CheckBox cb_OK. The following call to the Send function:

Send(Handle(Parent), 273, 0, Long(Handle(cb_OK), 0))

is equivalent to:

cb_OK.TriggerEvent(Clicked!)


This statement executes the script for the Clicked event in the CommandButton cb_OK immediately:

cb_OK.TriggerEvent(Clicked!)

This statement executes the script for the user-defined event cb_exit_request in the parent window:

Parent.TriggerEvent("cb_exit_request")

This statement executes the script for the Clicked event in the menu selection m_File on the menu m_Appl:

m_Appl.m_File.TriggerEvent(Clicked!)
dawugui 2009-02-12
  • 打赏
  • 举报
回复
在B的某处代码中写:

TriggerEven(子窗体A.控件名.事件名)

例如
TriggerEven(w_A.cb_1.Clicked!)
项目名称:高仿QQ2013通讯DEMO-10.30更新 版本号:10.30 最新版本 下载内容: (C#)CC2013局域网通讯源码一份, 可引用至工具箱最新版CSkin.dll-10.30版本界面库一份。 界面库更新说明: CC2013-10.30 1.由于SkinForm名字太多人使用,界面库命名正式改为CSkin.dll,官网www.cskin.net。 2.SkinTabControl标签中添加菜单箭头,可点击展开菜单。 3.SkinTabControl添加标签关闭按钮。 4.修复部分中文乱码问题。 5.优化好友列表右键菜单。 6.将窗体自定义系统按钮改为集合模式,可添加无数个自定义系统按钮。自定义系统按钮事件中可以 e.参数 来判断。 7.增加360安全卫士-DEMO案例。 8.增加SkinAnimatorImg控件,用于支持位图动画的播放。如360的动态logo。 9.各种细节BUG优化。 CC2013-10.11 1.添加SkinTabControlEx,加入更加自定义的美化属性和动画效果。 2.添加SkinAnimator,通用动画控件。 3.添加Html编辑器控件 4.修复SkinButton图标和文本相对位置的BUG CC2013-9.26 1.优化好友列表CPU占用 2.好友列表加入好友登录平台属性:安卓 苹果 WEBQQ PC 3.优化标题绘制模式,新添标题绘制模式属性。 4.新添标题偏移度属性。 5.加入圆形进度条控件:ProgressIndicator。 CC2013-9.5.2 1.优化截图控件,截图工具栏加入新功能。 2.解决个人信息卡和天气窗体显示后不会消失的问题。 3.各种细节BUG优化。 CC2013-9.5.1 1.解决贴边左右隐藏的BUG。 2.解决窗体点击事件不能触发的问题。 3.优化SkinButton继承父容器背景色的代码。 4.解决SkinButton异常错误。 CC2013-9.3 1.好友列表右键菜单没反应问题。 2.新增美化控件SkinDatagridview。 3.密码软件盘回删不了文字问题。 4.双击窗体最大化,最大化后再双击恢复原大小,(win7)。 5.部分细节调优。 实现功能: 1.界面库中多达25个自定义换肤控件,让每个控件设设属性就能达到你想要的效果,支持图片换肤和色调绘制。 2.四边阴影,毛边效果,可以设置阴影宽度和阴影颜色,支持所有系统。 3.拥有密码键盘输入,防护更贴心。 4.8种圆角窗体模式供你选择,淋漓尽致,润滑如圆。 5.登录主界面后,有登陆提示窗,提示上次登录的城市和时。 6.皮肤随心变:拖动任意一张图片至主界面,就可以改变皮肤。 7.皮肤色调获取:改变皮肤的同时,将计算图片色调,再将其运用到窗体背景色。 8.皮肤尾部渐变:上下左右方均可实现,渐变皮肤。 9.皮肤拖拉方向:可以选择皮肤在拉伸的时候,粘着哪一边拖拉。 10.GDI+界面重绘,处理消息机制,3种移动模式和拉伸是否启用只需要设置一个属性的事就可以解决。 11.界面渐变闪现和闪退:不再像平凡的突然出现,采用API渐变机制,渐渐出现和消失,win7系统下还有动态缩小至任务的效果。 12.完美好友列表,可添加上千好友,不卡不掉线,还可以拖动好友到其他分组。 13.好友悬浮至头像可以查看详细资料卡。 14.窗口可调渐变后透明度:让窗体看起来更像是Vista玻璃窗体风格。 15.聊天窗口可发送图片,大文件,表情,还有震动。 16.按钮控件背景色拥有继承窗体背景主色调的功能,让整体色调保持一致。 17.更是有和如出一辙的扣扣截图。仿真度也达到100%,完美修复所有已知BUG。 18.聊天窗口,可以调字体颜色和字体样式等多项功能。 20.SkinLabel与SkinButton控件字体与窗体标题可以根据背景色暗亮度自动调节字体为黑还是白。 21.MessageBox提示框的美化,并继承调用窗口的色调与背景,MessageBox可所谓已达到帅气的不能再帅气的境界了。 22.天气皮肤自动变,所有窗体根据当地天气自动决定皮肤背景,CC最帅气功能之一。 23.个人资料卡及聊天窗体拥有动态CC秀展示。 24.主界面拖动换肤的同时,所关联的窗体皮肤也会跟着变。 25.多线程大文件传输功能,支持无上限大文件传输,有进度条显示进程度。 26.界面库已封装了大图取主色调,颜色判断暗亮等多项功能。 27.如果你觉得获取天气让你的登录太慢不想要的话,注释相关调用方法即可快速登录。 界面库交流群:306485590 本人QQ:345015918 注意: Demo版不包括更新,为方便用户查看和使用属性等方法,dll只轻微加密。想反编译的就不要尝试了,里面有上百个类,改错改到你哭。 介意购买正版,永久更新配源码。 看截图或者想购买商业版的用户请访问以下地址: http://www.51aspx.com/code/TotalLikeQQ2013 特权:购买商业版的用户,有权利享有最快的更新服务,第一时将最新版本的dll源码送到你手上。 使本项目源码或本项目生成的DLL前请仔细阅读以下协议内容,如果你同意以下协议才能使用本项目所有的功能,否则如果你违反了以下协议,有可能陷入法律纠纷和赔偿,作者保留追究法律责任的权利。 1、你可以在开发的软件产品中使用和修改本项目的源码和DLL,但是请保留所有相关的版权信息。 2、不能将本项目源码与作者的其他项目整合作为一个单独的软件售卖给他人使用。 3、不能传播本项目的源码和DLL,包括上传到网上、拷贝给他人等方式。 4、以上协议暂时定制,由于还不完善,作者保留以后修改协议的权利。 时:2013-7-5 作者: 乔克斯 请保留以上版权信息,否则作者将保留追究法律责任。

1,110

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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