How to put the Desktop object in a DriveListBox

I have a custom dialog that includes Drive, Folder and File list boxes.  It would be nice to have the Desktop, My Documents and Network objects appear in the list as they do in the common dialog controls.

Is it possible to add objects to DriveListBox or is there another function that already has this ability?



Something like the browse folder dialog would also work but I'd need it to exist as an object in my form rather than in it's own dialog box.  And I don't think you can do things like that when calling a shell object.

This is being attempted in VB6.

Thanks
vbncsuAsked:
Who is Participating?
 
YensidModConnect With a Mentor Commented:
Question is PAQ'd and points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0
 
happelCommented:
'NOTE, code is not mine, copied from other vb-site
'I don't know the name of the author.


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


'Browsing type.
Public Enum BrowseType
  BrowseForFolders = &H1
  BrowseForComputers = &H1000
  BrowseForPrinters = &H2000
  BrowseForEverything = &H4000
End Enum

'Folder Type
Public Enum FolderType
  CSIDL_BITBUCKET = 10
  CSIDL_CONTROLS = 3
  CSIDL_DESKTOP = 0
  CSIDL_DRIVES = 17
  CSIDL_FONTS = 20
  CSIDL_NETHOOD = 18
  CSIDL_NETWORK = 19
  CSIDL_PERSONAL = 5
  CSIDL_PRINTERS = 4
  CSIDL_PROGRAMS = 2
  CSIDL_RECENT = 8
  CSIDL_SENDTO = 9
  CSIDL_STARTMENU = 11
End Enum

Private Const MAX_PATH = 260
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "kernel32.dll" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32.dll" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hWndOwner As Long, ByVal nFolder As Long, ListId As Long) As Long



Public Function BrowseFolders(hWndOwner As Long, sMessage As String, Browse As BrowseType, ByVal RootFolder As FolderType) As String
Dim Nullpos As Integer
Dim lpIDList As Long
Dim res As Long
Dim sPath As String
Dim BInfo As BrowseInfo
Dim RootID As Long

SHGetSpecialFolderLocation hWndOwner, RootFolder, RootID
BInfo.hWndOwner = hWndOwner
BInfo.lpszTitle = lstrcat(sMessage, "")
BInfo.ulFlags = Browse
If RootID <> 0 Then BInfo.pIDLRoot = RootID
lpIDList = SHBrowseForFolder(BInfo)
If lpIDList <> 0 Then
  sPath = String(MAX_PATH, 0)
  res = SHGetPathFromIDList(lpIDList, sPath)
  Call CoTaskMemFree(lpIDList)
  Nullpos = InStr(sPath, vbNullChar)
  If Nullpos <> 0 Then
    sPath = Left(sPath, Nullpos - 1)
  End If
End If
BrowseFolders = sPath
End Function


Private Sub cmdGetFolder_Click()
Dim sTmp As String
  'try different settings like CSIDL_DRIVES+CSIDL_PERSONAL+etc etc
  sTmp = BrowseFolders(Me.hWnd, "Select folder", BrowseForFolders, CSIDL_DRIVES+CSIDL_PERSONAL)
'
End Sub
0
 
vbncsuAuthor Commented:
This still uses shell commands to make a dialog for the browsing and returns the selected path.

Is there anyway to make the browse window appear in a dialog that I create?
0
 
GPrentice00Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->PAQ - with points refunded

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0
All Courses

From novice to tech pro — start learning today.