Article View: comp.lang.basic.visual.database
Article #54Re: List Box Control
From: Peter Walsh
Date: Mon, 09 Mar 1998 00:00
Date: Mon, 09 Mar 1998 00:00
85 lines
3393 bytes
3393 bytes
Sam <jasam@urs2.net> wrote in article <35003e1b.0@larry.urs2.net>...
> Does anyone have a active x control list box that will see the
> networkneighborhood and Maybe Mycomputer. The list box with visual basic
> only sees the local drives and any drives that are mapped. please help if
> anyone has any suggestions.
>
Try the following code:
' Stuff for selecting a folder in API
Public Type SHITEMID 'mkid
cb As Long
abID() As Byte
End Type
Public Type ITEMIDLIST 'idl
mkid As SHITEMID
End Type
Public Type BROWSEINFO 'bi
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Public Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, ByVal pszPath As String) As Long
Public Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" _
(lpBrowseInfo As BROWSEINFO) As Long
Public Const BIF_RETURNONLYFSDIRS = &H1
Function SelectFolder(oFrm As Form, Optional sRootPath As Variant, Optional
sTitle As Variant) As String
Dim i As Integer
Dim bi As BROWSEINFO
Dim IDL As ITEMIDLIST, IID As SHITEMID
Dim pidl As Long
Dim r As Long
Dim pos As Integer
Dim sPath As String
'Fill the BROWSEINFO structure with the needed data.
bi.hOwner = oFrm.hWnd
'Pointer to the item identifier list specifying the
'location of the "root" folder to browse from.
'If NULL, the desktop folder is used.
If Not IsMissing(sRootPath) Then
IID.cb = Len(sRootPath) + 4
ReDim IID.abID(Len(sRootPath) - 1)
For i = 1 To Len(sRootPath)
IID.abID(i - 1) = Asc(Mid(sRootPath, i, 1))
Next
End If
bi.pidlRoot = 0&
'message to be displayed in the Browse dialog.
'Note: the code here does not check to determine if
'in fact the system folder was selected; it is provided
'only as an example of a message.
If Not IsMissing(sTitle) Then _
bi.lpszTitle = sTitle
'the type of folder to return.
bi.ulFlags = BIF_RETURNONLYFSDIRS
'show the browse folder dialog
pidl& = SHBrowseForFolder(bi)
'the dialog has closed, so parse & display the user's
'returned folder selection contained in pidl&.
sPath$ = Space$(512)
r = SHGetPathFromIDList(ByVal pidl&, ByVal sPath$)
If r Then
pos = InStr(sPath$, Chr$(0))
SelectFolder = Left(sPath$, pos - 1)
Else: SelectFolder = ""
End If
End Function
Technical Details
Message-ID:
<01bd4bb4$ce658c80$ec173ccb@devil1>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<35003e1b.0@larry.urs2.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 110e3b,b961f85c1d7a5b71 X-Google-Attributes: gid110e3b,public X-Google-Thread: 108062,b961f85c1d7a5b71 X-Google-Attributes: gid108062,public X-Google-Thread: 10b997,b961f85c1d7a5b71 X-Google-Attributes: gid10b997,public X-Google-Thread: 1143a7,b961f85c1d7a5b71 X-Google-Attributes: gid1143a7,public From: "Peter Walsh" <peterw@southcom.com.au> Subject: Re: List Box Control Date: 1998/03/09 Message-ID: <01bd4bb4$ce658c80$ec173ccb@devil1> X-Deja-AN: 332449922 References: <35003e1b.0@larry.urs2.net> Organization: Southern Internet Services Newsgroups: comp.lang.basic.visual.database,comp.lang.basic.visual.misc,cz.comp.lang.basic.visual,it.comp.lang.visual-basic