I think there is a way to know when the form has focus, it could be an event, or a windows message. I don't remember