Hi Andre,
I see we must start a little bit earlier:
hWnd is just a window handle variable taken as an example placeholder.
Here is a working example.
Just put one window above the other and move the mouse over the labels.
package require Tk
proc checkWhoIsTop {} {
if { [wm stackorder . isabove .t2] } {
puts "Ontop is: [wm title .]"
} else {
puts "Ontop is: [wm title .t2]"
}
}
toplevel .t2
pack [label .t2.l2 -text "enter me l2"]
pack [label .l1 -text "enter me l1"]
wm title . "main toplevel"
wm title .t2 "other toplevel"
bind .t2.l2 <Enter> { checkWhoIsTop }
bind .l1 <Enter> { checkWhoIsTop }
Hope this helps to start.
Best,
Detlef