setting delegate before showing in window. sending delegate method if already hidden. fixed warning