问题
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