Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3441930
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:36:43+00:00 2026-05-18T08:36:43+00:00

how to differentiate a Folder Type(Windows/FTP) in MFC(VC++)? In my case I have a

  • 0

how to differentiate a Folder Type(Windows/FTP) in MFC(VC++)?
In my case I have a MFC Treeview in which i am adding list of folders coming from server , that folders are Windows and CIFS .Now i want to differentiate internally what type of folder are they because i select some folder and say connect then it brings up login page where i need to login credentials details , but before that i need to differentiate what type of folder is that ?

Any treeview property like setting and geeting key or any other approach.
Thanks in Advance.

I get folder list from server in this format volume1/Folder1,volume2/Folder2||Folder3,Folder4 in this below method i am removing “||” and maintaining them in two differnt variables: strDataFolder contains – FTP Folders and
strNASfolders conatins CIFS folder , then one more method i am using UpdateFolder. If it is FTP then directly Add but if it CIFS check for duplication if that folder is already there dont add it again to treeview.

Now iam not able to get it how to differentiate what type of folder are they ?

void CNDSClientDlg::UpdateSharedFolder(CString strNASfolders,HTREEITEM hChildItem)
{
    CString strDataFolder = "";
    CString strData = "";       

    int iPos = 0;
    int fPosition = 0;

    fPosition = strNASfolders.Find("||");           
    if(fPosition != -1)
    {
        strDataFolder = strNASfolders.Mid(0,fPosition);
        strNASfolders = strNASfolders.Right(strNASfolders.GetLength()-(fPosition+2));   

    }
    else
    {
       strDataFolder = strNASfolders;
    }

    if (strDataFolder != "" )
    {
         UpdateFolders(strDataFolder,hChildItem,false);

    }
    if (strNASfolders != "" )        //don't add if already exist
    {
        UpdateFolders(strNASfolders,hChildItem,true);
    }

}

void CNDSClientDlg::UpdateFolders(CString strFolderType,HTREEITEM hChildItem,bool bCheck)
{
        int iPos = 0 ;      
        CString strData = "";
        CString strCurrFolder ="";
        HTREEITEM HShareFolder = NULL;
        bool bFound = false ;
        while (iPos != -1)
        {
            iPos = strFolderType.Find(","); 



        if (iPos != -1)
        {               
             strData = strFolderType.Mid(0,iPos);//get the folder details
        }
        else
        {
            strData = strFolderType;//get the last folder details
        }

        strFolderType = strFolderType.Right(strFolderType.GetLength()-(iPos+1)); //get remaining data
        int fPos = strData.ReverseFind('/');
        if (fPos != -1)
        {
            strCurrFolder = strData.Mid(fPos+1,strData.GetLength());    // get required data                                

        }
        else
        {
            strCurrFolder = strData; //else assign all the data 
        }

         if(bCheck == true)
         {
            bFound = false ;
            HTREEITEM hTempItem = NULL;
            CString strItemText = "" ;
            hTempItem = m_pTreeview->GetChildItem(hChildItem);
            strItemText = m_pTreeview->GetItemText(hTempItem);
            while(hTempItem != NULL)
            {
                if(strItemText != strCurrFolder) 
                {
                    strItemText = m_pTreeview->GetItemText(hTempItem);
                    hTempItem = m_pTreeview->GetNextSiblingItem(hTempItem);
                }
                else
                {
                    bFound = true;
                    break;
                }
            }


         }
        if(bCheck == false || bFound == false)
         {

                HShareFolder = m_pTreeview->InsertItem(strCurrFolder,hChildItem);                   
                m_pTreeview->SetItemImage(HShareFolder,2,2);
                TTipItemData* pToolTipData ; 
                pToolTipData  = new TTipItemData; 
                pToolTipData->strTool = strData ;                                                                
                m_pTreeview->SetItemData(HShareFolder,DWORD(pToolTipData));

            }

         m_pTreeview->Expand(hParentItem,TVE_EXPAND);
         m_pTreeview->EnsureVisible(hParentItem);



    }

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:36:44+00:00Added an answer on May 18, 2026 at 8:36 am

    Items in treeviews can have arbitrary data associated with them. Check out:

    http://msdn.microsoft.com/en-us/library/ettyybhw(VS.80).aspx

    The InsertItem method shown here has an LPARAM parameter. This is for your use, and you can set this to some value that is meaningful to your application.

    (EDIT: Alternatively, use one of the least convoluted overloads to insert your item and use CTreeCtrl::SetItemData on the handle that is returned afterwards).

    To find out what value is associated with your item, use CTreeCtrl::GetItemData.

    Minor Example:

    HTREEITEM hItem = m_ctrlTree.InsertItem("My Item", TVI_ROOT);
    HTREEITEM hOther = m_ctrlTree.InsertItem("Child Item", hItem);
    m_ctrlTree.SetItemData(hItem, static_cast<DWORD_PTR>(10)); // set LPARAM to 10
    
    // note, you can also store pointers!  This assumes pObj is some kind of instance
    // of a class.
    m_ctrlTree.SetItemData(hOther, static_cast<DWORD_PTR>(pObj));
    
    
    // at a later point:
    int myVal = static_cast<int>(m_ctrlTree.GetItemData(hItem));
    MyObject* pObj = static_cast<MyObject*>(m_ctrlTree.GetItemData(hOther));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to differentiate between an incoming request from an Iphone App and an
I have a web project which the folders are constructed within the areas .
how to differentiate the 480X800 and 480X854 screens. we have an option to put
I have a problem, which only is an issue when my application is deployed
I need to differentiate between page load and page refresh in jQuery. I have
I am trying to differentiate a click from a swipe in Javascript using touch
In a software, how would you differentiate a Component from a Module?
Is there anyway in Thunderbird to differentiate between new messages and messages that have
How I can differentiate in the dataInit event wether am I adding new data
I have two IIS sites pointing to diffent physical folders. This is to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.