Consume .NET Events

You can dynamically connect PowerBuilder events or functions to a .NET event of a third-party control using PowerScript.

There are two ways to make the connection: using Delegate += or .NET AddHandler function.

Declare Event or Function

First, declare a PowerBuilder event or function with parameters that are the same as the .NET event.

event MyDockWindowClosing(object sender, RoutedEventArgs e)
{
CancelSourceRoutedEventArgs cancelArg = e;
cancelArg.Cancel = true;
mle_1.text += e.OriginalSource;
}

or

function wf_DockWindowClosing(object sender, RoutedEventArgs e)
{
CancelSourceRoutedEventArgs cancelArg = e;
cancelArg.Cancel = true;
mle_1.text += e.OriginalSource;
}

Delegate +=

dockWindow.Closing += MyDockWindowClosing

or

dockWindow.Closing += wf_DockWindowClosing

.NET AddHandler function

System.Windows.RoutedEventHandler reh
reh = this.wf_DockWindowClosing //or reh = this.MyDockWindowClosing
System.Windows.RoutedEvent re
re = DevComponents.WpfDock.DockWindow.ClosingEvent
w_frame.InnerControl.AddHandler(re, reh)