WindowEventHandler Delegate (2007 System)
Represents the method that will handle the ActivateEvent, Deactivate, and WindowSize events.
This API is not CLS-compliant.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)
Syntax
'Declaration
<CLSCompliantAttribute(False)> _
Public Delegate Sub WindowEventHandler ( _
sender As Object, _
e As WindowEventArgs _
)
'Usage
Dim instance As New WindowEventHandler(AddressOf HandlerMethod)
[CLSCompliantAttribute(false)]
public delegate void WindowEventHandler(
Object sender,
WindowEventArgs e
)
[CLSCompliantAttribute(false)]
public delegate void WindowEventHandler(
Object^ sender,
WindowEventArgs^ e
)
JScript does not support delegates.
Parameters
sender
Type: System.ObjectThe source of the event.
e
Type: Microsoft.Office.Tools.Word.WindowEventArgsA SaveEventArgs that contains the event data.
Remarks
When you create a WindowEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, until you remove the delegate. For more information about delegates, see Events and Delegates.
Examples
The following code example creates an event handler for the WindowSize event. The event handler displays in the window caption the number of times that the window has been resized.
This example is for a document-level customization.
Private resizeCount As Integer = 0
Private Sub DocumentWindowSize()
AddHandler Me.WindowSize, AddressOf ThisDocument_WindowSize
End Sub
Private Sub ThisDocument_WindowSize(ByVal sender As Object, ByVal e As Microsoft.Office.Tools.Word.WindowEventArgs)
resizeCount += 1
e.Window.Caption = "Window resized " & resizeCount.ToString() & " times."
End Sub
int resizeCount = 0;
private void DocumentWindowSize()
{
this.WindowSize +=
new Microsoft.Office.Tools.Word.WindowEventHandler(
ThisDocument_WindowSize);
}
void ThisDocument_WindowSize(object sender,
Microsoft.Office.Tools.Word.WindowEventArgs e)
{
resizeCount++;
e.Window.Caption = "Window resized " +
resizeCount.ToString() + " times.";
}