|
55 Кб. |
|
| Здравствуйте все)
Суть вопроса: Приведенным ниже способом я вызываю окно указания файла.
Все бы хорошо, но есть вопрос: Как можно запустить эту процедуру, что бы вместо отображения файлов в режиме список (у меня так по-умолчанию) - выводились файлы в режиме таблицы (с размером, типом и датой изменения).
В приложенном файле сверху показано как у меня выводится, а снизу как хотелось бы это видеть по-умолчанию.
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 Sub Command1_Click()
Dim ofn As OPENFILENAME
ofn.lStructSize = Len(ofn)
ofn.hwndOwner = Form1.hWnd
ofn.hInstance = App.hInstance
ofn.lpstrFilter = "Text Files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "All files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
ofn.lpstrFile = Space$(254)
ofn.nMaxFile = 255
ofn.lpstrFileTitle = Space$(254)
ofn.nMaxFileTitle = 255
ofn.lpstrInitialDir = CurDir
ofn.lpstrTitle = "Our File Open Title"
ofn.flags = 0
Dim a
a = GetOpenFileName(ofn)
If (a) Then
MsgBox "File to Open: " + Trim$(ofn.lpstrFile)
Else
MsgBox "Cancel was pressed"
End If
End Sub |
Подскажите кто что думает, весь интернет облазал...
| |
|
| |
|
|
|
|
Подскажите кто что думает, весь интернет облазал
|
а что тут думать? жмем F1
InitialView Property
See AlsoApplies ToExampleSpecificsReturns or sets an MsoFileDialogView constant representing the initial presentation of files and folders in a file dialog box. Read/write.
MsoFileDialogView can be one of these MsoFileDialogView constants.
msoFileDialogViewDetails
msoFileDialogViewLargeIcons
msoFileDialogViewList
msoFileDialogViewPreview
msoFileDialogViewProperties
msoFileDialogViewSmallIcons
msoFileDialogViewThumbnail This constant is only available in conjunction with Microsoft Windows 2000 or Microsoft Windows Millennium Edition, or later.
msoFileDialogViewWebView Not available. If you select this constant, the default view will be used.
expression.InitialView
expression Required. An expression that returns one of the objects in the Applies To list.
Example
The following example displays a File Picker dialog box in details view using the FileDialog object and displays each selected file in a message box.
Sub Main()
'Declare a variable as a FileDialog object.
Dim fd As FileDialog
'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant
'Use a With...End With block to reference the FileDialog object.
With fd
'Set the initial view to the details view.
.InitialView = msoFileDialogViewDetails
'Use the Show method to display the File Picker dialog box and return the user's action.
'If the user presses the action button...
If .Show = -1 Then
'Step through each string in the FileDialogSelectedItems collection.
For Each vrtSelectedItem In .SelectedItems
'vrtSelectedItem is a String that contains the path of each selected item.
'You can use any file I/O functions that you want to work with this path.
'This example simply displays the path in a message box.
MsgBox "Selected item's path: " & vrtSelectedItem
Next vrtSelectedItem
'If the user presses Cancel...
Else
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing
End Sub
|
| |
|
| |
|
|
|
| Хммм, а КАК эту переменную (FileDialogViewDetails) вкрячить то в выше приведенную ф-цию?))) Вот что у меня ни как не выходит.. Поможите)
Вот тот список переменных, что я смог найти. Но среди них нет ни одной, отвечающей за вывод в виде списка...
Const OFN_ALLOWMULTISELECT As Long = &H200
Const OFN_CREATEPROMPT As Long = &H2000
Const OFN_ENABLEHOOK As Long = &H20
Const OFN_ENABLESIZING As Long = &H800000
Const OFN_ENABLETEMPLATE As Long = &H40
Const OFN_ENABLETEMPLATEHANDLE As Long = &H80
Const OFN_EXPLORER As Long = &H80000
Const OFN_EXTENSIONDIFFERENT As Long = &H400
Const OFN_FILEMUSTEXIST As Long = &H1000
Const OFN_HIDEREADONLY As Long = &H4
Const OFN_LONGNAMES As Long = &H200000
Const OFN_NOCHANGEDIR As Long = &H8
Const OFN_NODEREFERENCELINKS As Long = &H100000
Const OFN_NOLONGNAMES As Long = &H40000
Const OFN_NONETWORKBUTTON As Long = &H20000
Const OFN_NOREADONLYRETURN As Long = &H8000
Const OFN_NOTESTFILECREATE As Long = &H10000
Const OFN_NOVALIDATE As Long = &H100
Const OFN_OVERWRITEPROMPT As Long = &H2
Const OFN_PATHMUSTEXIST As Long = &H800
Const OFN_READONLY As Long = &H1
Const OFN_SHAREAWARE As Long = &H4000
Const OFN_SHOWHELP As Long = &H10
|
| |
|
| |
|
|
|
| никак не вклячить
решайте не через API а через FSO | |
|
| |
|
|
|
|
Но среди них нет ни одной, отвечающей за вывод в виде списка
|
http://www.cyberguru.ru/programming/win32/std-dialog-ref-page25.html | |
|
| |
|
|
|
| Уряяя, заработало!!
to Explorer
Спасибо огромное!!! Вы меня натолкнули на нужную мыслю))))
Итак, задача ВЫПОЛНЕНА (не мной, мной тока редактирована))). Ловите :)
КОД МОДУЛЯ!
Option Explicit
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
pvReserved As Long
dwReserved As Long
FlagsEx As Long
End Type
Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public Const FCIDM_SHVIEW_LARGEICON As Long = &H7029& ' 28713
Public Const FCIDM_SHVIEW_SMALLICON As Long = &H702A& ' 28714
Public Const FCIDM_SHVIEW_LIST As Long = &H702B& ' 28715
Public Const FCIDM_SHVIEW_REPORT As Long = &H702C& ' 28716
Public Const FCIDM_SHVIEW_THUMBNAIL As Long = &H702D& ' 28717
Public Const FCIDM_SHVIEW_TILE As Long = &H702E& ' 28718
Public Const WM_COMMAND As Long = &H111&
Public Enum OPENFILENAME_FLAGS
OFN_ALLOWMULTISELECT = &H200
OFN_CREATEPROMPT = &H2000
OFN_ENABLEHOOK = &H20
OFN_ENABLETEMPLATE = &H40
OFN_ENABLETEMPLATEHANDLE = &H80
OFN_EXTENSIONDIFFERENT = &H400&
OFN_FILEMUSTEXIST = &H1000
OFN_HIDEREADONLY = &H4&
OFN_NOCHANGEDIR = &H8&
OFN_NOLONGNAMES = &H40000
OFN_NONETWORKBUTTON = &H20000
OFN_NOREADONLYRETURN = &H8000
OFN_NOTESTFILECREATE = &H10000
OFN_NOVALIDATE = &H100
OFN_OVERWRITEPROMPT = &H2&
OFN_PATHMUSTEXIST = &H800
OFN_READONLY = &H1
OFN_SHAREAWARE = &H4000
OFN_SHAREFALLTHROUGH = 2
OFN_SHAREWARN = 0
OFN_SHARENOWARN = 1
OFN_SHOWHELP = &H10
OFS_MAXPATHNAME = 128
OFN_EXPLORER = &H80000
OFN_NODEREFERENCELINKS = &H100000
OFN_LONGNAMES = &H200000
OFN_ENABLEINCLUDENOTIFY = &H400000
OFN_ENABLESIZING = &H800000
OFN_DONTADDTORECENT = &H2000000
OFN_FORCESHOWHIDDEN = &H10000000
OFN_EX_NOPLACESBAR = &H1
End Enum
Public Type NMHDR
hwndFrom As Long
idfrom As Long
code As Long
End Type
Public Const WM_NOTIFY As Long = &H4E&
Public Const CDN_FIRST As Long = (0& - 601&)
Public Const CDN_LAST As Long = (0& - 699&)
Public Const CDN_INITDONE As Long = (CDN_FIRST - &H0&)
Public Const CDN_SELCHANGE As Long = (CDN_FIRST - &H1&)
Public Const CDN_FOLDERCHANGE As Long = (CDN_FIRST - &H2&)
Public Const CDN_SHAREVIOLATION As Long = (CDN_FIRST - &H3&)
Public Const CDN_HELP As Long = (CDN_FIRST - &H4&)
Public Const CDN_FILEOK As Long = (CDN_FIRST - &H5&)
Public Const CDN_TYPECHANGE As Long = (CDN_FIRST - &H6&)
Public Const CDN_INCLUDEITEM As Long = (CDN_FIRST - &H7&)
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWndParent&, ByVal hWndChildAfter&, ByVal lpClassName$, ByVal lpWindowName$) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpDest As Any, lpSource As Any, ByVal cBytes As Long)
Public Declare Function GetParent Lib "user32" (ByVal hWnd&) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd&, ByVal wMsg&, wParam As Any, lParam As Any) As Long
Public Function GetFileReturnProcAddress(ByVal lpProc&) As Long
GetFileReturnProcAddress = lpProc
End Function
Public Function GetFileDialogHookProc(ByVal hDlg&, ByVal nMsg&, ByVal wParam&, ByVal lParam&) As Long
Dim hLV&, lpNMHDR As NMHDR
Select Case nMsg
Case WM_NOTIFY
CopyMemory lpNMHDR, ByVal lParam, Len(lpNMHDR)
Select Case lpNMHDR.code
Case CDN_FOLDERCHANGE
hLV = FindWindowEx(GetParent(hDlg), 0, "SHELLDLL_DefView", vbNullString)
If hLV Then
Call SendMessage(hLV, WM_COMMAND, ByVal FCIDM_SHVIEW_REPORT, ByVal 0&)
End If
End Select
End Select
End Function |
Вызывающий код функции
Private Sub Command1_Click()
Dim oFN As OPENFILENAME
With oFN
.lStructSize = Len(oFN)
.hwndOwner = Form1.hWnd
.hInstance = App.hInstance
.lpstrFilter = "Text Files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "All files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
.lpstrFile = String$(512, 0)
.nMaxFile = 255
.lpstrFileTitle = String$(512, 0)
.nMaxFileTitle = 255
.lpstrInitialDir = CurDir
.lpstrTitle = "Our File Open Title"
.flags = 0
'NEW
.flags = OFN_EXTENSIONDIFFERENT Or OFN_NOCHANGEDIR Or OFN_OVERWRITEPROMPT Or OFN_HIDEREADONLY Or OFN_EXPLORER Or OFN_ENABLESIZING Or OFN_FORCESHOWHIDDEN
.flags = .flags Or OFN_ENABLEHOOK
.lpfnHook = GetFileReturnProcAddress(AddressOf GetFileDialogHookProc)
End With
Dim a
a = GetOpenFileName(oFN)
If (a) Then
MsgBox "File to Open: " + Trim$(oFN.lpstrFile)
Else
MsgBox "Cancel was pressed"
End If
End Sub |
Уряяя | |
|
| |
|
|
|
| помнится в 97-м мне нужно было чтобы отображались миниатюры (thumbnails) а не список...
о была задача...
но не помню уже как выкручивался :) | |
|
| |
|