Removing repeated path
-
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
-
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
-
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
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.
-
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.
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); // // } <
-
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); // // } <
-
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); // // } <
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.
-
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); // // } <
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 FindItemYou 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