ok this is the code to position any window given by its caption (title) on the desktop
it position the left,top,width and height of the window
try but change the window caption (i suppose your locale is english)
_Screen.WindowState=1
Local mycaption
mycaption="Explorateur de fichiers"
Run/N explorer.Exe
Inke(3)
#Define GW_HWNDLAST 1
#Define GW_HWNDNEXT 2
#Define GW_CHILD 5
Do Declare
Create Cursor csResult (HWnd N(12), isvisible N(1),;
leftpos I, toppos I, rightpos I, botpos I, wincap C(100), classname C(64))
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)
cWinClass= GetClsName(hCurrent)
nVisible = IsWindowVisible(hCurrent)
rc = Repli(Chr(0),16)
= GetWindowRect(hCurrent, @rc)
nLeft = buf2dword(Substr(rc, 1,4))
nTop = buf2dword(Substr(rc, 5,4))
nRight = buf2dword(Substr(rc, 9,4))
nBottom = buf2dword(Substr(rc, 13,4))
If Allt(Lower(mycaption)) == Allt(Lower(cWinCap))
Insert Into csResult Values (hCurrent, nVisible,;
nLeft, nTop, nRight, nBottom, cWinCap, cWinClass)
Endi
If hCurrent = hLastChild
Exit
Endif
hCurrent = GetWindow(hCurrent, GW_HWNDNEXT)
Enddo
Locate
If Reccount()=0
Messagebox("Window ["+mycaption+" ] not found...cancelling",16+4096,"error",1500)
Return .F.
Endi
lnHandle=HWnd
If HWnd=0
Messagebox("fails! no window on desktop....cancelling!",16+4096,"error",1500)
Return .F.
Endi
Local xleft,xtop,xwidth,xheight
m.xwidth=500
m.xheight=200
SetWindowPos(m.lnHandle,0, 0,0,m.xwidth+100,m.xheight-50,64)
Inke(1)
SetWindowPos(m.lnHandle,0, 100,0,m.xwidth,m.xheight+100,64)
Inke(1)
SetWindowPos(m.lnHandle,0, 100,300,m.xwidth-50,m.xheight,64)
Inke(1)
SetWindowPos(m.lnHandle,0,400,50,m.xwidth,m.xheight+40,64)
Inke(1)
SetWindowPos(m.lnHandle,0, 50,500,m.xwidth+100,m.xheight+100,64)
Inke(1)
m.xwidth=xwidth+200
m.xheight=m.xheight+200
SetWindowPos(m.lnHandle,0,(Sysmetric(1)-xwidth)/2,(Sysmetric(2)-xheight)/2,m.xwidth,m.xheight,64)
Retu
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)
Local cBuffer, nResult
cBuffer = Space(250)
nResult = GetWindowText(hWindow, @cBuffer, Len(cBuffer))
Return Substr(cBuffer, 1, nResult)
endfunc
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
Procedure Declare
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 SetWindowPos In user32;
INTEGER HWnd, Integer hWndInsertAfter,;
INTEGER x, Integer Y, Integer cx, Integer cy,;
INTEGER wFlags
endproc
note : can use findwindow API but i prefer this code .