Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SHBrowseForFolder: BIF_USENEWUI breaks BIF_RETURNONLYFSDIRS

161 views
Skip to first unread message

David Ching

unread,
Sep 18, 2002, 2:03:38 PM9/18/02
to
Hello,

I have some older code that calls SHBrowseForFolder() with the
BIF_RETURNONLYFSDIRS flag. On WinXP, the OK button is properly disabled
when, for example, the "My Network Places" item is selected (because "My
Network Places" is not a file system directory).

However, when I add the BIF_USENEWUI flag, the OK button is still enabled
when "My Network Places" is selected. It seems to ignore the
BIF_RETURNONLYFSDIRS flag. There is no knowledgebase article on this - has
anyone experienced the same problem, and fixed it?

Again, this is on WinXP Professional, no service pack.

Thanks,
David

David Lowndes

unread,
Sep 19, 2002, 7:44:05 AM9/19/02
to
>I have some older code that calls SHBrowseForFolder() with the
>BIF_RETURNONLYFSDIRS flag. On WinXP, the OK button is properly disabled
>when, for example, the "My Network Places" item is selected (because "My
>Network Places" is not a file system directory).
>
>However, when I add the BIF_USENEWUI flag, the OK button is still enabled
>when "My Network Places" is selected. It seems to ignore the
>BIF_RETURNONLYFSDIRS flag.

David,

I confirm your results, and note that the latest MSDN documentation
says:

"There are two styles of dialog box available. The older style is
displayed by default, and is not resizable. To specify a new-style
dialog box, set the BIF_USENEWUI flag in the ulFlags member of the
BROWSEINFO structure. It has a number of additional features,
including: drag and drop capability within the dialog box, reordering,
shortcut menus, new folders, delete, and other shortcut menu commands.
Initially, it is larger than the old dialog box, but can be resized by
the user.

If you implement a callback function, you will receive a handle to the
dialog box. One use of this window handle is to modify the layout or
contents of the dialog box. Because it is not resizable, modifying the
old-style dialog box is relatively straightforward. Modifying the
new-style dialog box is much more difficult, and not recommended. Not
only does it have a different size and layout than the old style, but
its dimensions and the positions of its controls change every time it
is resized by the user.

If the BIF_RETURNONLYFSDIRS flag is set in the ulFlags member of the
BROWSEINFO structure, the OK button will remain enabled for "\\server"
items, as well as "\\server\share" and directory items. However, if
the user selects a "\\server" item, passing the PIDL returned by the
dialog box to SHGetPathFromIDList will fail.
"

... which to my mind, vaguely implies that you're meant to do the
checking yourself.

Dave Lowndes
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq

David Ching

unread,
Sep 19, 2002, 2:55:08 PM9/19/02
to
David Lowndes wrote:

> David,
>
> I confirm your results, and note that the latest MSDN documentation
> says:
>

...

> If the BIF_RETURNONLYFSDIRS flag is set in the ulFlags member of the
> BROWSEINFO structure, the OK button will remain enabled for "\\server"
> items, as well as "\\server\share" and directory items. However, if
> the user selects a "\\server" item, passing the PIDL returned by the
> dialog box to SHGetPathFromIDList will fail.
> "
>
> ... which to my mind, vaguely implies that you're meant to do the
> checking yourself.
>

David, thanks for taking the time to confirm my results and referring to the
doc. I had seen that, but hadn't made the connection to "My Network Places"
being analogous to a "\\server" syntax. I emulated the desired behavior
with the new UI by adding a BrowseCallbackProc() and handling the
BFFM_SELCHANGED message to first call SHGetPathFromIDList, and if it returns
FALSE, to disable the OK button, by sending the dialog a BFFM_ENABLEOK
message. It seems to work fine.

I don't understand why MS decided to enable the OK button when a \\server
(or My Network Places) is selected, when these are clearly not part of the
file system proper.

Best regards,
David


David Lowndes

unread,
Sep 19, 2002, 4:45:18 PM9/19/02
to
>I don't understand why MS decided to enable the OK button when a \\server
>(or My Network Places) is selected, when these are clearly not part of the
>file system proper.

... me neither, I'll try to find out.

Dave

0 new messages