Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Regaining Focus from ShellExecute
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Regaining Focus from ShellExecute
Miscellaneous
Thread ID:
01324662
Message ID:
01324662
Views:
60
Hi Gang!

I have a problem here.....

I have a method in a form that runs the ShellExecute API to run an external webservice program.....

As soon as it executes this API, the method continues and runs a loop to look for a textfile returned from the webservice....

But the focus stays on the the webservice and I would like to have the focus back on the object running the method (this is because in the timing loop there is an INKEY looking for the ESC key to exit the timing loop and return control back to the user (to bail out if the webservice is taking too long)).

Here is some of the code....
..... code above to prepare to run wHccGet.exe a webservice and lcEXE the parameter string to give to wHccGet.exe....

		DECLARE LONG ShellExecute in "shell32.dll" long hwnd, string lpszOp, ;
		             	string lpszFile, string lpszParams, ;
		                string lpszDir, long nShowCmd

		ShellExecute( 0, "open", SYS(5) + CURDIR() + "WHccGet.exe", lcEXE, SYS(5) + CURDIR() ,2)
	
		CLEAR DLLS "ShellExecute"

*TMT 05/30/08 Wait for return file with data from datawarehouse.... if not back in 20 seconds, then show
*failure and allow to try again.....
		ltStart  = DATETIME()
		lbFileExists = .f.
		DO WHILE (DATETIME() - ltStart) < 21 
		   Thisform.pgfFSN.pageFSN.edtStatus.Value = "Waiting for response from Frequent Shopper - " + STR((DATETIME() - ltStart),3,0) + " seconds elapsed."
		   IF FILE("C:\POSTEMP\" + lcDateTime + lcDecimalSeconds + '.FRQ') 
		      lbFileExists = .t.
		      EXIT
		   ENDIF

*****************
*here is where I look for the ESC key.... but the focus is on the wHCCGet webservice which is minimized to the task bar....
*If I take the mouse and click on the executing main program to bring focus to it, I can press ESC and exit.... 
*I need the focus back on the main program as soon as the webservice is minimized to the taskbar.....
*****************
		   IF INKEY() = 27	&& ESC pressed
		   		Thisform.p_exitloop = .T.
		   		Thisform.pgfFSN.pageFSN.edtStatus.Value = "USER PRESSED ESCAPE TO CANCEL FREQUENT SHOPPER"
		   		EXIT 
		   ENDIF 
		ENDDO
		
		IF NOT lbFileExists AND NOT Thisform.p_exitloop
		   MESSAGEBOX("Frequent Shopper System is temporarily down." + CHR(13) + ;
		   				CHR(13) + "Please try again in a few moments.",0+16+0,"Frequent Shopper Problem")
		   RETURN 
		ELSE
			IF NOT lbFileExists AND Thisform.p_exitloop	&& We ESCAPED out
				RETURN 
			ENDIF 
		ENDIF
		Thisform.pgfFSN.pageFSN.edtStatus.Value = " "
Any ideas?

Thanks!
Tommy Tillman A+ NetWork+ MCP
Next
Reply
Map
View

Click here to load this message in the networking platform