Did you know that the CXTShellTree control's PopulateTree method doesn't work with UNC paths?
The problem is in PathFindNextComponent or XTFuncPathFindNextComponent depending on which version of the library you are using.
Anyway, that method will return an invalid path if a UNC path is passed to it
in the PathFindNextComponent the if statement should be
CString CXTShellTreeBase::PathFindNextComponent(const CString& pszPath)
{
// Find the path delimiter
int nIndex = pszPath.Find(_T('\\'));
//if one wasn't found, or the first char is the \
if (nIndex <= 0)
return _T("");
return pszPath.Mid(nIndex + 1);
}
and XTFuncPathFindNextComponent should be:
_XT_EXT_CLASS LPTSTR AFXAPI XTFuncPathFindNextComponent(LPTSTR pszPath)
{
// We will return static memory
static TCHAR tNextComponent[MAX_PATH + 1];
// Make sure we were given a valid path
if ( pszPath == NULL || _tcslen( pszPath ) == 0 ) {
return NULL;
}
// Find the path delimiter
TCHAR *cp = _tcschr( pszPath, _T('\\') );
//if one wasn't found, or the first char is the \
if ( cp == NULL || cp == pszPath) {
// If we didn't find it, return an empty string
tNextComponent[0] = 0;
return tNextComponent;
}
// OK, we have the delimiter. Copy the rest of
// the path to our internal buffer and return it
STRCPY_S( tNextComponent, MAX_PATH , cp + 1 );
return tNextComponent;
}
|