NextPrevUpTopContentsIndex

3.3.5 Using connection points

Event sink interfaces can be connected and disconnected using the functions interface-connect and interface-disconnect.

For example, the following macro connects a sink interface pointer event-handler to a source of i-clonable-events events clonable for the duration of its body.

(defmacro handling-clonable-events ((clonable event-handler)
                                    &body body)
  (lw:with-unique-names (cookie)
    (lw:rebinding (clonable event-handler)
      `(let ((,cookie nil))
         (unwind-protect
             (progn
               (setq ,cookie
                     (interface-connect ,clonable
                                        'i-clonable-events
                                        ,event-handler))
               ,@body)
           (when ,cookie
             (interface-disconnect ,clonable
                                   'i-clonable-events
                                   ,cookie)))))))

LispWorks COM/Automation User Guide and Reference Manual - 21 Feb 2008

NextPrevUpTopContentsIndex