Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
List of handles for all open editor windows
Message
De
06/05/2010 09:14:36
 
 
À
05/05/2010 19:26:14
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01463339
Message ID:
01463403
Vues:
66
Below is code that I am using to get a list of the forms in VFP; I am then cycling through the list to get the coordinates (left, top) but you could adopt for your own use. It gets all windows -- I don't know of a way to segregate them based on source (scx from vcx from prg windows). There might be a property on each window that you can use... NOTE: the below code calls Win32 API functions that are declared via a global DECLARE DLL prg that I have (declared as needed).
*-***********************************************************************************************
*-*  Routine for determining if a window is already present at the left and top coordinates
*-*
FUNCTION GKKGetVFPForms
LPARAMETERS pnLeft,pnTop
LOCAL llFound, loWindow, loForm, lhDesktop, lhFirstChild, lhLastChild, lhCurrent, lcWinCap
#DEFINE GW_HWNDLAST   1
#DEFINE GW_HWNDNEXT   2
#DEFINE GW_CHILD      5
llFound = .F.
IF pnLeft > 0 .AND. pnTop > 0
	CREATE CURSOR c_wintext (winhandle I, wintitle C(200))
*-*	Get VFP forms
	loWindow = CREATEOBJECT("Twindow", _VFP.hWnd, 0)
*-*	Get Forms in Windows
	lhDesktop    = GetDesktopWindow()
	lhFirstChild = GetWindow(lhDesktop, GW_CHILD)
	lhLastChild  = GetWindow(lhFirstChild, GW_HWNDLAST)
	lhCurrent    = lhFirstChild
	DO WHILE .T.
		lcWinCap = GetWinText(lhCurrent)
		INSERT INTO c_wintext (winhandle,wintitle) VALUES (lhCurrent,lcWinCap)
		IF lhCurrent = lhLastChild
			EXIT
		ENDIF
		lhCurrent = GetWindow(lhCurrent, GW_HWNDNEXT)
	ENDDO
*-*	Check for position overlap
	SELECT c_wintext
	SCAN FOR !EMPTY(wintitle)
		lpRect = REPLICATE(CHR(0),16)
		=GetWindowRect(c_wintext.winhandle, @lpRect)
		lnLeft = buf2dword(SUBSTR(lpRect,1,4))
		lnTop  = buf2dword(SUBSTR(lpRect,5,4))
		IF lnLeft = pnLeft .AND. lnTop = pnTop
			llFound = .T.
			EXIT
		ENDIF
	ENDSCAN
	USE
ENDIF
RETURN llFound
ENDFUNC


*-***********************************************************************************************
*-* Converts buffer to integer
*-*
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)
ENDFUNC


*-***********************************************************************************************
*-* Converts buffer to integer
*-*
FUNCTION GetWinText(phHdl)
LOCAL lcBuffer, lnResult
lcBuffer = SPACE(200)
lnResult = GetWindowText(phHdl, @lcBuffer, LEN(lcBuffer))
RETURN UPPER(LEFT(lcBuffer, lnResult))
ENDFUNC

*-***********************************************************************************************
*-*  Retreives FoxPro based forms (In-Screen mode)
*-*
DEFINE CLASS Twindow As Custom
	PROCEDURE  Init
		LPARAMETERS pnHandle, pnParent
		LOCAL lhChild, loChild, lhNext, loNext, lcWinCap
		IF pnHandle = 0
			RETURN .F.
		ENDIF
		lcWinCap = GetWinText(pnHandle)
		INSERT INTO c_wintext (winhandle,wintitle) VALUES (pnHandle,lcWinCap)
		lhChild = GetWindow(pnHandle, GW_CHILD)
		loChild = CREATEOBJECT("Twindow", lhChild, pnHandle)
		IF pnParent <> 0
			lhNext = GetWindow(pnHandle, GW_HWNDNEXT)
			loNext = CREATEOBJECT("Twindow", lhNext, pnParent)
		ENDIF
	ENDPROC
ENDDEFINE
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform