SHBrowseForFolder does not work with BIF_NEWDIALOGSTYLE

I've had XP for awhile. Programs I've written have used SHBrowseForFolder for several years with no problems. For the last two or three months, SHBrowseForFolder will not work in any program if used with BIF_NEWDIALOGSTYLE. This is true for programs I've written as well as programs I download or install. What happens is, the dialog will appear showing appropriate buttons, but the treeview is missing. Because the treeview is missing, no folders are shown. I need to get this working again because software I download often doesn't work, because the same blank "browse for folder" dialog appears.
Who is Participating?
Seems it's something wrong with explorer namespace. Did you see
Try this simple Shell.Application solution to see if it shows the Treeview.
Here it shows the New Dialog with Edit Box:

'In Form:

Option Explicit

Private Sub Command1_Click()
   Dim sSelect As String
   sSelect = ShellBrowse("Dialog Title " & ChrW$(&H6B22) & ChrW$(&H8FCE), BIF_USENEWUI)
   MsgBox sSelect
End Sub

'In Module

Option Explicit

' Flags for the options parameter
Public Enum bif
   BIF_RETURNONLYFSDIRS = &H1        ' For finding a folder to start document searching
   BIF_DONTGOBELOWDOMAIN = &H2       ' For starting the Find Computer
   BIF_STATUSTEXT = &H4              ' 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.
   BIF_EDITBOX = &H10                ' Add an editbox to the dialog
   BIF_VALIDATE = &H20               ' insist on valid result (or CANCEL)

   BIF_NEWDIALOGSTYLE = &H40         ' Use the new dialog layout with the ability to resize
   ' Caller needs to call OleInitialize() before using this API


   BIF_BROWSEINCLUDEURLS = &H80      ' Allow URLs to be displayed or entered. (Requires BIF_USENEWUI)
   BIF_UAHINT = &H100                ' Add a UA hint to the dialog, in place of the edit box. May not be combined with BIF_EDITBOX
   BIF_NONEWFOLDERBUTTON = &H200     ' Do not add the "New Folder" button to the dialog.  Only applicable with BIF_NEWDIALOGSTYLE.
   BIF_NOTRANSLATETARGETS = &H400    ' don't traverse target as shortcut
   BIF_BROWSEFORCOMPUTER = &H1000    ' Browsing for Computers.
   BIF_BROWSEFORPRINTER = &H2000     ' Browsing for Printers
   BIF_BROWSEINCLUDEFILES = &H4000   ' Browsing for Everything
   BIF_SHAREABLE = &H8000            ' sharable resources displayed (remote shares, requires BIF_USENEWUI)
End Enum
Public Function ShellBrowse(ByVal sTitle As String, _
   Optional ByVal Flags As Long = &H1) As String
   Dim wShell
   Dim myFolder
   On Error GoTo ErrHandler
   Set wShell = CreateObject("Shell.Application")
   Set myFolder = wShell.BrowseForFolder(&H0, sTitle, Flags, "")
   ShellBrowse = myFolder.Items.Item.Path
   Debug.Print "ShellBrowse"
   Set myFolder = Nothing
   Set wShell = Nothing
   Exit Function
   Debug.Print "Error " & Err.Number, Err.Description

End Function
dmcdivittAuthor Commented:
No, it does not work. The treeview is blank.
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

dmcdivittAuthor Commented:
I will make sure 500 points get assigned to whoever solves the problem.
Does your computer use NET Framework ?
dmcdivittAuthor Commented:
I don't use any .Net stuff, but framework 1.1 and 2.0 are installed.
Not sure, but try to remove BIF_STATUSTEXT flag as well as appropriate   Case BFFM_SELCHANGED from callback function
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."
What are your Shell32.Dll and ComCtl32.Dll version numbers?

On my XP-SP2 machine:
Shell32.Dll = 6.0.2900.2951
ComCtl32.Dll = File Version 5.82.2900.2982, Product Version 6.00.2900.2982

Have you tried updating these files? Perhaps it got corrupted. Here are some update Links: 

Here is a free tool that will update ComCtl32.Dll. Grab a copy of ComCtl32.Dll from a known working machine that has the latest XP-SP2 updates. 
dmcdivittAuthor Commented:
Nope. Didn't work. I have another XP partition on the same machine I use to backup the main partition, as well as test stuff. I keep it current. Shell32.Dll and ComCtl32.Dll on both systems had the same version numbers. I deleted items in DLLCache and replaced the files from the backup system. No difference.

I really like the CopyLock program. Very cool.

Maybe I can send a request to Microsoft, detailing the problem as best I know it. I don't know where to send such a request. Since it is a problem in Windows they might have interest. How the problem was induced doesn't matter, so much as the possibility the problem may occur elsewhere. I don't know how it was induced, anyway.

I still think it might be a namespace error. It is possible the treeview is initialized differently, or nodes are built differently, if BIF_NEWDIALOGSTYLE is set or not set. SHBrowseForFolder works OK when not used with BIF_NEWDIALOGSTYLE. This is why I doubted the problem would have anything to do with ComCtl32.Dll, but I tried that anyway. The problem could have been in Shell32.Dll, but that didn't fix it.
Did you try BIF_NEWDIALOGSTYLE without callback (.lpfn=0)?
dmcdivittAuthor Commented:
Yes. That's the first thing I tried. No difference. The first avenue I pursued was problems with VB or my code. These are not the problem.

No program I try to run will do a successful SHBrowseForFolder using BIF_NEWDIALOGSTYLE. All programs that try to do this have a missing treeview in the dialog.
dmcdivittAuthor Commented:
Points were originally 500 for this question. When I posted several of the question the points were reduced by the moderator. I am bumping back up to 500 and canceling out the others.
dmcdivittAuthor Commented:
Please advise if the answer did not provide 500 points.
Thanks for points, glad I could help
dmcdivittAuthor Commented:
It was worth 500 points because I've been trying to resolve this on and off for months. I've done endless searches on web pages and in newsgroups. I've posted questions in newsgroups.

The answer you gave is strange. Verbiage at the web site does not contain anything searchable that would resolve my problem, or that resolves functionality issues with SHBrowseForFolder. Reading the web site only vaguely describes my problem because I was not doing the edit function described in Windows Explorer. I think I'll email the owner and express that.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.