Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Removing repeated path

Removing repeated path

Scheduled Pinned Locked Moved C / C++ / MFC
help
7 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sarfaraznawaz
    wrote on last edited by
    #1

    Hi, i have inserted the item in list as a file name or path now again i don't want insert the same path in an list control. i tried with clist find item but i couldn't make it ...... please help me

    _ L 2 Replies Last reply
    0
    • S sarfaraznawaz

      Hi, i have inserted the item in list as a file name or path now again i don't want insert the same path in an list control. i tried with clist find item but i couldn't make it ...... please help me

      _ Offline
      _ Offline
      _Flaviu
      wrote on last edited by
      #2

      CList have CList::Find[^] method ... did you used ? Or you refer on CListBox ?

      1 Reply Last reply
      0
      • S sarfaraznawaz

        Hi, i have inserted the item in list as a file name or path now again i don't want insert the same path in an list control. i tried with clist find item but i couldn't make it ...... please help me

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        sarfaraznawaz wrote:

        i tried with clist find item but i couldn't make it

        We have no way of guessing what this could mean. Please explain clearly, with code extracts, what you are trying to do and what results you are seeing.

        One of these days I'm going to think of a really clever signature.

        S 1 Reply Last reply
        0
        • L Lost User

          sarfaraznawaz wrote:

          i tried with clist find item but i couldn't make it

          We have no way of guessing what this could mean. Please explain clearly, with code extracts, what you are trying to do and what results you are seeing.

          One of these days I'm going to think of a really clever signature.

          S Offline
          S Offline
          sarfaraznawaz
          wrote on last edited by
          #4

          sorry for not explaining m_listCrl = DEBUG_NEW CListCtrl; if(!m_listCrl->Create(WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_AUTOARRANGE,/*CRect(65, 100, 960, 448)*/CRect (60, 105, 954, 435),this,IDC_LIST_CTRL)) { TRACE ("\nDBG:\tFailed to create window object for List ctrl at line %u in %s.", __LINE__, __FILE__); return -1; } GetPrivateProfileString (_T ("Remo Eraser"), _T ("IDS_CLOUMN1"), NULL, (LPWSTR)szNewText, sizeof(szNewText), m_szPath); m_listCrl->GetHeaderCtrl(); m_listCrl->InsertColumn(1,(LPWSTR)szNewText,LVCFMT_LEFT,75+75+25+50+25+25+25,-1); GetPrivateProfileString (_T ("Remo Eraser"), _T ("IDS_CLOUMN2"), NULL, (LPWSTR)szNewText, sizeof(szNewText), m_szPath); m_listCrl->InsertColumn(2,(LPWSTR)szNewText,LVCFMT_CENTER,75+75+25+50+25+25+25+10,-1); GetPrivateProfileString (_T ("Remo Eraser"), _T ("IDS_CLOUMN3"), NULL, (LPWSTR)szNewText, sizeof(szNewText), m_szPath); m_listCrl->InsertColumn(3,(LPWSTR)szNewText,LVCFMT_CENTER,75+75+25+50+25+25+10-1); m_listCrl->InsertItem(0,File_Name,NULL); m_listCrl->SetItemText(0,1,m_Filepath); m_listCrl->SetItemText(0,2,_T("10KB"));

          here is the code am adding the file name and file path in an Clist ctl. am dont want to add the same file name or path in an list . i tried with FindItem // info.flags =/* LVFI_PARTIAL|LVFI_STRING*/LVFI_PARAM; // info.psz = m_Filepath; // Delete all of the items that begin with the string. // index = m_listCrl->FindItem(&info); // while ((index = m_listCrl->FindItem(&info))!= -1) // { // MessageBox(_T("File Already exists "),_T("Inforamtion"),MB_ICONINFORMATION); // m_listCrl->DeleteItem(index); // // } <

          _ L D 3 Replies Last reply
          0
          • S sarfaraznawaz

            sorry for not explaining m_listCrl = DEBUG_NEW CListCtrl; if(!m_listCrl->Create(WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_AUTOARRANGE,/*CRect(65, 100, 960, 448)*/CRect (60, 105, 954, 435),this,IDC_LIST_CTRL)) { TRACE ("\nDBG:\tFailed to create window object for List ctrl at line %u in %s.", __LINE__, __FILE__); return -1; } GetPrivateProfileString (_T ("Remo Eraser"), _T ("IDS_CLOUMN1"), NULL, (LPWSTR)szNewText, sizeof(szNewText), m_szPath); m_listCrl->GetHeaderCtrl(); m_listCrl->InsertColumn(1,(LPWSTR)szNewText,LVCFMT_LEFT,75+75+25+50+25+25+25,-1); GetPrivateProfileString (_T ("Remo Eraser"), _T ("IDS_CLOUMN2"), NULL, (LPWSTR)szNewText, sizeof(szNewText), m_szPath); m_listCrl->InsertColumn(2,(LPWSTR)szNewText,LVCFMT_CENTER,75+75+25+50+25+25+25+10,-1); GetPrivateProfileString (_T ("Remo Eraser"), _T ("IDS_CLOUMN3"), NULL, (LPWSTR)szNewText, sizeof(szNewText), m_szPath); m_listCrl->InsertColumn(3,(LPWSTR)szNewText,LVCFMT_CENTER,75+75+25+50+25+25+10-1); m_listCrl->InsertItem(0,File_Name,NULL); m_listCrl->SetItemText(0,1,m_Filepath); m_listCrl->SetItemText(0,2,_T("10KB"));

            here is the code am adding the file name and file path in an Clist ctl. am dont want to add the same file name or path in an list . i tried with FindItem // info.flags =/* LVFI_PARTIAL|LVFI_STRING*/LVFI_PARAM; // info.psz = m_Filepath; // Delete all of the items that begin with the string. // index = m_listCrl->FindItem(&info); // while ((index = m_listCrl->FindItem(&info))!= -1) // { // MessageBox(_T("File Already exists "),_T("Inforamtion"),MB_ICONINFORMATION); // m_listCrl->DeleteItem(index); // // } <

            _ Offline
            _ Offline
            _Flaviu
            wrote on last edited by
            #5

            Take care, CListCtrl::FindInfo[^] search in list only in items (not in subitems), and you want to search in subitems ... so, you have to loop in all list control and test if subitem 'Path' is already there ...

            1 Reply Last reply
            0
            • S sarfaraznawaz

              sorry for not explaining m_listCrl = DEBUG_NEW CListCtrl; if(!m_listCrl->Create(WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_AUTOARRANGE,/*CRect(65, 100, 960, 448)*/CRect (60, 105, 954, 435),this,IDC_LIST_CTRL)) { TRACE ("\nDBG:\tFailed to create window object for List ctrl at line %u in %s.", __LINE__, __FILE__); return -1; } GetPrivateProfileString (_T ("Remo Eraser"), _T ("IDS_CLOUMN1"), NULL, (LPWSTR)szNewText, sizeof(szNewText), m_szPath); m_listCrl->GetHeaderCtrl(); m_listCrl->InsertColumn(1,(LPWSTR)szNewText,LVCFMT_LEFT,75+75+25+50+25+25+25,-1); GetPrivateProfileString (_T ("Remo Eraser"), _T ("IDS_CLOUMN2"), NULL, (LPWSTR)szNewText, sizeof(szNewText), m_szPath); m_listCrl->InsertColumn(2,(LPWSTR)szNewText,LVCFMT_CENTER,75+75+25+50+25+25+25+10,-1); GetPrivateProfileString (_T ("Remo Eraser"), _T ("IDS_CLOUMN3"), NULL, (LPWSTR)szNewText, sizeof(szNewText), m_szPath); m_listCrl->InsertColumn(3,(LPWSTR)szNewText,LVCFMT_CENTER,75+75+25+50+25+25+10-1); m_listCrl->InsertItem(0,File_Name,NULL); m_listCrl->SetItemText(0,1,m_Filepath); m_listCrl->SetItemText(0,2,_T("10KB"));

              here is the code am adding the file name and file path in an Clist ctl. am dont want to add the same file name or path in an list . i tried with FindItem // info.flags =/* LVFI_PARTIAL|LVFI_STRING*/LVFI_PARAM; // info.psz = m_Filepath; // Delete all of the items that begin with the string. // index = m_listCrl->FindItem(&info); // while ((index = m_listCrl->FindItem(&info))!= -1) // { // MessageBox(_T("File Already exists "),_T("Inforamtion"),MB_ICONINFORMATION); // m_listCrl->DeleteItem(index); // // } <

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              First comment, please use <pre> tags around code snippets, as I have done below. Your LVFINDINFO.flags are wrong, and should be as follows:

              info.flags = LVFI_STRING;
              info.psz = m_Filepath;

              index = m_listCrl->FindItem(&info);
              if (m_listCrl->FindItem(&info) == -1)
              {
              // File path not found
              }

              One of these days I'm going to think of a really clever signature.

              1 Reply Last reply
              0
              • S sarfaraznawaz

                sorry for not explaining m_listCrl = DEBUG_NEW CListCtrl; if(!m_listCrl->Create(WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_AUTOARRANGE,/*CRect(65, 100, 960, 448)*/CRect (60, 105, 954, 435),this,IDC_LIST_CTRL)) { TRACE ("\nDBG:\tFailed to create window object for List ctrl at line %u in %s.", __LINE__, __FILE__); return -1; } GetPrivateProfileString (_T ("Remo Eraser"), _T ("IDS_CLOUMN1"), NULL, (LPWSTR)szNewText, sizeof(szNewText), m_szPath); m_listCrl->GetHeaderCtrl(); m_listCrl->InsertColumn(1,(LPWSTR)szNewText,LVCFMT_LEFT,75+75+25+50+25+25+25,-1); GetPrivateProfileString (_T ("Remo Eraser"), _T ("IDS_CLOUMN2"), NULL, (LPWSTR)szNewText, sizeof(szNewText), m_szPath); m_listCrl->InsertColumn(2,(LPWSTR)szNewText,LVCFMT_CENTER,75+75+25+50+25+25+25+10,-1); GetPrivateProfileString (_T ("Remo Eraser"), _T ("IDS_CLOUMN3"), NULL, (LPWSTR)szNewText, sizeof(szNewText), m_szPath); m_listCrl->InsertColumn(3,(LPWSTR)szNewText,LVCFMT_CENTER,75+75+25+50+25+25+10-1); m_listCrl->InsertItem(0,File_Name,NULL); m_listCrl->SetItemText(0,1,m_Filepath); m_listCrl->SetItemText(0,2,_T("10KB"));

                here is the code am adding the file name and file path in an Clist ctl. am dont want to add the same file name or path in an list . i tried with FindItem // info.flags =/* LVFI_PARTIAL|LVFI_STRING*/LVFI_PARAM; // info.psz = m_Filepath; // Delete all of the items that begin with the string. // index = m_listCrl->FindItem(&info); // while ((index = m_listCrl->FindItem(&info))!= -1) // { // MessageBox(_T("File Already exists "),_T("Inforamtion"),MB_ICONINFORMATION); // m_listCrl->DeleteItem(index); // // } <

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                sarfaraznawaz wrote:

                m_listCrl->InsertColumn(1,(LPWSTR)szNewText,LVCFMT_LEFT,75+75+25+50+25+25+25,-1);

                Are you seriously doing this in production code or is this just a personal project?

                sarfaraznawaz wrote:

                m_listCrl->InsertItem(0,File_Name,NULL); m_listCrl->SetItemText(0,1,m_Filepath); m_listCrl->SetItemText(0,2,_T("10KB"));

                This should be:

                int nItem = m_listCrl->InsertItem(0, File_Name);
                m_listCrl->SetItemText(nItem, 1, m_Filepath);
                m_listCrl->SetItemText(nItem, 2, _T("10KB"));

                sarfaraznawaz wrote:

                here is the code
                am adding the file name and file path in an Clist ctl.
                am dont want to add the same file name or path in an list .
                i tried with FindItem

                You should be using some other data structure that is better suited for searching, or one that doesn't allow duplicates to begin with. Populate the list control from that.

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups