Problem using SHBrowseForFolder

  • Thread starter Thread starter Art Metz
  • Start date Start date
A

Art Metz

I am using VS 2003, .net 1.1

I am trying to use the SHBrowseForFolder dialog, as wrapped up in a
component from CodeProject (I don't have the URL handy).

The dialog appears, but the treeview does not.

I get the same result using the old .net 1.0 method with
FolderNameEditor and FolderBrowser(). It used to work before I
upgraded to 1.1 .

Any suggestions?

TIA,

Art
 
Art Metz said:
I am using VS 2003, .net 1.1

I am trying to use the SHBrowseForFolder dialog, as wrapped up in a
component from CodeProject (I don't have the URL handy).

The dialog appears, but the treeview does not.

Make sure there is no 'MTAThread' attribute specified on your 'void Main'.
Instead use 'STAThread', which ist the default and doesn't need to be
specified, at least in VB.NET.
 
Art said:
I am using VS 2003, .net 1.1

I am trying to use the SHBrowseForFolder dialog, as wrapped up in a
component from CodeProject (I don't have the URL handy).

The dialog appears, but the treeview does not.

I get the same result using the old .net 1.0 method with
FolderNameEditor and FolderBrowser(). It used to work before I
upgraded to 1.1 .

Any suggestions?

TIA,

Art

like the other post already said, make sure you have the [STAThread] in
front of your application's entry point.

btw, is there any particular reason why you aren't using the
System.Windows.Forms.FolderBrowserDialog component? It uses the same
control, but it's already wrapped in the .NET framework.
 
I think the guy is working on a WindowsCE device
hence his peculiar needs.

Davy Brion said:
Art said:
I am using VS 2003, .net 1.1

I am trying to use the SHBrowseForFolder dialog, as wrapped up in a
component from CodeProject (I don't have the URL handy).

The dialog appears, but the treeview does not.

I get the same result using the old .net 1.0 method with
FolderNameEditor and FolderBrowser(). It used to work before I
upgraded to 1.1 .

Any suggestions?

TIA,

Art

like the other post already said, make sure you have the [STAThread] in
front of your application's entry point.

btw, is there any particular reason why you aren't using the
System.Windows.Forms.FolderBrowserDialog component? It uses the same
control, but it's already wrapped in the .NET framework.
 
First of all, a sincere Thank You to all who replied. The problem was
indeed the missing [STAThread]. The code for .net 1.0 had it. At
some point in my editing , I removed it; I'm not sure why.

To confess my ignorance, I don't understand why it is necessary, or
what this dialog has to do with COM at all.

To Davy Brion: thank you for the suggestion. I changed the code to
use the built-in FolderBrowserDialog and it works perfectly. I
remember rejecting it because the example in the built-in help is
quite convoluted (it's a small part of an example using menus, open
file dialogs, and what have you.)

I notice now that that example does _not_ have the [STAThread]
attribute on its Main() method. This may be why I removed it in the
first place. Then, as I looked for alternatives, I forgot to put
[STAThread] back in.

To Lloyd Dupont: nope, not using WindowsCE. I come from a Delphi
background, where third-party wrappers for API calls are often more
robust than the native Borland components. Hence, I am predisposed to
look elsewhere.

Again, my thanks to all who replied.

Art Metz
 
Back
Top