Yesterday did the sorting function in ListControl, but after use, it was found that only when the first data was completely not sorted, it was correct, carefully read the callback function used to sort: int Callback cstamdiag :: Comparefunc LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) {CString strItem1 = g_dlg-> m_List_StaResult.GetItemText ((int) lParam1, (int) lParamSort); CString strItem2 = g_dlg-> m_List_StaResult.GetItemText ((int) lParam2, (int) lParamSort ); Int R1 = ATOI (stritem1); int R2 = ATOI (stritem2); if (r1 == r2) returnography; else {if (r1> r2) return -1; else return 1;}} finally discovered problems At the time, it is assumed that the arrangement of the LParam parameters is 0, 1, 2, 3, 4, 5, when starting, g_dlg-> m_list_staresisult.getitemtext (int) LPARAM, (int) LPARMSORT), if To take the second project, it is (1, lparamsort), but after sorting, according to the above algorithm, take the second item, due to the arrangement of the LPARAM parameter may be 0, 3, 2, 1, 4, 5. As a result, it will take the wrong project, which leads to the sorting of the project to come to the project, and of course not allowed, so cstring stritem1 = g_dlg-> m_list_staresis settExt ((int) LPARAM1, (int) lparamsort) It is wrong, so it cannot be used to represent the line of data in the data. Since you can pass a LPARAM parameter, that program is definitely what you want to try, so we have to do it through the LPARAM to get the data in the project, find the relevant information, the results are as follows: CSTRING STRITEM1, STRITEM2; LVFINDINFO INFO ; int nIndex; info.flags = LVFI_PARAM; info.lParam = lParam1; if (! (nIndex = g_dlg-> m_List_StaResult.FindItem (& info)) = - 1) strItem1 = g_dlg-> m_List_StaResult.GetItemText (nIndex, (int) LParamsort; info.lparam = lparam2; if ((Nindex = g_dlg-> m_list_staresis)! = - 1) stritem2 = g_dlg-> m_list_staresis (NINDEX, (INT) LParamsort;
In this way, it will take the correct item, and what is going on behind, this is not written here, I only say a key part.