Click here to Skip to main content
16,004,944 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralLoading dll:s from a dll Pin
Member 190142122-Apr-05 2:58
Member 190142122-Apr-05 2:58 
GeneralRe: Loading dll:s from a dll Pin
Peter Ritchie23-Apr-05 9:00
Peter Ritchie23-Apr-05 9:00 
GeneralRe: Loading dll:s from a dll Pin
Member 190142124-Apr-05 8:17
Member 190142124-Apr-05 8:17 
QuestionStack or heap pointer? Pin
Bob Stanneveld22-Apr-05 2:56
Bob Stanneveld22-Apr-05 2:56 
AnswerRe: Stack or heap pointer? Pin
James R. Twine22-Apr-05 3:45
James R. Twine22-Apr-05 3:45 
GeneralRe: Stack or heap pointer? Pin
Bob Stanneveld24-Apr-05 20:26
Bob Stanneveld24-Apr-05 20:26 
AnswerRe: Stack or heap pointer? Pin
22491722-Apr-05 7:44
22491722-Apr-05 7:44 
GeneralListCtrl Won't Sort - Help ! Pin
Jethro6322-Apr-05 2:45
Jethro6322-Apr-05 2:45 
Hi:

I am trying to write an extended ListCtrl class for my own use and as a self-learning exercise. I have a perplexing problem here and I have tried to reduce it to the simplest of possible terms.

The two key code segments are as follows:

A button handler which requests that the list box items be sorted:

void CReportWiseDlg::OnSortBtn()
{
m_nrcDemo.SetRedraw( FALSE );
m_nrcDemo.SortItems( TempCmpFunc, (LPARAM)&m_nrcDemo );
m_nrcDemo.SetRedraw( TRUE );
}

And the CALLBACK function that provides the compare operation. In this case, I wanted to sort by column two which contains floating point values (which I have to convert, of course):

int CALLBACK TempCmpFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
CNiceReportCtrl* pListCtrl = (CNiceReportCtrl *)lParamSort;
CString strItem1, strItem2;
int nItem1, nItem2;

nItem1 = (int)lParam1;
nItem2 = (int)lParam2;

strItem1 = pListCtrl->GetItemText(nItem1, 2);
strItem2 = pListCtrl->GetItemText(nItem2, 2);

double f1, f2;
f1 = atof( (LPCTSTR)strItem1 );
f2 = atof( (LPCTSTR)strItem2 );

if (f1 < f2)
return 1;
else if (f1 > f2)
return -1;
else
return 0;
}

Now, when I click my sort button, I can see my OnSortBtn routine get called. Furthermore, I can see my CALLBACK function getting called several times. For a List box with 8 rows, I counted 13 calls to my CALLBACK. The problem is that every single time the CALLBACK is called, the lParam1 and lParam2 input parameters are ALWAYS equal to ZERO. The net result of this is that the list does not get sorted. It stays exactly the same.

I just followed the example code provided on the MSDN disks for CListCtrl::SortItems. It all looked pretty straight-forward.

Can anybody suggest what might be going on?

Thank you in advance for your help.
Mark
GeneralRe: ListCtrl Won't Sort - Help ! Pin
Stlan22-Apr-05 3:49
Stlan22-Apr-05 3:49 
GeneralRe: ListCtrl Won't Sort - Help ! Pin
David Crow22-Apr-05 8:02
David Crow22-Apr-05 8:02 
QuestionChat - Using Threads? Pin
DKT_22-Apr-05 2:12
DKT_22-Apr-05 2:12 
AnswerRe: Chat - Using Threads? Pin
Jack Puppy22-Apr-05 2:36
Jack Puppy22-Apr-05 2:36 
GeneralRe: Chat - Using Threads? Pin
Anonymous22-Apr-05 2:45
Anonymous22-Apr-05 2:45 
AnswerRe: Chat - Using Threads? Pin
ThatsAlok22-Apr-05 2:38
ThatsAlok22-Apr-05 2:38 
GeneralRe: Chat - Using Threads? Pin
Anonymous22-Apr-05 2:47
Anonymous22-Apr-05 2:47 
GeneralRe: Chat - Using Threads? Pin
Bob Stanneveld22-Apr-05 2:53
Bob Stanneveld22-Apr-05 2:53 
GeneralRe: Chat - Using Threads? Pin
Anonymous22-Apr-05 3:02
Anonymous22-Apr-05 3:02 
GeneralRe: Chat - Using Threads? Pin
Bob Stanneveld22-Apr-05 3:41
Bob Stanneveld22-Apr-05 3:41 
GeneralRe: Chat - Using Threads? Pin
Anonymous25-Apr-05 0:18
Anonymous25-Apr-05 0:18 
GeneralRe: Chat - Using Threads? Pin
Bob Stanneveld25-Apr-05 4:40
Bob Stanneveld25-Apr-05 4:40 
GeneralRe: Chat - Using Threads? Pin
DKT_25-Apr-05 8:46
DKT_25-Apr-05 8:46 
GeneralText display on a vertical tab control with owner draw enabled Pin
Asha Udupa22-Apr-05 1:06
Asha Udupa22-Apr-05 1:06 
GeneralRe: Text display on a vertical tab control with owner draw enabled Pin
Ravi Bhavnani22-Apr-05 11:50
professionalRavi Bhavnani22-Apr-05 11:50 
GeneralRe: Text display on a vertical tab control with owner draw enabled Pin
Asha Udupa24-Apr-05 19:56
Asha Udupa24-Apr-05 19:56 
GeneralRe: Text display on a vertical tab control with owner draw enabled Pin
Ravi Bhavnani25-Apr-05 2:01
professionalRavi Bhavnani25-Apr-05 2: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.