Solved

SHBrowseForFolder does not work with BIF_NEWDIALOGSTYLE

Posted on 2006-11-26
19
1,163 Views
Last Modified: 2012-06-27
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.
0
Comment
Question by:dmcdivitt
  • 8
  • 6
  • 3
19 Comments
 
LVL 22

Expert Comment

by:danaseaman
ID: 18019019
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_RETURNFSANCESTORS = &H8
   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_USENEWUI = (BIF_NEWDIALOGSTYLE Or BIF_EDITBOX)

   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
ErrHandler:
   Debug.Print "Error " & Err.Number, Err.Description

End Function
0
 

Author Comment

by:dmcdivitt
ID: 18019688
No, it does not work. The treeview is blank.
0
 

Author Comment

by:dmcdivitt
ID: 18022476
I will make sure 500 points get assigned to whoever solves the problem.
0
 
LVL 27

Expert Comment

by:Ark
ID: 18023898
Does your computer use NET Framework ?
0
 

Author Comment

by:dmcdivitt
ID: 18024043
I don't use any .Net stuff, but framework 1.1 and 2.0 are installed.
0
 
LVL 27

Expert Comment

by:Ark
ID: 18024472
Not sure, but try to remove BIF_STATUSTEXT flag as well as appropriate   Case BFFM_SELCHANGED from callback function
0
 
LVL 27

Expert Comment

by:Ark
ID: 18024785
PS. From MSDN
"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."
0
 
LVL 22

Expert Comment

by:danaseaman
ID: 18026241
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:

http://www.microsoft.com/downloads/details.aspx?familyid=CA4EAE1F-E591-4D38-894F-FA42367796D4&displaylang=en
http://www.microsoft.com/downloads/details.aspx?familyid=235bca55-8d43-4eaf-8970-a55bc3165e3d&displaylang=en


0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 22

Expert Comment

by:danaseaman
ID: 18026546
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.

http://noeld.com/programs.asp?cat=misc#CopyLock
0
 

Author Comment

by:dmcdivitt
ID: 18030444
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.
0
 
LVL 27

Expert Comment

by:Ark
ID: 18032419
Did you try BIF_NEWDIALOGSTYLE without callback (.lpfn=0)?
0
 

Author Comment

by:dmcdivitt
ID: 18033585
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.
0
 
LVL 27

Accepted Solution

by:
Ark earned 500 total points
ID: 18033730
Seems it's something wrong with explorer namespace. Did you see http://windowsxp.mvps.org/copytoempty.htm
0
 

Author Comment

by:dmcdivitt
ID: 18033972
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.
0
 

Author Comment

by:dmcdivitt
ID: 18033982
Please advise if the answer did not provide 500 points.
0
 
LVL 27

Expert Comment

by:Ark
ID: 18034164
Thanks for points, glad I could help
0
 

Author Comment

by:dmcdivitt
ID: 18034513
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.

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now