Version 0 of How I catch iconification and such

Updated 2003-12-21 18:23:07

Use <Unmap> and <Map>:

    bind . <Unmap> {puts "Someone just iconified me."}

More sophisticated programming recognizes "that toplevel bindings apply to every child widget, so you should also test that the widget is a toplevel" and also that "Unmap will also happen when you switch desktops, so you have to ... test the state":

    bind . <Unmap> {unmapper %W}

    proc unmapper W {
    if {[string equal [winfo toplevel $W] $W] && 
        [string equal [wm state $W] iconic]} {
        puts "Minimizing $W."
     }