Share via


Event.SetFilterCommands Method

Visio Automation Reference

Specifies an array of command ranges and a True or False value indicating how to filter events for each command range.

Version Information
 Version Added:  Visio 2002

Syntax

expression.SetFilterCommands(Commands())

expression   A variable that represents an Event object.

Parameters

Name Required/Optional Data Type Description
Commands() Required Long An array of command ranges and a True or False value specifying how to filter events for each command range.

Return Value
Nothing

Remarks

When an Event object created with the AddAdvise method is added to the EventList collection of a source object, the default behavior is that all occurrences of that event are passed to the event sink. The SetFilterCommands method provides a way of ignoring selected events based on command ID.

The Commands() parameter passed to SetFilterCommands is an array defined in the following way.

The number of elements in Commands() is a multiple of 3:

  • The first element contains the beginning command ID of the range (any member of VisUICmds).
  • The second element contains the end command ID of the range (any member of VisUICmds).
  • The third element contains a True or False value, which indicates whether you are listening to events for that command range (True to listen to events; False to exclude events).

For an event to successfully pass through a command filter, it must satisfy the following criteria:

  • It must have a valid command ID.
  • If all filters are True, the event must match at least one filter.
  • If all filters are False, the event must not match any filter.
  • If the filters are a mixture of True and False, the event must match at least one True filter and not match any False filters.

If there are no True ranges in the array, events are considered True.

For example, to set up an array that blocks out a single command, use the following:

Visual Basic for Applications
  
    Dim aFilterCommands(1 To (1 * 3)) As Long 
'Ignore the layout command.
aFilterCommands(1) = visCmdLayoutDynamic 
aFilterCommands(2) = visCmdLayoutDynamic 
aFilterCommands(3) = False

Or, to set up an array that listens only to the Send to Back command:

Visual Basic for Applications
  
    Dim aFilterCommands(1 To (3 * 3)) As Long 
'Pay attention to the "Send to Back" command. 
aFilterCommands(1) = visCmdObjectSendToBack 
aFilterCommands(2) = visCmdObjectSendToBack 
aFilterCommands(3) = True 

'Ignore any command IDs before the "Send to Back" command. 
aFilterCommands(4) = visCmdFirst 
aFilterCommands(5) = visCmdObjectSendToBack - 1 
aFilterCommands(6) = False 

'Ignore any command IDs after the "Send to Back" command. 
aFilterCommands(7) = visCmdObjectSendToBack + 1 
aFilterCommands(8) = visCmdLast 
aFilterCommands(9) = False

See Also