Path Picker with Network Capabilities | CodeGuru

Path Picker with Network Capabilities

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
May 30, 1999
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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 );
    
Advertisement

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

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.