Thanks for the reply

I tried checking IsWindowVisible() function for the Main window. It always return true even if it is not seen on the screen.

i tried using getForegroundWindow() also. It returns hadle to the topmost window. So it is not possible to determine if the Main window is visble in the screen.

Is there any way to set the Z-Order of the new window one above the ZOrder of the main window?