WindowEventHandler Delegate


Represents the method that will handle the ActivateEvent, Deactivate, and WindowSize events.

Namespace:   Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

public delegate void WindowEventHandler(
	object sender,
	WindowEventArgs e


Type: System.Object

The source of the event.

Type: Microsoft.Office.Tools.Word.WindowEventArgs

A SaveEventArgs that contains the event data.

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.

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.

int resizeCount = 0;
private void DocumentWindowSize()
    this.WindowSize +=
        new Microsoft.Office.Tools.Word.WindowEventHandler(

void ThisDocument_WindowSize(object sender,
    Microsoft.Office.Tools.Word.WindowEventArgs e)
    e.Window.Caption = "Window resized " +
        resizeCount.ToString() + " times.";
Return to top