这是我的回调函数:
int CALLBACK SortMeAscending(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
int nRetVal = 0;
PITEMDATA pData1 = (PITEMDATA)lParam1;
PITEMDATA pData2 = (PITEMDATA)lParam2;
switch(lParamSort)
{
case 0:
if(pData1->iSeq < pData2->iSeq)
nRetVal = -1;
else if(pData1->iSeq > pData2->iSeq)
nRetVal = 1;
else
nRetVal = 0;
break;
case 1:
nRetVal = lstrcmp(pData2->pszCueName, pData1->pszCueName);
break;
case 2:
nRetVal = lstrcmp(pData2->pszTags, pData1->pszTags);
break;
default:
break;
}
return nRetVal;
}
int CALLBACK SortMeDescending(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
int nRetVal = 0;
PITEMDATA pData1 = (PITEMDATA)lParam1;
PITEMDATA pData2 = (PITEMDATA)lParam2;
switch(lParamSort)
{
case 0:
if(pData1->iSeq > pData2->iSeq)
nRetVal = -1;
else if(pData1->iSeq < pData2->iSeq)
nRetVal = 1;
else
nRetVal = 0;
break;
case 1:
nRetVal = lstrcmp(pData1->pszCueName, pData2->pszCueName);
break;
case 2:
nRetVal = lstrcmp(pData1->pszTags, pData2->pszTags);
break;
default:
break;
}
return nRetVal;
}
那是我的 OnCompareItems:
int CTest::OnCompareItems(LPARAM lParam1, LPARAM lParam2, int iColumn)
{
CMFCHeaderCtrl &headerCntrl = GetHeaderCtrl();
BOOL b = 0;
if(headerCntrl.IsAscending())
{
return SortItems(SortMeDescending, iColumn);
}
else
{
return SortItems(SortMeAscending, iColumn);
}
}
如果我关注这篇文章http://support.microsoft.com/kb/250614 我没有在标题中排序的箭头。如果我使用您在上面看到的方法,我会在排序方面遇到一些差距。我点击它排序,下次它不会排序,一次又一次,请帮助我