Click here to Skip to main content
15,902,114 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Listview Sorting Pin
Eugen Podsypalnikov21-Apr-10 1:12
Eugen Podsypalnikov21-Apr-10 1:12 
GeneralRe: Listview Sorting Pin
arun_pk21-Apr-10 18:31
arun_pk21-Apr-10 18:31 
GeneralRe: Listview Sorting Pin
Eugen Podsypalnikov21-Apr-10 19:15
Eugen Podsypalnikov21-Apr-10 19:15 
GeneralRe: Listview Sorting Pin
arun_pk21-Apr-10 19:18
arun_pk21-Apr-10 19:18 
GeneralRe: Listview Sorting Pin
Eugen Podsypalnikov21-Apr-10 19:43
Eugen Podsypalnikov21-Apr-10 19:43 
GeneralRe: Listview Sorting Pin
arun_pk21-Apr-10 19:55
arun_pk21-Apr-10 19:55 
GeneralRe: Listview Sorting Pin
Eugen Podsypalnikov21-Apr-10 20:07
Eugen Podsypalnikov21-Apr-10 20:07 
GeneralRe: Listview Sorting Pin
arun_pk21-Apr-10 20:18
arun_pk21-Apr-10 20:18 
Yup.....
Now my code is like this


on WM_NOTIFY
case LVN_COLUMNCLICK:
        {
            int iCol = ((LPNMLISTVIEW) lParam)->iSubItem;
                if (0 <= iCol && iCol < 3)
                {
                    g_arOrders[iCol] = !g_arOrders[iCol]; // order reversing,                                              // will be used at comparing
                    ListView_SortItems((GetDlgItem(hDlg,LV_NOTATIONS)), ListViewCompareProc, iCol);
                }



and my ListViewCompareProc method is


int CALLBACK SelectNotationsDlg::ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
	LPLVITEMDATA	lplvid1 = (LPLVITEMDATA) lParam1;
	LPLVITEMDATA	lplvid2 = (LPLVITEMDATA) lParam2;
	int				rc = 0;
	int				second_sort = FALSE;
	char epoch1[100];
	char epoch2[100];

	if (lParamSort & second_sort)
	{
		lParamSort &= ~second_sort;
		second_sort = TRUE;
	}

	switch (lParamSort)												// this is the type of sorting being done
	{
	case 0:														// name
		{
			itoa((*NotationInfo)[lplvid1->ListNumber].nEpoch,epoch1,10);
			itoa((*NotationInfo)[lplvid2->ListNumber].nEpoch,epoch2,10);
			rc = Left_Greater_Than_Right(epoch1,epoch2,
												  20, TRUE);
			break;
		}

	case 1:														// type
		{
			rc = Left_Greater_Than_Right((*NotationInfo)[lplvid1->ListNumber].szDateTime, (*NotationInfo)[lplvid2->ListNumber].szDateTime,
												  max(lstrlen((*NotationInfo)[lplvid1->ListNumber].szDateTime), lstrlen((*NotationInfo)[lplvid2->ListNumber].szDateTime)),
																	  FALSE);
			break;
		}

	case 2:														// time
		{
			// compare HH:MM
			rc = Left_Greater_Than_Right((*NotationInfo)[lplvid1->ListNumber].szEvent ,
												  (*NotationInfo)[lplvid2->ListNumber].szEvent, 6, FALSE);
			break;
		}
	}
	if ((!rc) && (Sort1 != Sort2) && (!second_sort))
	{
		rc = ListViewCompareProc(lParam1, lParam2, (Sort2 | second_sort));
	}

	return (rc * g_arOrders[lParamSort]);
	}

still not able to get sorted
still missing something?
GeneralRe: Listview Sorting Pin
Eugen Podsypalnikov21-Apr-10 20:30
Eugen Podsypalnikov21-Apr-10 20:30 
GeneralRe: Listview Sorting Pin
arun_pk21-Apr-10 20:45
arun_pk21-Apr-10 20:45 
GeneralRe: Listview Sorting Pin
Eugen Podsypalnikov21-Apr-10 20:49
Eugen Podsypalnikov21-Apr-10 20:49 
GeneralRe: Listview Sorting Pin
arun_pk21-Apr-10 20:51
arun_pk21-Apr-10 20:51 
GeneralRe: Listview Sorting Pin
Eugen Podsypalnikov21-Apr-10 20:57
Eugen Podsypalnikov21-Apr-10 20:57 
GeneralRe: Listview Sorting Pin
arun_pk21-Apr-10 21:01
arun_pk21-Apr-10 21:01 
GeneralRe: Listview Sorting Pin
arun_pk21-Apr-10 20:55
arun_pk21-Apr-10 20:55 
GeneralRe: Listview Sorting Pin
Eugen Podsypalnikov21-Apr-10 21:04
Eugen Podsypalnikov21-Apr-10 21:04 
GeneralRe: Listview Sorting Pin
arun_pk21-Apr-10 21:09
arun_pk21-Apr-10 21:09 
GeneralRe: Listview Sorting Pin
Eugen Podsypalnikov21-Apr-10 21:18
Eugen Podsypalnikov21-Apr-10 21:18 
GeneralRe: Listview Sorting Pin
arun_pk21-Apr-10 22:45
arun_pk21-Apr-10 22:45 
GeneralRe: Listview Sorting Pin
Eugen Podsypalnikov21-Apr-10 22:46
Eugen Podsypalnikov21-Apr-10 22:46 
GeneralRe: Listview Sorting Pin
arun_pk21-Apr-10 23:03
arun_pk21-Apr-10 23:03 
GeneralRe: Listview Sorting Pin
Eugen Podsypalnikov21-Apr-10 23:14
Eugen Podsypalnikov21-Apr-10 23:14 
GeneralRe: Listview Sorting Pin
arun_pk21-Apr-10 23:14
arun_pk21-Apr-10 23:14 
GeneralRe: Listview Sorting Pin
Eugen Podsypalnikov21-Apr-10 23:18
Eugen Podsypalnikov21-Apr-10 23:18 
GeneralRe: Listview Sorting Pin
arun_pk22-Apr-10 0:06
arun_pk22-Apr-10 0:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.