fix the OwningWindow is null

set the OwningWindow value before using it