Windows style file browser

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've written a simple application which connects to an FTP server and
recursively lists the contents of the directories in this server in a
ListBox. What I'm wanting to do is change the ListBox and instead, use
something like the Windows file browser. Like when you go through My
Computer, that kind of thing.

Looking at the components that come with Windows.Forms I'm guessing my best
bet is the ListView. The problem I see with this component is, although you
can add pictures for the icons of the contents, they wont be the official
icons. I.E. When the user changes the icon theme these wont change because
they're static pictures.

Is it possible to use the official file browser in a C# app and if so how?
If not, what alternatives are there that I should look at?

Cheers,

Darrell
 
Redneon,

You may be able to use the embedded Internet Explorer control (the browser
control contained within shdocvw.dll) and leverage its built-in file system
browsing capabilities to accomplish what you need.

Check out this article for a good tutorial on how to do this...

Let me know if it works....

Cheers,

Wadih Pazos

Solutions@MBA

(e-mail address removed)

www.SatMBA.com

www.PaperSave.com
 
Darrell,

Even if you were able to access a file browser component, it would
probably link directly to the filesystem, and not allow you to specify which
items you want to display.

The ListView is still the way to go, IMO, you just have to get the icons
for the files. You can get the operating system icons. You can call the
SHGetFileInfo function through the P/Invoke layer to get the icon for
directories and files (either specific ones or for general ones). This way,
you don't have to worry about changes to the icons changing your icons.

Hope this helps.
 
Thanks. I decided to go the SHGetFileInfo router because using IE wouldn't
allow me to specify what's shown. I'd have a lot more control, plus MS
recommend it. I've been looking at the followin MSDN article on it...

http://support.microsoft.com/?kbid=319350

....which has taught me what I needed to know. But I have a little problem
with it. It doesn't seem to work with transparencies well. Instead, it seems
to just show what should be transparent as black. Look at the following for a
screenshot...

http://www.attw91.dsl.pipex.com/capture.jpg

Any ideas of a way around this because it looks really ugly?

Darrell
 
Darrell,

I think that the reason that is happening is because you are using the
new icon formats that were introduced with XP. They have a larger color
palette, and I don't think that the ListView (or the painting algorithms)
support it as of yet. You will have to use the icons with the lower color
palette, I believe.

Hope this helps.
 
Back
Top