CustomTaskPane 事件 (Office)CustomTaskPane.DockPositionStateChange event (Office)

该事件发生在用户更改活动自定义任务窗格的停靠位置时。Occurs when the user changes the docking position of the active custom task pane.

语法Syntax

表达式DockPositionStateChange(CustomTaskPaneInst)expression.DockPositionStateChange (CustomTaskPaneInst)

_表达式_一个返回**CustomTaskPane** 对象的表达式。expression An expression that returns a CustomTaskPane object.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
CustomTaskPaneInstCustomTaskPaneInst 必需Required ObjectObject 活动自定义任务窗格。The active custom task pane.

示例Example

以下用 c # 编写的示例创建一个自定义任务窗格, 并添加一个在另一个项目中创建的 Microsoft ActiveX 按钮控件。The following example, written in C#, creates a custom task pane and adds a Microsoft ActiveX button control that was created in another project. 然后,将定义一个类型为 _CustomTaskPaneEvents_DockPositionStateChangeEventHandlerDockPositionStateChange 事件。A DockPositionStateChange event of type _CustomTaskPaneEvents_DockPositionStateChangeEventHandler is then defined. 该事件被触发时,将显示一个消息框,告知用户固定的任务窗格已移动。When the event is triggered, a message box is displayed telling the user that the docked task pane has been moved.

object missing = Type.Missing; 
public CustomTaskPane CTP = null; 
 
public void CTPFactoryAvailable(ICTPFactory CTPFactoryInst) 
{ 
 CTP = CTPFactoryInst.CreateCTP("SampleActiveX.myControl", "Task Pane Example", missing); 
 sampleAX = (myControl)CTP.ContentControl; 
 sampleAX.InsertTextClicked += new InsertTextEventHandler(sampleAX_InsertTextClicked); 
 CTP.Visible = true; 
 
 CTP.DockPositionStateChange += new _CustomTaskPaneEvents_DockPositionStateChangeEventHandler(CTP_DockPositionStateChange); 
 
} 
 
private void CTP_DockPositionStateChange(object sender, string dockpositionArgs) 
{ 
 Console.WriteLine("The custom task pane was moved"); 
}

备注

您可以创建任何支持 COM 的语言的自定义任务窗格, 并允许您创建动态链接库 (DLL) 文件;例如, Microsoft visual basic 6.0、visual basic .net、visual c + +、visual c + + .net 和 visual c #。You can create custom task panes in any language that supports COM and allows you to create dynamic-linked library (DLL) files; for example, Microsoft Visual Basic 6.0, Visual Basic .NET, Visual C++, Visual C++ .NET, and Visual C#. 但是,Microsoft Visual Basic for Applications (VBA) 不支持创建自定义任务窗格。However, Microsoft Visual Basic for Applications (VBA) does not support creating custom task panes.

另请参阅See also

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.