CodeGuru
Earthweb Search
Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

follow us on Twitter

Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.

Become a Marketplace Partner

jobs.internet.com

internet.commerce
Partners & Affiliates
















Home >> Visual C++ / C++ >> Controls >> Treeview Control >> Directory Browsers


Path Picker with Network Capabilities
Rating: none

John McTainsh (view profile)
May 30, 1999


(continued)



Sample Image

Environment: VC6 SP2

This DLL displays a directory tree similar to the one found in "Find in Files" Browse button. See below.

I have noticed several applications requiring a user to select a path that often use CFileDialog which does not fit the task very well. A better option is to use a Tree control but I have not found any that allow access to the network other than via mapped drives. Both methods lack the style that "Find in Files" provides.

I have developed the Dialog as a DLL for easy implementation. The source is written to put the Dialog object into a single class so it can be hacked out and used in any willing developers code.

How to use it.

I have provided two ways of using this code. Using the DLL directly requires the least effort, but allows least customisation.

Method 1 - Adding to your own project.

  1. Copy the source files DlgGetPath.cpp and DlgGetPath.h to your Project directory and add them to your project.
  2. Change #include "PathPicker.h" to the name of your project as necessary.
  3. From within your project open the PathPicker.rc file and drag the Bitmap and Dialog into your project.
  4. Add the following code where you want to activate the Picker dialog. ie in a button handler.
    
    #include "DlgGetPath.h"      //Definition to get path
    ...
    void CBlarOnButtonBrowse()
    {
    	CDlgGetPath dlgPath( this );
    	dlgPath.SetTitle( _T("Blar..") );
    	dlgPath.m_sTopNote = _T("Blar blar blar...");
    	if( dlgPath.DoModal() == IDOK )
    	{
    		//Do some cool stuff with it here
    		//SetDlgItemText( IDC_EDIT_SEARCH_IN, dlgPath.GetPath() );
    	}
    }
    
Method 2 - Using the DLL. This method uses the DLL. It is a regular DLL so can also be used with inferior languages such as VB and Delphi. The following example is a simple static implementation however dynamic loading when the dialog is called is also possible.
  1. Link your project with PathPicker.lib and insert the following code where you want the dialog to appear.
  2. Place the PathPicker.DLL in the same directory as your app or the System directory.
    
    #include "PathPickerDll.h"
    ...
        //Once the parent window is created
        TCHAR szPath[200];
        ShowDialog( (long)m_hWnd, "Blar.", "Blar blar...", szPath, 199 );
        MessageBox( szPath );
    

Notes.

  • This code was developed using VC++ 6.0, SP 2.0.
  • Notes on limitations are in Source file DlgGetPath.cpp.

Downloads

Download DLL files and Method2 sample - 12 Kb

Download source - 20 KB

History

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed







RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

(You must be signed in to rank an article. Not a member? Click here to register)

Latest Comments:
Great stuff!!! Added a selection routine to select a given path - bgsommerfeld (03/27/2006)
Help : Tree Item link to directory - Legacy CodeGuru (02/09/2004)
i haven't the disk C in the tree - Legacy CodeGuru (01/11/2002)
Displaying files within directory??? - Legacy CodeGuru (12/04/2001)
Large Network Problem - Legacy CodeGuru (10/19/2001)

View All Comments
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



(You must be signed in to comment on an article. Not a member? Click here to register)

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers