Stuart McLachlan
stuart at lexacorp.com.pg
Sun Nov 9 20:50:50 CST 2003
On 9 Nov 2003 at 7:57, Tom Keatley wrote: > Hi all... > I am using the code below to bring up a standard file dialogue in Windows to > select a file for import which works GREAT. > > I would like however the dialogue to appear in the centre of the form it is > being called from. I believe this will have something to do with the HWND > but have no idea how to proceed from here. > > Can anyone assist ? > > Just uncomment the line 'OpenFile.hwndOwner = me.Hwnd and the dialog becomes a child of the form is opened from. > > > Function APIDialogBox() > Dim OpenFile As OPENFILENAME > Dim lReturn As Long > Dim sFilter As String > OpenFile.lStructSize = Len(OpenFile) > 'OpenFile.hwndOwner = me.Hwnd > 'OpenFile.hInstance = App.hInstance > sFilter = "Pied Piper Order Files (*.eml)" & Chr(0) & "*.eml" & > Chr(0) _ > & "OLD Pied Piper Order Files (*.XXX)" & Chr(0) & "*.XXX" & Chr(0) > _ > & "All Files (*.*)" & Chr(0) & "*.*" & Chr(0) > 'sFilter = "All Files (*.*)" & Chr(0) & "*.*" & Chr(0) > OpenFile.lpstrFilter = sFilter > 'OpenFile.nFilterIndex = 1 > OpenFile.lpstrFile = String(257, 0) > > OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1 > OpenFile.lpstrFileTitle = OpenFile.lpstrFile > OpenFile.nMaxFileTitle = OpenFile.nMaxFile > OpenFile.lpstrInitialDir = "C:\_WebOrders\" > OpenFile.lpstrTitle = "Please Select a Web Order" > OpenFile.flags = 0 > lReturn = GetOpenFileName(OpenFile) > If lReturn = 0 Then > APIDialogBox = "" > Else > APIDialogBox = Trim(OpenFile.lpstrFile) > 'gives me pathname\filename > OrdFilNam = OpenFile.lpstrFile > 'gives me filename > filnam = OpenFile.lpstrFileTitle > 'gives me path\ > PthNam = Left(OpenFile.lpstrFile, OpenFile.nFileOffset) > 'Call WEBIMPORT > End If > > > End Function > > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com -- Lexacorp Ltd http://www.lexacorp.com.pg Information Technology Consultancy, Software Development,System Support.