Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Running an external exe file from VFP
Message
From
22/10/2004 04:42:53
Jon Neale
Bond International Software
Wootton Bassett, United Kingdom
 
 
To
22/10/2004 04:21:00
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00953639
Message ID:
00953653
Views:
14
Sorry thats what you get when you cut and paste (not very well at that).

In the shutdown code of your exe put a call to the x_payrun function passing it the name of the window you want to close. I've included the complete version of x_parun (with the DEcl function) there are some bits in here that you wont need as they are specific to my app but when I tried to cut them out last time I ended up missing out half the functions.

Hope this makes a little more sense.
FUNCTION x_payrun
LPARAMETERS p_title,p_thread
* p_thread is used to check to see if the window has been closed

LOCAL llThread

IF EMPTY(p_title)
	RETURN -1
ENDIF 

llThread = .F.
IF TYPE("p_thread") = "N"
	llThread = .T.
ENDIF

#DEFINE GW_HWNDLAST  1 
#DEFINE GW_HWNDNEXT  2 
#DEFINE GW_CHILD     5 
DO decl 

LOCAL hDesktop, hFirstChild, hLastChild, rc, cWinCap, cWinClass,; 
    nVisible, nLeft, nTop, nRight, nBottom 

hDesktop = GetDesktopWindow() 
hFirstChild = GetWindow(hDesktop, GW_CHILD) 
hLastChild = GetWindow(hFirstChild, GW_HWNDLAST) 

hCurrent = hFirstChild 
DO WHILE .T. 

    cWinCap = GetWinText(hCurrent) 
	
	IF (UPPER(ALLTRIM(p_title))$UPPER(ALLTRIM(cWinCap))) and IsWindowVisible(hCurrent) <> 0

		* got the correct window 
		llReturn = hCurrent
		
		IF llThread
			IF hCurrent = p_thread 
				* window is still open keep solus waiting before shutting down
				RETURN hCurrent
			ELSE
				RETURN -1
			ENDIF
		ELSE
			* if we find it activate it before closing it 
			Declare Integer ShowWindow in Win32API ;
				Integer hwnd, Integer nCmdShow
			* Restore it to its last size and position
			= ShowWindow(hCurrent,9)
			EXIT 
		ENDIF
	ENDIF 
	
    IF hCurrent = hLastChild 
        llReturn = -1
        EXIT 
    ENDIF 
    hCurrent = GetWindow(hCurrent, GW_HWNDNEXT) 
ENDDO 

RETURN llReturn 
*
*
*
FUNCTION GetClsName(hWindow) 
    LOCAL nBufsize, cBuffer 
    cBuffer = Repli(Chr(0), 250) 
    nBufsize = GetClassName(hWindow, @cBuffer, Len(cBuffer)) 
RETURN SUBSTR(cBuffer, 1, nBufsize) 
*
*
*
FUNCTION GetWinText(hWindow) 
* returns window title bar text -- Win9*/Me/XP/2000 
    LOCAL cBuffer, nResult 
    cBuffer = Space(250) 
    nResult = GetWindowText(hWindow, @cBuffer, Len(cBuffer)) 
RETURN SUBSTR(cBuffer, 1, nResult) 
*
*
*
FUNCTION buf2dword(lcBuffer) 
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ; 
    BitLShift(Asc(SUBSTR(lcBuffer, 2,1)),  8) +; 
    BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +; 
    BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24) 
*
*
*
PROCEDURE decl 
    DECLARE INTEGER GetDesktopWindow IN user32 
    DECLARE INTEGER GetWindow IN user32 INTEGER hwnd, INTEGER wFlag 
    DECLARE INTEGER GetWindowRect IN user32 INTEGER hwnd, STRING @lpRect 
    DECLARE INTEGER IsWindowVisible IN user32 INTEGER hWnd 

    DECLARE INTEGER GetWindowText IN user32; 
        INTEGER hwnd, STRING @lpString, INTEGER cch 

    DECLARE INTEGER GetClassName IN user32; 
        INTEGER hWnd, STRING lpClassName, INTEGER nMaxCount 

	DECLARE INTEGER GetLastError IN kernel32
	
RETURN
*
*
*
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform