I volunteer the following to try to simplify as much as possible an example call to the SHBrowseForFolder shell routine :

'*************** Win 98 Shell Declarations ***************
Type BrowseInfo
  hWndOwner As Integer
  pIDLRoot As Integer
  pszDisplayName As Integer
  lpszTitle As Integer
  ulFlags As Integer
  lpfnCallback As Integer
  lParam As Integer
  iImage As Integer
End Type

Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Integer)

Declare Function SHBrowseForFolder Lib "shell32"
 (lpbi As BrowseInfo) As Integer

Declare Function SHGetPathFromIDList Lib "shell32"
 (ByVal pidList As Integer, lpBuffer As String) As Integer

'*************** Function GetFolderName ***************
Declare Function GetFolderName(ByVal hMIWinHandle as integer) as string
Function GetFolderName(ByVal hMIWinHandle as integer) as string

  Define BIF_RETURNONLYFSDIRS 1
  Define MAX_PATH 260

 Dim lpIDList, lResult As Integer
 Dim udtBI As BrowseInfo
 Dim sPath as String

 GetFolderName=""
        'Set the owner window
 udtBI.hWndOwner = hMIWinHandle

        'Return only if the user selected a directory
 udtBI.ulFlags = BIF_RETURNONLYFSDIRS

    'Show the 'Browse for folder' dialog
 lpIDList = SHBrowseForFolder(udtBI)

 If lpIDList > 0 Then
  sPath = Space$(MAX_PATH)
      'Get the path from the IDList
  lResult = SHGetPathFromIDList(lpIDList, sPath)
  If lResult=1 then GetFolderName=sPath End if
 End If

 Call CoTaskMemFree( lpIDList)

 End Function

 '*************** Test program ***************
 Define SYS_INFO_MAPINFOWND 9
 Dim FolderName as string

 FolderName=GetFolderName(SystemInfo(SYS_INFO_MAPINFOWND))

 If FolderName = "" then Note "No Folder Chosen"
  Else Note "Chosen Folder: " + FolderName End if


  Robert Edwards
    The MapTools Company
  http://home.earthlink.net/~maptools/
_______________________________________________________________________ List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, send e-mail to [EMAIL PROTECTED] and put "unsubscribe MapInfo-L" in the message body.

Reply via email to