hi,
i want to make a button which functionality will be as typical browsing button. plzz guide me regarding that.
regards,
fims
Printable View
hi,
i want to make a button which functionality will be as typical browsing button. plzz guide me regarding that.
regards,
fims
Try this
VB Code:
Private Type BrowseInfo hWndOwner As Long pIDLRoot As Long pszDisplayName As Long lpszTitle As Long ulFlags As Long lpfnCallback As Long lParam As Long iImage As Long End Type Const BIF_RETURNONLYFSDIRS = 1 Const MAX_PATH = 260 Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long) Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long Private Sub Form_Load() 'KPD-Team 1998 'URL: [url]http://www.allapi.net/[/url] Dim iNull As Integer, lpIDList As Long, lResult As Long Dim sPath As String, udtBI As BrowseInfo With udtBI 'Set the owner window .hWndOwner = Me.hWnd 'lstrcat appends the two strings and returns the memory address .lpszTitle = lstrcat("C:\", "") 'Return only if the user selected a directory .ulFlags = BIF_RETURNONLYFSDIRS End With 'Show the 'Browse for folder' dialog lpIDList = SHBrowseForFolder(udtBI) If lpIDList Then sPath = String$(MAX_PATH, 0) 'Get the path from the IDList SHGetPathFromIDList lpIDList, sPath 'free the block of memory CoTaskMemFree lpIDList iNull = InStr(sPath, vbNullChar) If iNull Then sPath = Left$(sPath, iNull - 1) End If End If MsgBox sPath End Sub
This will open the Browse Dialog Box when the form is loaded.And If you select Any file it will display the filename in the msgbox otherwise it will display a blank msgbox.
can u please tell me wht its mean?
VB Code:
With udtBI
It is a Browers Type Declartion
whts this property of form do?
VB Code:
Me.hWnd
It will get the Handle(Long Integer) of the Form that you are Using.
Can u plz guide me abt these lines?
VB Code:
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long) Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
This are *declarations* (refferers) to some functions (APIs) that are already declared in some libraries somewhere in the system (in that case ole32.dll, kernel32.dll and shell32.dll). To learn more about APIs i suggest you to take a look at AllAPI.net.
Can u tell me please that is 'lpIDList' variable tells whether the list can be displayed or not? n how it works?
thankx for the guidance
this code does not select file... access only hierarchy of folders plzzz tell me how can i access file in that specified folder?????????????