Table of contents
TOC
折叠目录
展开目录

Application.CurrentScope 属性 (Visio)Application.CurrentScope Property (Visio)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

确定引起事件触发的范围 ID。只读。Determines the ID of the scope that causes an event to fire. Read-only.

语法Syntax

表达式CurrentScopeexpression . CurrentScope

表达式_一个表示应用程序对象的变量。_expression A variable that represents an Application object.

返回值Return Value

LongLong

注解Remarks

如果作用域未打开,则返回visScopeIDInvalid (-1)。作用域 ID 可以是内部 Microsoft Visio 作用域 ID 对应于 Visio 命令或通过BeginUndoScope方法传递给自动化客户端的外部作用域 ID。Returns visScopeIDInvalid (-1) if a scope isn't open. The scope ID could be an internal Microsoft Visio scope ID that corresponds to a Visio command or an external scope ID passed to an Automation client by the BeginUndoScope method.

事件的接收者考虑范围打开如果触发了EnterScope事件但不是触发了ExitScope事件。The recipients of an event consider a scope open if the EnterScope event has fired but the ExitScope event has not fired.

要确定是否事件队列的触发与内部应用程序打开或关闭的自动化客户端的特定范围,请使用IsInScope属性。To determine if the event queue firing is related to a particular scope internal to the application or one opened and closed by an Automation client, use the IsInScope property.

示例Example

此示例演示如何使用CurrentScope属性来确定当前作用域的 ID。This example shows how to use the CurrentScope property to determine the ID of the current scope.

Private WithEvents vsoApplication As Visio.Application 
Private lngScopeID As Long 

Public Sub ScopeActions() 

 Dim vsoShape As Visio.Shape 

 'Set the module level application variable to 
 'trap Application level events. 
 Set vsoApplication = Application 

 'Begin a scope, set the module level variable. 
 lngScopeID = Application.BeginUndoScope("Draw Shapes") 

 'Draw three shapes. 
 Set vsoShape = ActivePage.DrawRectangle(1, 2, 2, 1) 
 ActivePage.DrawOval 3, 4, 4, 3 
 ActivePage.DrawLine 4, 5, 5, 4 

 'Change a cell (which would trigger a cell changed event). 
 vsoShape.Cells("Width").Formula = 5 

 'End and commit this scope. 
 Application.EndUndoScope lngScopeID, True 

End Sub 

Private Sub vsoApplication_CellChanged(ByVal Cell As IVCell) 

 'Check to see if this cell change is the result of something 
 'happening within the scope. 
 If vsoApplication.IsInScope(lngScopeID) Then 
 Debug.Print Cell.Name &; " changed in scope "; lngScopeID 
 End If 

End Sub 

Private Sub vsoApplication_EnterScope(ByVal app As IVApplication, _ 
 ByVal nScopeID As Long, _ 
 ByVal bstrDescription As String) 

 If vsoApplication.CurrentScope = lngScopeID Then 
 Debug.Print "Entering current scope " &; nScopeID 
 Else 
 Debug.Print "Enter Scope " &; bstrDescription &; "(" &; nScopeID &; ")" 
 End If 

End Sub 

Private Sub vsoApplication_ExitScope(ByVal app As IVApplication, _ 
 ByVal nScopeID As Long, _ 
 ByVal strDescription As String, _ 
 ByVal bErrOrCancelled As Boolean) 

 If vsoApplication.CurrentScope = lngScopeID Then 
 Debug.Print "Exiting current scope " &; nScopeID 
 Else 
 Debug.Print "ExitScope " &; bstrDescription &; "(" &; nScopeID &; ")" 
 End If 

End Sub
© 2018 Microsoft