Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Help with seldirdlg() function

Help with seldirdlg() function

Help with seldirdlg() function

Help with seldirdlg() function

I had been using this function by M Gagnon for years before I stopped programming.
I have just put together a new small utility and I find this functions dlg starts at My PC on my Win 10 machine.
I have to access the network so how can I start higher up?


LPARAMETERS cDialogTitle, cStartingFolder, nBrowseFlags
*  Select a directory using the default browser dialog
*  Give a default title if none specified
IF TYPE('cDialogTitle') # 'C'
    cDialogTitle = 'Please select a folder:'
*  Default the start folder to an empty string;  if
*  you specify a starting folder, the browse is
*  anchored there, although you can override it with
*  the dialog's EditBox
IF TYPE('cStartingFolder') # 'C'
    cStartingFolder = ''
IF TYPE('nBrowseFlags') # 'N'
    * uses BROWSEINFO structure ulFlags values
    * by default, set BIF_RETURNONLYFSDIRS (1) and BIF_EDITBOX (16) and BIF_VALIDATE
    * to limit to returning directories, provide an edit box to let user enter a path,
    * and validate manually-entered paths
    * ulFlags values:
    *    BIF_STATUSTEXT            4
    *    BIF_EDITBOX                0x10
    *    BIF_VALIDATE            0x20
    *    BIF_BROWSEFORCOMPUTER    0x1000
    *    BIF_BROWSEFORPRINTER    0x2000
    nBrowseFlags = 32 + 16 + 1
LOCAL oBrowseObject, cPathToReturn, oShellObj
oShellObj = CREATEOBJ('Shell.Application')
cPathToReturn = ''
*    Get a Folder object
oBrowseObject = oShellObj.BrowseForFolder(0, ;
        cDialogTitle, ;
        nBrowseFlags, ;
*    Before I used the Items collection of the Folder object
*    to get a path;  it doesn't work if the directory is empty.
*    Instead, spin through the Items collection of the Parent
*    Folder and locate the item whose name matches the
*    Title property of the Folder object;  return that path
IF TYPE('oBrowseObject') = 'O' AND ! ISNULL(oBrowseObject)
    FOR EACH item IN oBrowseObject.ParentFolder.Items
        IF item.name == oBrowseObject.title
            cPathToReturn = Item.Path
RETURN cPathToReturn 

RE: Help with seldirdlg() function

I think is just a question of specifying a starting folder sufficiently high up the file system.

Instead of passing cStartingFolder as the fouth parameter to BrowseForFolder(), try passing the number 18. (I know this is numeric and the required folder name is a string, but it should work.)

18 is the value the ssfNETWORK constant, which represents the root of the network namespace hierarchy. If 18 doesn't work, try some of the other constants listed here: https://msdn.microsoft.com/en-us/library/windows/d...


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Help with seldirdlg() function

I'd just use the BIF_BROWSEFOREVERYTHING flag additional to the already used flags in the line nBrowseFlags = 32 + 16 + 1

This actually is nBrowseFlags = BIF_VALIDATE + BIF_EDITBOX + BIF_RETURNONLYFSDIRS + BIF_BROWSEFOREVERYTHING and you most likely need to skip BIF_RETURNONLYFSDIRS to also return a network location.

Then you need to find out whether that actually will help you get some path you can work with in UNC notation, for example. If not, and perhaps even without trying, you're better off by mapping network shares to drive letters.

Bye, Olaf.

RE: Help with seldirdlg() function


Unfortunately I still get the dialogue stuck on My PC when I pass numeral 18.

RE: Help with seldirdlg() function

I've messaged to use mapped drives on my form and of course it works like a charm.
I had tried BIF_BROWSEFOREVERYTHING by adding 4096 to the the line nBrowseFlags = 32 + 16 + 1 but it didn't change anything as far as I could tell.



RE: Help with seldirdlg() function

0x4000 is 16384, why don't you simply make use of the constants and don't work with the numbers? They are defined for a good reason to make clear what options are combined in the one flags value, plus you can't fail to make a wrong conversion to decimal. VFP understands 0x4000, simply do "? 0x4000" and see for yourself.

Bye, Olaf.

RE: Help with seldirdlg() function


Sorry my solution didn't work for you. I just tried your code myself, and passing 18 did indeed cause the dialogue to open at the network level. But there might well be operating system differences or other factors at work.

Anyway, it's good that you now have a solution.


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close