Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Common Dialog issues...

Status
Not open for further replies.

Neil Toulouse

Programmer
Mar 18, 2002
882
0
0
GB
Hi All!

I am trying to use the 'common dialog' foundation class in VFP8, but I am hitting a few issues with it!

Basically I am trying to restrict (as much as possible) the users movement around the system and so thought such properties as lNoNetworkButton and lNoChangeDir would be useful, BUT setting them to .T. makes no difference - the network button is still shown, and I can still change directories!

lNoPlacesBar on the other hand works, as in setting it to .T. removes it from the dialog.

Is there something obvious I am missing to get the other two properties to work?

TIA
Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
So something is turning it on. Just give a try by putting the code in its INIT event..

This.lNoNetworkButton = .t.
This.lNoChangeDir = .t.

Or try putting it with proper reference in the init of the form.

:)

____________________________________________
ramani - (Subramanian.G) :)
 
Hi Ramani!

I have tried setting these properties on the control itself (in a variety of places like INIT and SHOWFORM) and programmatically from the form, but nothing seems to make any difference!

But it could be my understanding of the dialog! The lNoNetworkButton I can get around by losing the places bar altogether, but I would really like to stop the user changing directory, or at least moving up in the hierarchy, so getting lNoChangeDir working would be 'spiffing' to say the least!

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Neil,

Have you thought about creating your own dialogue?

If I've got this right, you want to let the user choose a file, but not choose a directory. As you know, you can easily get a list of the files in a given directory. You can then display them in some suitable way (including a listview, which is basically what the user sees in the standard dialogue), and let the user make a choice.

With care, you could even make it look like the standard File Open dialogue (sans the directory icons, Look In list, and Back and Up buttons).

Just a thought.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike!

Hope all's well!

I started looking at the Common Dialog as I wanted an ability to seed the GETFILE() function with a given folder, then I came across the other settings and got excited about what it might be able to do!

If I've got this right, you want to let the user choose a file, but not choose a directory

...in some instances just a file and in some instances I would like them to select a folder. However I know I can seed GETDIR() so I can use that for folders.

Having had a quick chat with our teccie, he rekons that as long as I can give and file navigation a starting point he should be able to lock down the rest anyway so shouldn't be an issue. But it would have been nice to have been able to do it from the common dialog.

Have you thought about creating your own dialogue?

...looks like I may have to go that route! We have sooo much on at the mo I was trying to take the easy way out ;-)

Thanks Mike
Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
After seeing what power GETDIR() has with its flags, I have decided to roll my own using this instead!

All has gone well so far, but the help indicates there are more flags than is listed there ("see SHBrowseForFolder in MSDN."). Having checked MSDN, I have found a list of flags but no corresponding values are shown.

Can anyone point me to the list and its values?

Ta
Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Neil,

The codes listed for SHBrowseForFolder appear to be the same as those for GetDir():

Code:
RestrictToFilesystem = 0x0001
RestrictToDomain =     0x0002
RestrictToSubfolders = 0x0008
ShowTextBox =          0x0010
ValidateSelection =    0x0020
NewDialogStyle =       0x0040
BrowseForComputer =    0x1000
BrowseForPrinter =     0x2000
BrowseForEverything =  0x4000

I found them at Does it help at all?

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike!

Yes that is useful and adds another 2 flags to my list many thanks :)

..but there are more! I hate it when you try and make something as complete as is humanly possible and get hung up on it!

The list of flags I found comes from but give no values. I have listed them here and added the values we already know:

BIF_BROWSEFORCOMPUTER (4096)
Only return computers. If the user selects anything other than a computer, the OK button is grayed.

BIF_BROWSEFORPRINTER (8192)
Only allow the selection of printers. If the user selects anything other than a printer, the OK button is grayed.
In Microsoft Windows XP, the best practice is to use an XP-style dialog, setting the root of the dialog to the Printers and Faxes folder (CSIDL_PRINTERS).

BIF_BROWSEINCLUDEFILES (16384)
Version 4.71. The browse dialog box will display files as well as folders.

BIF_BROWSEINCLUDEURLS (???)
Version 5.0. The browse dialog box can display URLs. The BIF_USENEWUI and BIF_BROWSEINCLUDEFILES flags must also be set. If these three flags are not set, the browser dialog box will reject URLs. Even when these flags are set, the browse dialog box will only display URLs if the folder that contains the selected item supports them. When the folder's IShellFolder::GetAttributesOf method is called to request the selected item's attributes, the folder must set the SFGAO_FOLDER attribute flag. Otherwise, the browse dialog box will not display the URL.

BIF_DONTGOBELOWDOMAIN (2)
Do not include network folders below the domain level in the dialog box's tree view control.

BIF_EDITBOX (16)
Version 4.71. Include an edit control in the browse dialog box that allows the user to type the name of an item.

BIF_NEWDIALOGSTYLE (64)
Version 5.0. Use the new user interface. Setting this flag provides the user with a larger dialog box that can be resized. The dialog box has several new capabilities including: drag-and-drop capability within the dialog box, reordering, shortcut menus, new folders, delete, and other shortcut menu commands. To use this flag, you must call OleInitialize or CoInitialize before calling SHBrowseForFolder.

BIF_NONEWFOLDERBUTTON (???)
Version 6.0. Do not include the New Folder button in the browse dialog box.

BIF_NOTRANSLATETARGETS (???)
Version 6.0. When the selected item is a shortcut, return the PIDL of the shortcut itself rather than its target.

BIF_RETURNFSANCESTORS (8)
Only return file system ancestors. An ancestor is a subfolder that is beneath the root folder in the namespace hierarchy. If the user selects an ancestor of the root folder that is not part of the file system, the OK button is grayed.

BIF_RETURNONLYFSDIRS (1)
Only return file system directories. If the user selects folders that are not part of the file system, the OK button is grayed.

BIF_SHAREABLE (???)
Version 5.0. The browse dialog box can display shareable resources on remote systems. It is intended for applications that want to expose remote shares on a local system. The BIF_NEWDIALOGSTYLE flag must also be set.

BIF_STATUSTEXT (???)
Include a status area in the dialog box. The callback function can set the status text by sending messages to the dialog box. This flag is not supported when BIF_NEWDIALOGSTYLE is specified.

BIF_UAHINT (???)
Version 6.0. When combined with BIF_NEWDIALOGSTYLE, adds a usage hint to the dialog box in place of the edit box. BIF_EDITBOX overrides this flag.

BIF_USENEWUI (not used now?)
Version 5.0. Use the new user interface, including an edit box. This flag is equivalent to BIF_EDITBOX | BIF_NEWDIALOGSTYLE. To use BIF_USENEWUI, you must call OleInitialize or CoInitialize before calling SHBrowseForFolder.

BIF_VALIDATE (32)
Version 4.71. If the user types an invalid name into the edit box, the browse dialog box will call the application's BrowseCallbackProc with the BFFM_VALIDATEFAILED message. This flag is ignored if BIF_EDITBOX is not specified.

...so just need the values for those flags above marked with (???)!!

TIA
Neil



I like work. It fascinates me. I can sit and look at it for hours...
 
Found it! From the SHLOBJ.H file:

Code:
// Browsing for directory.
#define BIF_RETURNONLYFSDIRS   0x0001  // For finding a folder to start document searching
#define BIF_DONTGOBELOWDOMAIN  0x0002  // For starting the Find Computer
#define BIF_STATUSTEXT         0x0004   // Top of the dialog has 2 lines of text for BROWSEINFO.lpszTitle and one line if
                                        // this flag is set.  Passing the message BFFM_SETSTATUSTEXTA to the hwnd can set the
                                        // rest of the text.  This is not used with BIF_USENEWUI and BROWSEINFO.lpszTitle gets
                                        // all three lines of text.
#define BIF_RETURNFSANCESTORS  0x0008
#define BIF_EDITBOX            0x0010   // Add an editbox to the dialog
#define BIF_VALIDATE           0x0020   // insist on valid result (or CANCEL)

#define BIF_NEWDIALOGSTYLE     0x0040   // Use the new dialog layout with the ability to resize
                                        // Caller needs to call OleInitialize() before using this API

#define BIF_USENEWUI           (BIF_NEWDIALOGSTYLE | BIF_EDITBOX)

#define BIF_BROWSEINCLUDEURLS  0x0080   // Allow URLs to be displayed or entered. (Requires BIF_USENEWUI)
#define BIF_UAHINT             0x0100   // Add a UA hint to the dialog, in place of the edit box. May not be combined with BIF_EDITBOX
#define BIF_NONEWFOLDERBUTTON  0x0200   // Do not add the "New Folder" button to the dialog.  Only applicable with BIF_NEWDIALOGSTYLE.
#define BIF_NOTRANSLATETARGETS 0x0400   // don't traverse target as shortcut

#define BIF_BROWSEFORCOMPUTER  0x1000  // Browsing for Computers.
#define BIF_BROWSEFORPRINTER   0x2000  // Browsing for Printers
#define BIF_BROWSEINCLUDEFILES 0x4000  // Browsing for Everything
#define BIF_SHAREABLE          0x8000  // sharable resources displayed (remote shares, requires BIF_USENEWUI)

I like work. It fascinates me. I can sit and look at it for hours...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top