Hi Colin

I think the problem is in the sBuffer variable. When you call the functiuon
it is an emty string try to put somthing into the this string before you
call the function. For this you can use the mapbasic Sting$() function.

Therefor just add this to yor code, before you call the
SHGetPathFromIDList() function

sBuffer = String$(260, " ")

Med venlig hilsen
Peter Laulund

*************************************************************
Kort & Matrikelstyrelsen  ·  www.kms.dk
National Survey and Cadastre - Denmark
Rentemestervej 8  ·  DK 2400 København NV
E-mail:  [EMAIL PROTECTED]  ·  Home: [EMAIL PROTECTED]
Phone: +45 3587 5050  ·  Direct: +45 3587 5173

*************************************************************







Colin Henderson <[EMAIL PROTECTED]> - 04-05-2001 11:43:09
Besvar venligst til Colin Henderson <[EMAIL PROTECTED]>
                                                                           
                                                                           
                                                                           

                                                                 
                                                                 
                                                                 
 Til:        "MapInfo-L (E-mail)"                                
             <[EMAIL PROTECTED]>                 
                                                                 
 cc:         (bcc: Peter Laulund/MI/KMS)                         
                                                                 
                                                                 
                                                                 
 Vedrørende: MI-L: Using API call SHBrowseForFolder              
                                                                 








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.


Med venlig hilsen
Peter Laulund

*************************************************************
Kort & Matrikelstyrelsen  ·  www.kms.dk
National Survey and Cadastre - Denmark
Rentemestervej 8  ·  DK 2400 København NV
E-mail:  [EMAIL PROTECTED]  ·  Home: [EMAIL PROTECTED]
Phone: +45 3587 5050  ·  Direct: +45 3587 5173

*************************************************************





_______________________________________________________________________
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