How to re-direct events from one control to another control in PowerBuilder?

泄露秘密 提交于 2020-01-16 17:04:44

问题


A button control can trigger event of a datawindow control with TriggerEvent() function.

The button control in my code was set as child object of DataWindow control with SetParent win32 API function. SetParent external function moves button from window to datawindow control but after SetParent the code that was already written for Clicked event is not working anymore. That is why i need to redirect the clicked event of button to buttonclicked event of datawindow.

There is good example of redirecting event by using win32 API calls. here is the link http://bitmatic.com/c/redirecting-mousewheel-events-to-another-control i need to do the same thing in PowerBuilder.

Can someone see that code or help me to redirect events the way i want?


回答1:


You're doing things the hard way. Find the name of the datawindow control (e.g. dw_1), and from the command button just issue dw_1.event buttonclicked ( args ).

Better yet, move the code to a function in the parent object. Controls are navigation objects, they really shouldn't have too much code in them (IMHO), but fire off methods on the parent object.



来源:https://stackoverflow.com/questions/50156116/how-to-re-direct-events-from-one-control-to-another-control-in-powerbuilder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!