Listers,

I am trying to use the API to launch a browse for folders dialog, I want the
user to select an existing folder on their filesystem.  The output from the
dialog will then be placed in to an edittext control.  The browse dialog
launches fine, and returns the pointer to the selected directory, but when I
try to use the SHGetPathFromIDList call mapinfo crashes causing an error in
shell32.  Any ideas why? Below is the code involved:

Include "MapBasic.def"
Include "Icons.def"
Include "Menu.def"

Define BIF_RETURNONLYFSDIRS   1
Define BIF_DONTGOBELOWDOMAIN  2
Define MAX_PATH               260

Type BrowseInfo
        hWndOwner As Integer
        pIDLRoot As Integer
        pszDisplayName As Integer
        lpszTitle As String
        ulFlags As Integer
        lpfnCallBack As Integer
        lParam As Integer
        iImage As Integer
End Type

Declare Sub Main
Declare Sub BrowseFolders
Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As
Integer
Declare Function SHGetPathFromIDList Lib "shell32" Alias
"SHGetPathFromIDList" 
        (pidList As Integer, lpBuffer As String) As Integer

Sub Main
        Create Menu "Browse Folders" As
                "Browse" Calling BrowseFolders

        Alter Menu Bar Add "Browse Folders"
End Sub

Sub BrowseFolders
        Dim lpIDList, retVal As Integer
        Dim szTitle, sBuffer As String
        Dim tBrowseInfo As BrowseInfo

        szTitle = "Hello world. Click on a directory and its path will be
displayed in a message!"

        tBrowseInfo.hWndOwner = SystemInfo(SYS_INFO_MAPINFOWND)
        tBrowseInfo.lpszTitle = szTitle
        tBrowseInfo.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN

        lpIDList = SHBrowseForFolder(tBrowseInfo)
        
        If (lpIDList) Then
                sBuffer = Space$(MAX_PATH)
                retVal = SHGetPathFromIDList(lpIDList, sBuffer)
                sBuffer = Left$(sBuffer, InStr(1, sBuffer, " ") - 1)
                Note sBuffer
        End If
End Sub

TIA

--
Regards
Colin Henderson
Associate GIS Analyst
WFI Consulting
Tel: +44 (0)1483 400937
Fax: +44 (0)1483 400
Mobile: +44 (0)7887 638771
[EMAIL PROTECTED]



_______________________________________________________________________
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