Document.WindowSize Event (2007 System)
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)
Syntax
'Declaration
Public Event WindowSize As WindowEventHandler
'Usage
Dim instance As Document
Dim handler As WindowEventHandler
AddHandler instance.WindowSize, handler
public event WindowEventHandler WindowSize
public:
event WindowEventHandler^ WindowSize {
void add (WindowEventHandler^ value);
void remove (WindowEventHandler^ value);
}
JScript does not support events.
Examples
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.
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.";
}
This version is for an application-level add-in.
Private resizeCount As Integer = 0
Private Sub DocumentWindowSize()
Dim vstoDoc As Document = Me.Application.ActiveDocument.GetVstoObject()
AddHandler vstoDoc.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()
{
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.";
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.Office.Tools.Word Namespace
Change History
Date |
History |
Reason |
---|---|---|
July 2008 |
Added a version of the code example for an application-level add-in. |
SP1 feature change. |