You have a rather hairy state machine going on (I looked at your code again).
The difference I see is that you have ONE button which spawns window #1 or window #2 or window #3, depending on who's up already. But the logic to support that is part of the polling process of every loop. My app had one button for each window (each window was different). My reason for using occurrences was to eliminate all execution paths between the main and child windows. In other words the main didn't CALL the child directly, so therefore, they became parallel independent processes. This led to the correct behavior as far as windows on top, who has focus, etc. There are probably other ways to do it - VI server, for one. I did this project in 6.0 and didn't know about VI Server then.