Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GETFILE position on screen
Message
From
10/12/2001 08:46:31
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
10/12/2001 07:08:58
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00591997
Message ID:
00592011
Views:
20
>Can I somehow control the position on the screen of the getfile()
>commands dialog. (i have a control they sometimes like to read a value from
>so they always have to move the getfile() screen)
>
>Alternatively can I use another control API that will remeber the screen position...
>
>I tried :
>
>oShell = createobject("Shell.Application")
>* Get directory
>oFolder = oShell.BrowseForFolder(0, "Please Select folder",0)
>
>Strangely it only remembers the resize left and right but not up and don and the screen position...
>
>Thanks
declare integer GetActiveWindow in win32API
declare short GetClientRect in win32API integer HWND, string @ lpRect
declare short MoveWindow in win32API ;
  integer hWnd, integer X, integer Y, ;
  integer nWidth, integer nHeight, short bRepaint

#define BIF_BROWSEFORCOMPUTER  0x1000
#define BIF_BROWSEFORPRINTER   0x2000
#define BIF_BROWSEINCLUDEFILES 0x4000 
oShell = createobject("Shell.Application")
* Get directory
oTmr = CreateObject('myTimer',400,300)
oFolder = oShell.BrowseForFolder(0, "Please Select folder", 0 )
oTmr = .null.
release oTmr

define class myTimer as Timer
	Interval=10
	nLeft=0
	nTop=0
	procedure init
	lparameters tnLeft,tnTop
	this.nLeft=tnLeft
	this.nTop=tnTop
	endproc
	procedure timer
	local HWND, lnLeft, lnRight, lnTop, lnBottom
	if this.Tag='DONE'
		this.Enabled=.f.
		return
	endif
	HWND = GetActiveWindow()
	lpRect=space(4*4)
	GetClientRect(HWND,@lpRect)
	lnLeft=this.Str2Int(substr(lpRect,1,4))
	lnTop=this.Str2Int(substr(lpRect,5,4))
	lnRight=this.Str2Int(substr(lpRect,9,4))
	lnBottom=this.Str2Int(substr(lpRect,13,4))
	MoveWindow(HWND,this.nLeft,this.nTop,;
            lnRight-lnLeft,lnBottom-lnTop+sysmetric(9),1)
	this.Tag='DONE'
	endproc
	procedure Str2Int
	lparameters tcStr
	local ix,lnRet
	lnRet = 0
	for ix=1 to 4
	 lnRet = lnRet + asc(substr(tcStr,ix))*256^(ix-1)
	endfor
	return lnRet
	endproc
enddefine
Beware top,left position are screen coordinates not client area. You can find conversion functions for that in a message I posted earlier. The specific keyword to search I remember is GetCaretPos.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform