Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Directory browser with CtreeCtrl(?) 3

Status
Not open for further replies.

MvanH

Technical User
May 15, 2001
19
0
0
NL
hello people,

I have to make a dailog in which a user can browse in directories on the network and on the desktop pc.
In this dialog he has to be able to select command files in txt form. (which will than be interpreted)
I'm trying to use a CtreeCtrl object in a dialog.
But I don't know how I can get thinks like drives and directorys in the CTreeCtrl.
I can only put in CStrings with AddItem.

Can anybody tell me how to put in (add) directorys and drives?

(maybe a stupid question but isn't there something like a standard 'browse' dialog window?)

Thanks.
Martini.
 
Hi

There is a function called SHBrowseForFolder that could fit your needs.
Assume that you call this code in a function where the default starting path is passed as a parameter named strDefaultPath.
Don't forget to add the callback function. See MSDn for more info.

HTH
Thierry
EMail: Thierry.Marneffe@swing.be
WebSite:
BROWSEINFO bi;
char szBuffer[MAX_PATH];
LPTSTR pDefaultPath =
strDefaultPath.GetBuffer( strDefaultPath.GetLength());

LPITEMIDLIST pidl;

bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = szBuffer;
bi.lpszTitle = _T("Select the Directory");
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = BrowseCallBackProc;
bi.lParam = ( LPARAM) pDefaultPath;

pidl = SHBrowseForFolder( &bi);

strDefaultPath.ReleaseBuffer();

if ( pidl != NULL)
{
if ( SHGetPathFromIDList( pidl, szBuffer))
{
// Store Location

strLocation = szBuffer;
}
else
AfxMessageBox( "Error Getting Path ...");
}
}

Add the callback function

int CALLBACK BrowseCallBackProc( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{

switch( uMsg)
{
case BFFM_INITIALIZED:

::SendMessage( hwnd, BFFM_SETSELECTION, TRUE, lpData);

break;
}

return 0;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top