Hi Guido,
hier ein Beispiel:
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Declare Function GetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Declare Function GetSaveFileName Lib "comdlg32.dll" _
Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Const OFN_ALLOWMULTISELECT = &H200
Private Const OFN_CREATEPROMPT = &H2000
Private Const OFN_ENABLEHOOK = &H20
Private Const OFN_ENABLETEMPLATE = &H40
Private Const OFN_ENABLETEMPLATEHANDLE = &H80
Private Const OFN_EXPLORER = &H80000 ' Windows 95 Only
Private Const OFN_EXTENSIONDIFFERENT = &H400
Private Const OFN_FILEMUSTEXIST = &H1000
Private Const OFN_HIDEREADONLY = &H4
Private Const OFN_LONGNAMES = &H200000 ' Windows 95 Only
Private Const OFN_NOCHANGEDIR = &H8
Private Const OFN_NODEREFERENCELINKS = &H100000 ' Windows 95 Only
Private Const OFN_NOLONGNAMES = &H40000
Private Const OFN_NONETWORKBUTTON = &H20000
Private Const OFN_NOREADONLYRETURN = &H8000
Private Const OFN_NOTESTFILECREATE = &H10000
Private Const OFN_NOVALIDATE = &H100
Private Const OFN_OVERWRITEPROMPT = &H2
Private Const OFN_PATHMUSTEXIST = &H800
Private Const OFN_READONLY = &H1
Private Const OFN_SHAREAWARE = &H4000
Private Const OFN_SHAREFALLTHROUGH = 2
Private Const OFN_SHARENOWARN = 1
Private Const OFN_SHAREWARN = 0
Private Const OFN_SHOWHELP = &H10
Private Function DialogOpenSave(hWnd As Long, _
ByVal sTitle As String, _
sInitDir As String, _
ByVal sFile As String, _
ByVal sFilter As String, _
ByVal sDefExt As String, _
Optional ByVal nSaveFile As Integer = 0, _
Optional nFilterIndex As Integer = 1)
Dim oFile As OPENFILENAME
Dim wSize As Long
Dim Memhandle As Long
Dim szFile As String
Dim szFilter As String
Dim nResult As Long
szFile = sFile + String$(260 - Len(sFile), 0)
szFilter = Replace(sFilter + "||", "|", Chr$(0))
With oFile
.lStructSize = Len(oFile)
.hwndOwner = hWnd
.nFilterIndex = 1
.nMaxFile = Len(szFile)
.nFilterIndex = nFilterIndex
Select Case nSaveFile
Case 0
.flags = OFN_HIDEREADONLY Or OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST
Case 1
.flags = OFN_HIDEREADONLY Or OFN_PATHMUSTEXIST Or OFN_OVERWRITEPROMPT
Case 2
.flags = OFN_HIDEREADONLY Or OFN_PATHMUSTEXIST
End Select
.lpstrFile = szFile
.lpstrFilter = szFilter
.lpstrTitle = sTitle
.lpstrDefExt = sDefExt
.lpstrInitialDir = sInitDir
If nSaveFile = 0 Then
nResult = GetOpenFileName(oFile)
Else
nResult = GetSaveFileName(oFile)
End If
If nResult = 0 Then
DialogOpenSave = ""
Exit Function
End If
sFile = Left$(.lpstrFile, InStr(.lpstrFile, Chr$(0)) - 1)
sInitDir = Left$(sFile, .nFileOffset)
nFilterIndex = .nFilterIndex
DialogOpenSave = Right$(sFile, Len(sFile) - .nFileOffset)
End With
End Function _________________________
Professionelle Entwicklerkomponenten
www.tools4vb.de |