Can I make iconify-window binding work when minimize using window manager I can bind a function to run when Emacs iconifies a frame

(defun my-handle-iconify-frame()
  ;; I actually do something more useful than this...
  (message "my-handle-iconify-frame")
)
(define-key special-event-map [iconify-frame] (function my-handle-iconify-frame))


This runs my my-handle-iconify-frame function when I use M-x iconify-frame or a key binding that calls that function.

However, it does not run when I use the iconify icon (-) in the window frame.

I also tried adding before advice on iconify-frame but that also is not called when I iconify a frame via the window frame icon.

Is there some other hook or binding where I can set window manager event handlers?

I'm running GNU Emacs 24.2.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2012-08-27 on bob.porkrind.org
I solved this. I must make the function (interactive):

(defun my-handle-iconify-frame()
  (interactive)
  ;; I actually do something more useful than this...
  (message "in my-handle-iconify-frame")
)


obvious in retrospect, since it is run through a key binding, not as a hook function.