>OK, I didn't wait till tomorrow.
>
>* Here is the code I think will work *
>
>ON SHUTDOWN
>_screen.AddProperty( "awf" , .null. )
>Declare Integer GetActiveWindow In USER32.Dll
>
>
>Do Form FTP Name Main
>* no extra code here *
>_screen.awf=GetActiveWindow()
>
>
>* this shall be the last code before read events
>Declare SHORT SetForegroundWindow In USER32.Dll Integer HWnd
>If .Not. Isnull(_Screen.awf)
> If SetForegroundWindow(_screen.awf) # 0
> _screen.awf = .Null.
> main.caption = "I am on top"
> * MESSAGEBOX('Success')
> Else
> * MESSAGEBOX('Failure')
> Endif
>Endif
>Read Events
>QUIT
>
>* end *
>
>Try to mix this into your code.
>
>Shall I send you my complete test code as email?
That doesn't change anything. It goes into failure.