Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling CreateProcess() from a modal form
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 6
OS:
Windows XP SP2
Network:
Windows XP
Miscellaneous
Thread ID:
01362241
Message ID:
01364393
Views:
13
Hi Gregory,

Sorry for the delayed response - got wrapped up in other stuff for a while.

Thanks for the info - that solved the problem.
However, I still had to disable most of the controls on the VFP form while the external app was running so I opted to go with Christian's suggestion of hiding my app completely until the external app finished.

Thanks to both yourself and Christian.

Carl

>>Hi All,
>>
>>Using VFP6
>>I'm calling an external program from a modal form using the API CreateProcess() function using the technique described here http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q191/5/84.asp&NoWebContent=1 to cause my app to wait for the external executable to finish. The external executable does have a UI with a window displayed in front of my app.
>>
>>The problem is that if I switch back to my app before closing the external program, the modal form no longer has the same behaviour in that another form can be activated. The problem here is that the modal form's calling form occupies the entire screen and its "movable" property is set to .F. so the modal form "disappears" behind the calling form and cannot be reactivated. From a user's perspective, the app is hung.
>>
>>Is there some way around this behaviour ? Even making my app unavailable while the external program executes would be OK. The user should not be switching back to it anyway.
>>
>>Thanks,
>>Carl
>
>
>The problem you are facing is the DOEVENTS
>
>Try
>
>replace
>
> DO WHILE .T.
>      * Use timeout of TIMEOUT_INTERVAL msec so the display
>      * will be updated. Otherwise, the VFP window never repaints until
>      * the loop is exited.
>      IF WaitForSingleObject(hProcess, WAIT_INTERVAL) != WAIT_TIMEOUT
>           EXIT
>         ELSE
>            DOEVENTS
>         ENDIF
>      ENDDO
>
>
>
>with
>
>local ProcessExitCode, WaitExitStatus, hThread
>ProcessExitCode = 0
>hThread = str2long(SUBSTR(process_info, 5, 4))
>
>
>&& at least wait for the process to start completely
>&& ProcessExitCode = -1 is process gone (I think)
>
>ProcessExitCode = WaitForInputIdle(m.hProcess, 0xffffffff)
>
>if( m.hProcess = 0 )
>   && not there
>
>else
>
>
>    		do while TRUE 
>			=WaitWindowAtMouse('Waiting for process ...')
>			
>			WaitExitStatus = WaitForSingleObject(m.hProcess , 5000-4500)
>	
>			do case
>			case m.WaitExitStatus = 0x102	&& Timed out
>			
>			case empty(m.WaitExitStatus) && gone
>				do case
>				case empty( GetExitCodeProcess(m.hProcess , @m.ProcessExitCode) )
>					assert FALSE
>					ProcessExitCode = -1
>				otherwise
>					
>				endcase
>				exit
>				
>			otherwise
>				assert FALSE
>				exit
>			endcase
>			
>		enddo
>		=WaitWindowAtMouse()
>
>endif
>
>=CloseHandle(m.hThread)
>
>*-------------------------------------------------------------------------------
>function WaitWindowAtMouse(msg)
>
>	if( !empty(m.msg) )
>		wait window nowait at mRow(_screen.name), mCol(_screen.name) m.msg
>	else
>		wait clear
>	endif
>endfunc
>*--------------------------------------------------------------------------
>
Carl Chambers
Cardol Data Systems
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform