Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net
Go Back  Xtreme Visual Basic Talk > > > > Migrating SHBrowseForFolder dialog into .Net


Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2004, 08:29 PM
MKoslof's Avatar
MKoslofMigrating SHBrowseForFolder dialog into .Net MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default Migrating SHBrowseForFolder dialog into .Net


A big, growing challenge for VB programmers is migrating their VB apps into the .Net Framework. One of the biggest challenges is getting Win 32 API calls and functions to run successfully in .Net. There is a learning curve between VB and VB.Net and this code sample will show you how to create a public class for implementing the popular BrowseForFolder API dialog boxes. This Public class provides several functions for calling different dialog boxes such as:

setting a default directory (the initial function I am calling with my button_click example), browsing only for other computers on a network, browsing for only directory folders, browsing for files (no call back procedure for setting the initial directory), browsing via the CISDL, etc.

Since this code piece is lengthy, it will not fit on one thread. So instead of breaking the code up over several threads (this may get confusing) I have copied the whole code piece into a text file. This text file is attached. It will open in any text editor, such as TexPad or NotePad. You can simply copy this code into a standard module..it should work as is. I recommend using it in the 1.1 Framework, I have not tested it in 1.0, but I imagine it would still compile OK. To call any of the functions in this public class, say in a button click, you simply have to instantiate a new class instance like so:

In the New clsFolderBrowser constructor, you just need to pass in the handle you want, I have signified that by putting "handle" in the slot provided.

Code:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strString As String Dim xClass As clsFolderBrowser = New clsFolderBrowser(Handle) strString = xClass.BrowseForFiles("C:\Testing") Me.TextBox1.Text = strString End Sub
Attached Files
File Type: txt VBNet_BrowseForFolder.txt (10.7 KB, 273 views)
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown

Last edited by John; 04-02-2004 at 07:20 AM.
Reply With Quote
  #2  
Old 04-01-2004, 09:24 PM
OnErr0r's Avatar
OnErr0rMigrating SHBrowseForFolder dialog into .Net OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,774
Default

That's an excellent Win32 example. I should mention that the BrowseForFolder dialog is also accessible via the native FolderBrowserDialog class.

You could do something like this:
Code:
Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click Dim fbd As New FolderBrowserDialog fbd.Description = "Select a folder:" ' Add a caption fbd.ShowNewFolderButton = False ' Don't show the button fbd.RootFolder = Environment.SpecialFolder.Desktop ' Start at the desktop If fbd.ShowDialog() = DialogResult.OK Then Debug.WriteLine(fbd.SelectedPath) End If End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed: Template and Common Dialog in VB6 baufay API 1 04-28-2004 04:27 AM
VB6 Vs VB.net barkingmadscot Tech Discussions 9 08-16-2003 02:06 PM
Common Dialog Tutorial MikeJ Tutors' Corner 0 06-04-2003 10:12 PM
.NET - a step in which direction? Quercus Tech Discussions 25 11-07-2002 05:31 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net
 
Migrating SHBrowseForFolder dialog into .Net
Migrating SHBrowseForFolder dialog into .Net
 
-->