Paul,
Think this is what you meant.
Just change the references to GetPrinter to GetFile
Dave
PS. If the formatting is to cock, I'll post it up on the web for download
**************
* Program to move the GetPrinter Dialogue from
* the top left of the Screen and display the selected printer
* Author: Modified by Dave Crozier from a VB program
*
With _Screen
If Vartype(.PrinterDlg) <> "U"
.RemoveObject("PrinterDlg")
Endif
.AddObject("PrinterDlg", "PrinterDlg")
* .PrinterDlg.ShowDialog(.Width-500, .Height-300)
.PrinterDlg.ShowDialog(130, 10)
Endwith
* end of main
Return
Define Class PrinterDlg As Timer
#Define GetPrinter_Caption "Printer"
Protected XPos, YPos
hDialog=0
PrinterName=""
* Display the GetPrinter Dialogue
Procedure ShowDialog(nx, ny)
This.XPos = m.nX
This.YPos = m.nY
This.Interval=10
This.PrinterName = GetPrinter()
= Messagebox(This.PrinterName)
Endproc
* Initialise the Object
Procedure Init
* Do all the declares for the required DLL/API Calls
* Get the active Window
Declare Integer GetActiveWindow In user32
* Extract the title of the Window
Declare Integer GetWindowText In user32;
INTEGER HWnd, String @lpString, Integer cch
* Set/Get Window position
Declare Integer SetWindowPos In user32;
INTEGER HWnd, Integer hWndInsertAfter,;
INTEGER X, Integer Y, Integer CX, Integer CY,;
INTEGER wFlags
*
Endproc
* Add in a timer which kicks in when the
* modal dialogue has been displayed
* Note this times still works even though the
* window is modal
Procedure Timer
If This.hDialog = 0
If This.DialogFound()
This.SetPosition
Endif
This.Interval = 0
Endif
Endproc
* See if dialogue window has been found
Protected Function DialogFound
Local hWindow, cTitle
hWindow = getactivewindow()
cTitle = This.getwintext(hWindow)
This.hDialog = Iif(cTitle=GetPrinter_Caption, hWindow, 0)
*
Return (This.hDialog <> 0)
Endproc
* Set the position of the window up
* on the screen
Protected Procedure SetPosition
#Define hwnd_top 0
#Define swp_nosize 1
#Define swp_showwindow 0x40
= setwindowpos(This.hdialog, hwnd_top,;
THIS.xpos, This.ypos, 0,0,;
swp_showwindow+swp_nosize)
*
Endproc
* Get the window text
Protected Function GetWinText(hWindow)
Local nBufSize, cBuffer
nBufSize = 128
cBuffer = Repli(Chr(0), nBufSize)
nBufSize = getwindowtext(hWindow, @cBuffer, nBufSize)
Return Iif(nBufSize=0, "", Left(cBuffer, nBufSize))
Endfunc
*
Enddefine
*
* End of Program
**************
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Paul Newton
Sent: 26 March 2008 13:28
To: profox
Subject: GETFILE() window location
Hi all
Tristan first posed this question a couple of years ago:
Is there a way to tell VFP where to display the window when issuing a
GETFILE()?
And Dave C suggested:
How about wrapping the getfile() up with a timer in the background which
picks up the window handle via API calls and then repositions it according
to your wishes. Somewhere I have an example of this approach using the
Getprinter() dialogue so I know it works and yes the timer still fires even
thought the Getprinter() dialogue is modal.
I'll try and dig it out tonight.
He even said:
I did but its at home at the moment so I'll post it on the list tonight.
Trouble is I can find no trace of this - do you still have it (Dave) ? Or
Tristan ?
Thanks
Paul Newton
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.