There are a few ways to use the “Browse for Folder” dialog in SalesLogix to allow users to select a directory path. First of all, there is the LookupEdit control. The LookupEdit control has a property called LookupMode. Setting this property to lmDirectory will cause the Browse for Folder dialog to appear when the user clicks the Lookup button. One problem with this approach, however. The lmDirectory LookupMode was broken for many previous verions of SalesLogix. I’m not sure of the exact version this was fixed in, but I can tell you that it was still broken in version 6.2 IIRC, it is working in 7.2 – you’ll have to check if you’re on a version in between 😉
If this isn’t working for you, or you’d like a bit more control over the dialog, you can easily invoke it in VBScript using the Shell object. The Shell object has a built in BrowseForFolder method that you can use to invoke the dialog, and set values on it for the caption, starting directory, etc.
The code is easy enough to use. Here’s a sample:
Sub btnBrowseClick(Sender) Dim shell Dim folder Set shell = CreateObject("Shell.Application") ' Invoke the Browse for Folder dialog and set the caption and ' the initial folder to the root of the C: drive Set folder = shell.BrowseForFolder(Form.HWND, "Select a folder...", 0, "C:") If Not folder Is Nothing Then txtDirectory.Text = folder.Self.Path End If Set shell = Nothing End Sub
You’ll see this:
The main things to point out from this code, the BrowseForFolder method returns a Folder object. The first parameter is the HWND for the parent of the dialog. We could omit this, and leave it as 0, but then the dialog wouldn’t be modal to SalesLogix. Setting this to the HWND of the Form in SalesLogix makes the dialog modal. The second parameter is the caption for the dialog. The third and fourth parameters can make things quite interesting. The third param can be a combination of values from the ulFlags property of the BROWSEINFO struct. The forth param sets the initial directory. This can be an actual directory OR one of the ShellSpecialFolderConstants values.