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 |