📄 sortlistctrl.cpp
字号:
// SortListCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "simulate.h"
#include "SortListCtrl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSortListCtrl
CSortListCtrl::CSortListCtrl()
{
}
CSortListCtrl::~CSortListCtrl()
{
}
BEGIN_MESSAGE_MAP(CSortListCtrl, CListCtrl)
//{{AFX_MSG_MAP(CSortListCtrl)
ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnclick)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSortListCtrl message handlers
void CSortListCtrl::Sort(DWORD dwSub)
{
/* static DWORD LastSort;
//相同翻转
if(dwSub == LastSort)
{
m_Revert *= -1;
}
else
{
LastSort = dwSub;
m_Revert = 1;
}
m_pThis = this;
SortItems( (PFNLVCOMPARE)CompareFunc, dwSub );
TRACE("Sort By Sub %d\n", dwSub); */
}
//排序回调函数
int CALLBACK CSortListCtrl::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
/*
The comparison function must return a negative value
if the first item should precede the second, a positive
value if the first item should follow the second, or
zero if the two items are equivalent.
*/
/* if((lParamSort == 0) || (m_pThis == NULL))
{
if (lParam1 > lParam2)
return -m_Revert;
else
return m_Revert;
}
int nItem1, nItem2;
LVFINDINFO FindInfo;
FindInfo.flags = LVFI_PARAM;
FindInfo.lParam = lParam1;
nItem1 = m_pThis->FindItem(&FindInfo, -1);
FindInfo.lParam = lParam2;
nItem2 = m_pThis->FindItem(&FindInfo, -1);
if((nItem1 == -1) || (nItem2 == -1))
{
TRACE("无法找到!\n");
return 0;
}
CString Str1,Str2;
Str1 = m_pThis->GetItemText(nItem1, lParamSort);
Str2 = m_pThis->GetItemText(nItem2, lParamSort);
if(Str1 > Str2)
return -m_Revert;
else if(Str1 == Str2)
return 0;
else
return m_Revert; */
return 0;
}
void CSortListCtrl::OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -