Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CXTShellTree and UNC Path
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTShellTree and UNC Path

 Post Reply Post Reply
AliRafiee View Drop Down

Joined: 06 May 2004
Status: Offline
Points: 32
Post Options Post Options   Thanks (0) Thanks(0)   Quote AliRafiee Quote  Post ReplyReply Direct Link To This Post Topic: CXTShellTree and UNC Path
    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:

  // 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;


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.