*-*********************************************************************************************** *-* 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