Originally posted by: Jos� Lamas R�os
This is the relevant code at the end of OnInitDialog():
/**/ HTREEITEM hItemLast = NULL;
When I first tried this, including the initial path
selection, I noticed that the selected directory got
displayed as the first visible row of the tree (all parents
hidden). I prefer to see its parents, all the way back to
the root (as long as there is enough space). This
suggestion implements that. Lines added to the original
implementation are marked with /**/ at the start.
/**/ HTREEITEM hItemFirst = NULL;
while( ParsePath( m_sPath, nLevel, &sDirName ) )
{
//Network or Drive expand
if( !nLevel && sDirName.IsEmpty() )
sDirName = NETWORK_NEIGHBOUR;
//Search for the matching tree item and expand
HTREEITEM hItem = m_Tree.GetChildItem( hCurrent );
while( hItem )
{
if( sDirName.CompareNoCase( m_Tree.GetItemText( hItem ) ) == 0 )
{
hCurrent = hItem;
/**/ hItemLast = hCurrent;
/**/ if (hItemFirst == NULL)
/**/ hItemFirst = hCurrent;
m_Tree.Expand( hCurrent, TVE_EXPAND );
break;
}
hItem = m_Tree.GetNextSiblingItem( hItem );
}
nLevel++;
}
/**/ if (hItemFirst != NULL)
/**/ m_Tree.EnsureVisible(hItemFirst);
/**/ if (hItemLast != NULL && hItemLast != hItemFirst)
/**/ m_Tree.EnsureVisible(hItemLast);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
Originally posted by: Sven Ziegler
When I've tried this code on my computer, my device "D:" did not appear in the tree view. All other device did (A:,C:,E:,F:,X:,Y:,Z:).
So, I am new in MFC and I don't know what to do. :( I don't know if I use the newest "PathPickerDll.h" I've got the files from this article. In the Source Files is a comment about a bug fix by Sven Wiegand, but I did not know if the .dll is fixed too ?!?
Please help me!
- Sven
Originally posted by: Andrew Phillips
This would be great as a control in a "subclassed" CFileDialog to show you where you are in the directory tree!
Unlike the poster I disagree strongly that a CFileDialog solution is not the way to go. Although his solution is better than the horrendous SHBrowseForFolder.
The advantages of the CFileDialog solution I use are:
- you can type the path in, which I do a lot
- you can create and delete sub-directories
- you can view details about directories and even files
- you have access very useful options in the popup menu
- the window is resizeable
The only thing I don't like about the CFileDialog is that you cannot see at a glance where you are in the directory hierarchy.
The ultimate solution would be to add this directory tree control to the subclassed CFileDialog solution.
Reply
Originally posted by: charlie
I have a question regarding this Tree control:
when a network map drive is not accessible, it takes a long time
to load this tree view control in first time; however, same situation,
Window Explore doesn't take any time, I was wondering
how can I achieve that? Could you give me a hint?
Thanks a lot in advance,
Originally posted by: Ovidiu Burlacu
If I try to acces in the network a NT computer I can not and the program don't ask me for user and password.
How can I do this?
Originally posted by: Sven Wiegand
When I have tried this code on my computer, my device "C:" did not appear in the tree view.
To fix this bug I have changed the line
UINT nType = GetDriveType( sDrive );
in OnInitDialog() to
UINT nType = GetDriveType( sDrive + _T('\\') );
This is because the API-call GetDriveType does not expect the name of the drive, but the name of the root directory of the drive to test.
Originally posted by: Bruce Weirman
Can a default path be set?
If not, it sure would be a nice enhancement.
Originally posted by: Seo-Wooseok
plz....
How Can I get the file list in the Network Computers' folder
~~~~~~~~~
Originally posted by: Robin Leatherbarrow
Am I missing something here, or can't you do this more easily using SHBrowseForFolder()
Reply