SetFilterCommands method

Microsoft Visio Developer Reference

SetFilterCommands method

   Example   

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

Version added

2002

Syntax

object.SetFilterCommands commands

object

Required. An expression that returns an Event object.

commands

Required Long. An array of command ranges and a True or False value specifying how to filter events for each command range.

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 argument 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:

Dim cmdArray (1 * 3) As Long
'Ignore the layout command
cmdArray(1) = visCmdLayoutDynamic
cmdArray(2) = visCmdLayoutDynamic
cmdArray(3) = False

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

Dim cmdArray (3 * 3) As Long
' Pay attention to the Send To Back command
cmdArray(1) = visCmdObjectSendToBack
cmdArray(2) = visCmdObjectSendToBack
cmdArray(3) = True
'Ignore any command IDs before the Send To Back command
commands(4) = visCmdCMDFIRST
commands(5) = visCmdObjectSendToBack - 1
cmdArray(6) = False
'Ignore any command IDs after the Send To Back command
commands(4) = visCmdObjectSendToBack + 1
commands(5) = visCmdCMDLAST
commands(6) = False