CXTShellTree and UNC Path |
Post Reply |
Author | |
AliRafiee
Groupie Joined: 06 May 2004 Status: Offline Points: 32 |
Post Options
Thanks(0)
Posted: 22 July 2009 at 11:11am |
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;
}
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |