共用方式為


Visio (的 Application.MarkerEvent 事件)

呼叫 QueueMarkerEvent 方法所造成。

語法

運算式MarkerEvent (appSequenceNumCoNtextString)

expression 代表 Application 物件的變數。

參數

名稱 必要/選用 資料類型 描述
應用程式 必要 [IVAPPLICATION] 使用中的 Microsoft Visio 實例。
SequenceNum 必要 Long 此事件相對於過去事件的序數位置。
CoNtextString 必要 字串 QueueMarkerEvent 方法傳送的內容字串。

註解

與 Visio 引發的其他事件不同,MarkerEvent 事件是由用戶端程式所引發的。 用戶端程式只有在呼叫 QueueMarkerEvent 方法時,才會收到 MarkerEvent 事件。

搭配使用 MarkerEvent 事件與 QueueMarkerEvent 方法時,用戶端程式可以將事件佇列在它本身。 用戶端程式會在 Visio 於發生 QueueMarkerEvent 呼叫時,引發所有位於其事件佇列中的事件後,收到 MarkerEvent 事件。

MarkerEvent 事件會將 QueueMarkerEvent 方法所傳送的內容字串,以及 MarkerEvent 事件的序號傳送至 MarkerEvent 事件處理常式。 其中一個值可用來將 QueueMarkerEvent 呼叫與 MarkerEvent 事件相互關聯。 如此一來,用戶端程式就能夠分辨出事件是不是由它產生的。

例如,會變更 Visio 儲存格值的用戶端程式可能只想要回應並非由它產生的 CellChanged 事件。 用戶端程式可以先呼叫 QueueMarkerEvent 方法,並傳遞內容字串,以供稍後用來括住其處理範圍。

 
vsoObject.QueueMarkerEvent "ScopeStart" 
 <My program changes cells here> 
vsoObject.QueueMarkerEvent "ScopeEnd" 

MarkerEvent 事件處理常式中,用戶端程式接著可以使用傳遞至 QueueMarkerEvent 方法的內容字串來識別它所造成的 CellChanged 事件。

 
Dim blsICausedCellChanges as Boolean 
 
Private Sub vsoObject_MarkerEvent (ByVal vsoApplication As Visio.IVApplication, _ 
 ByVal lngSequenceNum As Long, ByVal strContextString As String) 
 
 If strContextString = "ScopeStart" Then 
 blsICausedCellChanges = True 
 ElseIf strContextString = "ScopeEnd" Then 
 blsICausedCellChanges = "False" 
 End If 
 
End Sub 
 
Private Sub vsoObject_CellChanged (ByVal Cell As Visio.IVCell) 
 
 'Respond only if this client didn't cause a cell change. 
 If blsICausedCellChanges = False Then 
 <respond to the cell changes> 
 End If 
 
End Sub

如果您是使用 Microsoft Visual Basic 或 Visual Basic for Applications (VBA),則本主題中的語法會描述有效處理事件的常用方式。

如果您想要建立自己的 Event 物件,請使用 AddAddAdvise 方法。

若要建立可以執行附加元件的 Event 物件,可使用 Add 方法,因為它可適用於 EventList 集合。

若要建立用於接收通知的 Event 物件,則使用 AddAdvise 方法。

若要尋找您要建立之事件的事件代碼,請參閱 事件代碼

如果您要從接收通知的程式處理此事件,MarkerEvent事件是其中一個事件群組,可在Application物件的EventInfo屬性中記錄額外的資訊。

如前所述,EventInfo 屬性會傳回 ContextStringVisEventProcvarMoreInfo 引數則會是空白。

範例

這個範例會顯示如何使用 MarkerEvent 事件,標示事件佇列中的事件。

將此範例程式碼貼到 [ThisDocument 程式 代碼] 視窗中,然後執行 UseMarker。 輸出會顯示在 [即時運算] 視窗中。

 
Dim WithEvents vsoApplication As Visio.Application 
 
Private Sub vsoApplication_MarkerEvent(ByVal app As Visio.IVApplication, _ 
 ByVal lngSequenceNum As Long, ByVal strContextString As String) 
 Debug.Print "Marker: " & app.EventInfo(0) 
 
End Sub 
 
Private Sub vsoApplication_ShapeAdded(ByVal vsoShape As Visio.IVShape) 
 Debug.Print " ShapeAdded: " & vsoShape.Name 
 
End Sub 
 
Public Sub UseMarker() 
 
 Set vsoApplication = ThisDocument.Application 
 
 'MarkerEvent events can be used to comment a segment 
 'of events in the queue. 
 vsoApplication.QueueMarkerEvent "I am starting..." 
 ActivePage.DrawRectangle 0, 0, 3, 3 
 vsoApplication.QueueMarkerEvent "I am finished..." 
 
End Sub

[即時運算] 視窗中的輸出會類似於下列內容:

Marker: I am starting...

ShapeAdded: Sheet.1

Marker: I am finished...

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應