Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[blue]Const MAX_PATH = 260
Const BIF_RETURNONLYFSDIRS = &H1&
Const BIF_STATUSTEXT = &H4
Const WM_USER = &H400
Const BFFM_INITIALIZED = 1
Const BFFM_SELCHANGED = 2
Const BFFM_SETSTATUSTEXT = WM_USER + 100
Const BFFM_SETSELECTION = WM_USER + 102
Const SHGFI_DISPLAYNAME = &H200
Const SHGFI_PIDL = &H8
Const WM_SETTEXT = &HC
Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(Destination As Any, _
Source As Any, _
ByVal Length As Long)
Declare Function BrowseForFolder Lib "shell32" _
Alias "SHBrowseForFolder" _
(lpbi As BROWSEINFO) As Long
Declare Function GetPathFromIDList Lib "shell32" _
Alias "SHGetPathFromIDList" _
(ByVal pidl As Long, _
ByVal pszPath As String) As Long
Declare Function SHGetFileInfo Lib "shell32" _
Alias "SHGetFileInfoA" _
(ByVal pszPath As Any, _
ByVal dwFileAttributes As Long, _
psfi As SHFILEINFO, _
ByVal cbFileInfo As Long, _
ByVal uFlags As Long) As Long
Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Type BROWSEINFO
hwndOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As String
iImage As Long
End Type
Type SHFILEINFO
hIcon As Long
iIcon As Long
dwAttributes As Long
szDisplayName As String * MAX_PATH
szTypeName As String * 80
End Type
Function BrowseCallbackProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal lParam As Long, _
ByVal lpData As String) As Long
Dim Path As String * MAX_PATH
If uMsg = BFFM_SELCHANGED Then
GetPathFromIDList lParam, Path
If Asc(Path) = 0 Then
Dim sfi As SHFILEINFO
SHGetFileInfo lParam, 0, sfi, Len(sfi), SHGFI_DISPLAYNAME Or SHGFI_PIDL
Path = sfi.szDisplayName
End If
SendMessage hwnd, BFFM_SETSTATUSTEXT, 0&, ByVal Path
ElseIf uMsg = BFFM_INITIALIZED Then
SendMessage hwnd, BFFM_SETSELECTION, True, ByVal lpData
SendMessage hwnd, WM_SETTEXT, 0, ByVal "Browse for Folder"
End If
End Function
Public Function BrowseFolders(frm As Form, Optional StartFolder As String) As String
Dim bi As BROWSEINFO, pidl As Long, Path As String * MAX_PATH, SF As String
If StartFolder = "" Then StartFolder = "C:\"
CopyMemory bi.lpfn, AddressOf BrowseCallbackProc, 4
bi.ulFlags = BIF_RETURNONLYFSDIRS Or BIF_STATUSTEXT
bi.hwndOwner = Screen.ActiveForm.hwnd
bi.lParam = StrConv(Trim$(StartFolder), vbUnicode)
bi.lpszTitle = "Select a folder from the tree."
pidl = BrowseForFolder(bi)
If pidl Then
GetPathFromIDList pidl, Path
BrowseFolders = Left$(Path, InStr(Path, vbNullChar) - 1)
Else
BrowseFolders = StartFolder
End If
End Function[/blue]
[blue] Me![purple][b][i]TextboxName[/i][/b][/purple] = BrowseFolders(Me, "C:\Windows")[/blue]