I saw a need to add a selection routine to select a given path. This is helpful when the user keeps going back to the same folder.
Here's the code.
bool CDlgGetPath::SelectItem(HTREEITEM hItem, CString szFindPath, CString szFullPath)
{
bool bContinue = true;
CString szCurPath;
CString szCompare;
if( szFindPath.IsEmpty() )
return false;
if( szFindPath[szFindPath.GetLength()-1] != '\\' )
szFindPath += "\\";
szFindPath.MakeLower();
szCompare = szFindPath.SpanExcluding( "\\" );
szFindPath = szFindPath.Mid( szCompare.GetLength() + 1 );
szFullPath += szCompare;
szFullPath += "\\";
if( szCompare.IsEmpty() || !hItem )
{
// We couldn't find it...abort
return false;
}
//
//Search through the siblings for the current segment
//
while( bContinue && hItem )
{
szCurPath = m_Tree.GetItemText( hItem );
szCurPath.MakeLower();
if( szCurPath == szCompare )
{
// We found this segment
m_Tree.SelectItem( hItem );
PopulateTree( szFullPath, hItem );
if( szCompare.GetLength() < 1 )
{
// We found it...stop
bContinue = false;
}
else
{
// Now traverse through our children
HTREEITEM hChildItem = m_Tree.GetChildItem( hItem );
bContinue = SelectItem( hChildItem, szFindPath, szFullPath );
}
}
hItem = m_Tree.GetNextSiblingItem( hItem );
}
return bContinue;
}
Reply
Originally posted by: zeus
Is there a possible way to link a directory directly
to a tree Item instead of starting from the C: directory???
Any help will be appreciated(sample code,etc..)
Thanks...
ReplyOriginally posted by: Maitri Venkat-Ramani
How do you modify the code to display files in each directory???
Thank you!!
ReplyOriginally posted by: Schuster, CP
Function:
Original Code Section:
Replace with:
This Lets the Do While Loop keep Looping Until All Items are Enumerated.
Chris Schuster
I have over a thousand listings in some network groups.
When you would Open Network Neighborhood only about half of
the computers in the group would show. The TRACE Message
was "*** ERROR 0 - Cannot complete network drive
enumeration" I looked up the WNetEnumResource and this
function is meant to be called many times. One simple
change fixes every thing.
bool CDlgGetPath::EnumNetwork( HTREEITEM hParent )
if( dwResult != ERROR_NO_MORE_ITEMS )
{
TRACE( _T("*** ERROR %d - Cannot complete network drive enumeration\n"), dwResult );
break;
}
if( dwResult != ERROR_NO_MORE_ITEMS && dwResult != NO_ERROR)
{
TRACE( _T("*** ERROR %d - Cannot complete network drive enumeration\n"), dwResult );
dwResult = ERROR_NO_MORE_ITEMS;
}
Originally posted by: BwB
Folders listed under local drives on my machine (mainly my C drive, which is the only local one I have) are not listed in alphabetical order. I'm running Win2k Professional. Its very annoying and difficult to select a folder when you have to look through the entire list to find the one you want...
Anyone have a fix for this?
ReplyOriginally posted by: David Gosbee
Linking...
.\PathPicker.lib : fatal error LNK1106: invalid file or disk full: cannot seek to 0x3749f77a
Error executing link.exe.
Can anyone help?
thanx.
Originally posted by: Cho
Thanks for good source code.
But I have a question for your code.
I have met the same error whenever I push the
cancel butten without any directory selected.
Could you fix the error?
Reply
Originally posted by: Shlomi Ben-Zvi
I added the following line to BEGIN_MESSAGE_MAP
ON_NOTIFY(NM_RDBLCLK, IDC_TREE, OnRdblclkTree)
and the appropriate code to the OnRdblclkTree() function
Unfortunately, I can't figure out why OnRdblclkTree never receives control.
Thank you.
I am trying to add a double clicking capability to the tree control so the user can
select and exit the dialog in one action.
Originally posted by: Andreas H
Hi!
I tried your function here because it sounds so great, it
was just what i had been looking for. I added the files to my project like in method one. But when i try to compile later i get this error messages:
DlgGetPath.obj : error LNK2001: unresolved external symbol _WNetCloseEnum@4
DlgGetPath.obj : error LNK2001: unresolved external symbol _WNetEnumResourceA@16
DlgGetPath.obj : error LNK2001: unresolved external symbol _WNetOpenEnumA@20
Debug/PlayList.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
Im running VC++6.
Please help me i kind of got a deadline on this project!
Thanks in Advance / Andreas
Originally posted by: Chris S.
Sorting can be done easily by adding
> if (bGotChildren)
> m_Tree.SortChildren(hParent);
into PopulateTree, if (hParent == m_hNetworkRoot) .. else if .. else, directly after while (bWorking)
Where is SetPath()-function ? added myself:
> void SetPath( CString sPath) { m_sPath = sPath; }
Display recycle bin:
add into PopulateTree, while (bWorking), if (finder.IsDirectory())
> bool bRecycleDir = finder.GetFileName() == "RECYCLED" && finder.IsSystem();
modify the following InsertItem(..)-call (or introduce a #define-constant DIR_RECYCLE or whatever)
> InsertItem( hParent, NULL, finder.GetFileName(), (bRecycleDir ? 15 : DRIVE_NO_ROOT_DIR), (bRecycleDir ? 15 : DRIVE_UNKNOWN) );
Image No. 15 (added by me) is an image of the bin as it is displayed by the Windows explorer
Possibility to hide the recycle bin
add bool m_bHideRecycleBin, let the constructor set a default value
add into PopulateTree, while (bWorking), if (finder.IsDirectory()) after bool bRecycleDir = ..
> if (!bRecycleDir || !m_bHideRecycleBin)
> { InsertItem(..); bGotChildren = true; } /*old stuff*/
Reply