improved dimmer and formwindow function