>>>From my VFP application I am running another executable using ! /N7 xyz.exe. The executable is a background process without a window, but when running the executable it results in losing the focus of the VFP application. So the user must click on the form again to continue working. I try to set the focus to a textbox on the form, but the application itself does not have focus anymore.
>>>The best would be if the focus would not go away in the first place, but I tried different ways and could not succeed. Any ideas?
>>
>>
>>*To use:
>>*
>>*lcProg = 'Yourpath\yourprog.exe'
>>*lcPar = 'some parameters'
>>*ShellX(lcProg, lcPar)
>>Lparameters tcURL, tcParameter
>>if empty(tcParameter)
>> tcParameter = ''
>>Endif
>>#define SW_HIDE 0
>>#DEFINE SW_SHOWNORMAL 1
>>#DEFINE SW_SHOWMINIMIZED 2
>>#DEFINE SW_SHOWMAXIMIZED 3
>>*!* Legal verbs: open, edit, print, find, explore, NULL
>>DECLARE INTEGER ShellExecute IN shell32.dll ;
>> INTEGER hndWin, STRING cAction, STRING cFileName, ;
>> STRING cParams, STRING cDir, INTEGER nShowWin
>>ShellExecute( 0, "open", tcURL, tcParameter , "", SW_SHOWNORMAL )
>
>Thanks, I am now using ShellExecute, but the focus issue remains the same. I tested with another executable to be sure (Notepad.exe) and then it does work properly, so I think the culprit is the executable that I run, which is another small VFP executable. This executable has Screen=OFF in the config.fpw and _SCREEN.Visible = .F. in the INIT of main.prg. So even with these settings, and running the exe with SW_SHOWHIDE it takes away the focus from the calling program and sets the focus to the next running window (because it cannot set the focus to itself I assume). I wonder if there is another setting I overlook.
As far as I remember, there is an API call you can use to set focus to whatever program you want, maybe you can use it to set focus back to the caller?