CListCtr.SortItem lParam1 == lParam2
-
Ich will mit SortItem meine Liste sortieren,aber aus irgendeinen Grund packt das Programm bei jeden Aufruf meiner Vergleichsfunktion in lParam1 und lParam2 die erste Zeile Liste.Woran kann das liegen?
-
-
Das hat leider nichts mit meinen Problem zu tun ich versuchen nicht lParam als Index zu verwenden.
int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2,LPARAM lParamSort) { CString e1,e2; int SortBy =(int)lParamSort; LVFINDINFO lvf; lvf.flags = LVFI_PARAM; lvf.lParam =lParam1; e1 = l->GetItemText(l->FindItem(&lvf),SortBy); lvf.lParam =lParam2; e2 = l->GetItemText(l->FindItem(&lvf),SortBy); int rv =0; switch(SortBy) { case 1: case 2: if(e1 == e2) { rv =0; AfxMessageBox(e1 + " = " + e2); } if(e1 > e2) { rv =1; AfxMessageBox(e1 + " > " + e2); } if(e1 < e2) { rv =-1; AfxMessageBox(e1 + " < " + e2); } break; } return rv; }
In der Messagebox steht immer "Text1=Text1"
-
Original erstellt von Andorxor:
In der Messagebox steht immer "Text1=Text1"Und das liegt mit ziemlicher Sicherheit daran, dass lParam1 und lParam2 für jedes Item Null sind. Und warum das so ist, steht in dem FAQ-Beitrag:
If you have not assigned any data to these variables, then they will be zero when passed to your sort function.
-
Danke,hab geändert wie die Item eingegeben werden und jetzt läuft