Export (0) Print
Expand All

Document.WindowSize Event (2007 System)

Updated: July 2008

Occurs when the document window is resized or moved.

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

public event WindowEventHandler WindowSize

The following code example creates a handler for the WindowSize event. The event handler displays in the window caption the number of times that the window has been resized.

This version is for a document-level customization.

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.";
}

This version is for an application-level add-in.

int resizeCount = 0;
private void DocumentWindowSize()
{
    Document vstoDoc = this.Application.ActiveDocument.GetVstoObject();
    vstoDoc.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.";
}

Date

History

Reason

July 2008

Added a version of the code example for an application-level add-in.

SP1 feature change.

Community Additions

ADD
Show:
© 2015 Microsoft