Вот код моей функции:
- Код: Выделить всё
Option Explicit
Public Const OFN_ALLOWMULTISELECT As Long = &H200
Public Const OFN_FILEMUSTEXIST As Long = &H1000
Public Const OFN_HIDEREADONLY As Long = &H4
Public Const OFN_LONGNAMES As Long = &H200000
Public Const OFN_NOREADONLYRETURN As Long = &H8000&
Public Const OFN_OVERWRITEPROMPT As Long = &H2
Public Const OFN_PATHMUSTEXIST As Long = &H800
Public 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
Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (ByRef pOpenfilename As OPENFILENAME) As Long
Public Const GET_TRUE As Long = 1
Public Function GetOpenDialog(ByVal hwndMain As Long, ByVal strTitle As String, _
ByVal strFilter As String, ByVal lFilter As Long, ByVal strName As String, _
Optional ByVal bAllowMultiselect As Boolean = False, _
Optional ByVal strInitDirectory As String = vbNullString) As String
Dim CommonDialogOpen As OPENFILENAME
Dim X As Long
With CommonDialogOpen
.lStructSize = Len(CommonDialogOpen)
.hwndOwner = hwndMain
.hInstance = App.hInstance
.lpstrTitle = strTitle
.lpstrFilter = strFilter
.nFilterIndex = lFilter
.lpstrInitialDir = strInitDirectory
.lpstrFile = strName & LPBuff(512 - Len(strName))
.nMaxFile = 511
.lpstrFileTitle = LPBuff(512)
.nMaxFileTitle = 511
.flags = OFN_HIDEREADONLY Or OFN_LONGNAMES Or OFN_FILEMUSTEXIST
If bAllowMultiselect Then .flags = .flags Or OFN_ALLOWMULTISELECT
End With
X = GetOpenFileName(CommonDialogOpen)
If X <> GET_TRUE Then
GetOpenDialog = vbNullString
Exit Function
Else
GetOpenDialog = StripTerminator(CommonDialogOpen.lpstrFile)
End If
End Function
Public Function LPBuff(ByVal lNumber As Long) As String
LPBuff = String$(lNumber, vbNullChar)
End Function
Public Function StripTerminator(ByVal strString As String) As String
Dim intZeroPos As Integer
intZeroPos = InStr(strString, vbNullChar)
If intZeroPos > 0 Then
StripTerminator = Left$(strString, intZeroPos - 1)
Else
StripTerminator = strString
End If
End Function
Мне-то нужно мульти выделение. Так в чём тут дело?
P.S.
Переход на ComDlg32.ocx не предлагать