Click here to Skip to main content
15,896,552 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: List Control Pin
David Crow30-Apr-04 7:59
David Crow30-Apr-04 7:59 
GeneralRe: List Control Pin
aman200630-Apr-04 8:06
aman200630-Apr-04 8:06 
GeneralRe: List Control Pin
David Crow30-Apr-04 8:12
David Crow30-Apr-04 8:12 
GeneralRe: List Control Pin
aman200630-Apr-04 8:33
aman200630-Apr-04 8:33 
GeneralRe: List Control Pin
David Crow30-Apr-04 8:41
David Crow30-Apr-04 8:41 
GeneralRe: List Control Pin
aman200630-Apr-04 8:45
aman200630-Apr-04 8:45 
GeneralRe: List Control Pin
David Crow30-Apr-04 9:50
David Crow30-Apr-04 9:50 
GeneralRe: List Control Pin
aman200630-Apr-04 10:42
aman200630-Apr-04 10:42 
Here u go:

typedef struct _tagSORTDATA
{
INT isortSubItem;
CListCtrl *m_pointer;
INT iUPDOWN;
BOOL StringComp;
} SORTDATA;
enum{
eSORT_UP = 1,
eSORT_DOWN
};
void CEditForm::OnColumnclickHistoryList(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
static WORD nSort;
SORTDATA sortData;

m_RecordList =(CListCtrl*)GetDlgItem(IDC_HISTORY_LIST);


if(nSort == eSORT_UP)
nSort = eSORT_DOWN;
else
nSort = eSORT_UP;

sortData.isortSubItem = pNMListView->iSubItem;
sortData.iUPDOWN = nSort;
sortData.m_pointer = (CListCtrl*)m_RecordList;
sortData.StringComp = TRUE;
if(m_RecordList->SortItems(ListViewCompProc, (DWORD)(LPARAM)&sortData) != TRUE)
AfxMessageBox(_T("Error"));


*pResult = 0;
}


int CALLBACK CEditForm::ListViewCompProc(LPARAM lp1, LPARAM lp2, LPARAM lp3)
{
static LVFINDINFO lvf;
static INT nItem1, nItem2;
CString buf1, buf2;




SORTDATA *lpsd;

lpsd = (SORTDATA *)lp3;
CListCtrl *m_RecordList = (CListCtrl*)lpsd->m_pointer;

lvf.flags = LVFI_PARAM;
lvf.lParam = lp1;
// nItem1 = ListView_FindItem(lpsd->hwndList, -1, &lvf);
nItem1 = m_RecordList->FindItem(&lvf);

lvf.lParam = lp2;
//nItem2 = ListView_FindItem(lpsd->hwndList, -1, &lvf);
nItem2 = m_RecordList->FindItem(&lvf);

//ListView_GetItemText(lpsd->hwndList, nItem1, lpsd->isortSubItem, buf1, sizeof(buf1));
buf1 = m_RecordList->GetItemText(nItem1,lpsd->isortSubItem);
//ListView_GetItemText(lpsd->hwndList, nItem2, lpsd->isortSubItem, buf2, sizeof(buf2));
buf2 = m_RecordList->GetItemText(nItem2,lpsd->isortSubItem);

if (lpsd->isortSubItem != 9)
{
// string comparision
if (lpsd->iUPDOWN == eSORT_UP)
{
return(buf1.Compare(buf2));
}
else
{
return(buf1.Compare(buf2) * -1);
}
}
else
{
// digit comparision
if (lpsd->iUPDOWN == eSORT_UP)
{
if (_ttoi(buf1) > _ttoi(buf2))
return 1;
else if (_ttoi(buf1) == _ttoi(buf2))
return 0;
else
return -1;
}
else
{
if (_ttoi(buf1) > _ttoi(buf2))
return -1;
else if (_ttoi(buf1) == _ttoi(buf2))
return 0;
else
return 1;
}
}
return 0;
}


GeneralRe: List Control Pin
David Crow30-Apr-04 10:53
David Crow30-Apr-04 10:53 
GeneralConsole Application Pin
maxpayne30-Apr-04 6:44
maxpayne30-Apr-04 6:44 
GeneralRe: Console Application Pin
Navin30-Apr-04 7:29
Navin30-Apr-04 7:29 
QuestionHow can i pass MFC pointers to non MFC DLL's? Pin
Jobby Joseph30-Apr-04 6:38
Jobby Joseph30-Apr-04 6:38 
AnswerRe: How can i pass MFC pointers to non MFC DLL's? Pin
David Crow30-Apr-04 6:41
David Crow30-Apr-04 6:41 
Questionprogramatically click a button on a HTML? Pin
Ehsan Baghaki30-Apr-04 5:34
Ehsan Baghaki30-Apr-04 5:34 
AnswerRe: programatically click a button on a HTML? Pin
David Crow30-Apr-04 6:49
David Crow30-Apr-04 6:49 
GeneralRe: programatically click a button on a HTML? Pin
Ehsan Baghaki30-Apr-04 7:01
Ehsan Baghaki30-Apr-04 7:01 
AnswerRe: programatically click a button on a HTML? Pin
Jason Henderson30-Apr-04 9:27
Jason Henderson30-Apr-04 9:27 
GeneralQuick style question Pin
Nitron30-Apr-04 5:27
Nitron30-Apr-04 5:27 
GeneralRe: Quick style question Pin
jmkhael30-Apr-04 6:16
jmkhael30-Apr-04 6:16 
GeneralInternet Explorer style combo box Pin
jason9930-Apr-04 4:12
jason9930-Apr-04 4:12 
GeneralRe: Internet Explorer style combo box Pin
Michael Dunn30-Apr-04 4:26
sitebuilderMichael Dunn30-Apr-04 4:26 
GeneralRe: Internet Explorer style combo box Pin
David Crow30-Apr-04 6:44
David Crow30-Apr-04 6:44 
GeneralList Control with buttons Pin
prcarp30-Apr-04 3:52
prcarp30-Apr-04 3:52 
GeneralRunning SQL Server Script from code Pin
Vadim Tabakman30-Apr-04 3:22
Vadim Tabakman30-Apr-04 3:22 
GeneralRe: Running SQL Server Script from code Pin
Blake Miller30-Apr-04 6:01
Blake Miller30-Apr-04 6:01 

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.