how to detect main window size via code