Handling user interface extension events |
Meridian Enterprise allows you to customize the behavior of a user interface extension with event handlers that will be executed at predefined moments.
To create an event handler:
Private Sub UIExtensionComposer_EventName _ (ByVal sender As Object, ByVal e As EventArgs) _ Handles MyBase.EventName ' TODO: Add your event handling code here. End Sub
The standard signature of an event handler defines a method that does not return a value, whose first parameter is of the type Object that refers to the instance that raises the event, and whose second parameter is derived from the type EventArgs that holds the event data. If the event does not generate event data, the second parameter is simply an instance of EventArgs. Otherwise, the second parameter is a custom type derived from EventArgs that supplies any fields or properties needed to hold the event data.
If an event represents an operation that can be aborted, then the second parameter of the handler provides a property Cancel (this is analogous to the Abort parameter in Visual Basic 6 API). The following Visual Basic .NET code sample demonstrates how to prevent copying a document named MyDocument.doc. You can also see in the sample how the ExtensionHost property is used to get access to a BatchOperation service.
Private Sub UIExtensionComposer_BeforeCopy _ (ByVal sender As Object, ByVal e As CancelCopyEventArgs) _ Handles MyBase.BeforeCopy If e.Document.DisplayName.Equals("MyDocument.doc") Then ExtensionHost.BatchOperation.PrintDetails("You may not copy this document.") e.Cancel = True End If End Sub