WindowEventHandler 委托

表示将处理 ActivateEventDeactivateWindowSize 事件的方法。

命名空间:  Microsoft.Office.Tools.Word
程序集:   Microsoft.Office.Tools.Word(在 Microsoft.Office.Tools.Word.dll 中)
  Microsoft.Office.Tools.Word.v4.0.Utilities(在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

语法

声明
Public Delegate Sub WindowEventHandler ( _
    sender As Object, _
    e As WindowEventArgs _
)
public delegate void WindowEventHandler(
    Object sender,
    WindowEventArgs e
)

参数

备注

当创建 WindowEventHandler 委托时,将标识处理事件的方法。若要使该事件与事件处理程序相关联,请将该委托的一个实例添加到事件中。每当事件出现时就调用事件处理程序,直到移除该委托。有关委托的更多信息,请参见事件和委托

示例

下面的代码示例为 WindowSize 事件创建一个事件处理程序。该事件处理程序在窗口标题中显示窗口进行大小调整的次数。

此示例针对的是文档级自定义项。

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

请参见

参考

Microsoft.Office.Tools.Word 命名空间