Click here to Skip to main content
15,898,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to copy ClientDC to Memory Device Context? Pin
Vadim Tabakman14-Jun-04 19:28
Vadim Tabakman14-Jun-04 19:28 
GeneralSorting date with CListCtrl Pin
Mr Bose Dayala14-Jun-04 19:21
Mr Bose Dayala14-Jun-04 19:21 
GeneralRe: Sorting date with CListCtrl Pin
Vadim Tabakman14-Jun-04 19:36
Vadim Tabakman14-Jun-04 19:36 
GeneralRe: Sorting date with CListCtrl Pin
Mr Bose Dayala14-Jun-04 20:00
Mr Bose Dayala14-Jun-04 20:00 
GeneralRe: Sorting date with CListCtrl Pin
Vadim Tabakman14-Jun-04 20:29
Vadim Tabakman14-Jun-04 20:29 
GeneralRe: Sorting date with CListCtrl Pin
David Crow15-Jun-04 2:43
David Crow15-Jun-04 2:43 
GeneralRe: Sorting date with CListCtrl Pin
Mr Bose Dayala15-Jun-04 17:02
Mr Bose Dayala15-Jun-04 17:02 
GeneralRe: Sorting date with CListCtrl Pin
David Crow16-Jun-04 2:46
David Crow16-Jun-04 2:46 
A sorting algorithm either sorts or it doesn't. There is no "some."

How are you adding items to the list control? What parameters are you calling SetItemData() with? The 0.0 == dblResult comparison is obviously wrong. You should never compare double or float variables in this fashion. Hopefully you meant for the comparision to look like return ((0.0 < dblResult) ? 1 : ((dblResult < 0.0) ? -1 : 0)), but this will still lead to undesirable results, because dblResult will always be greater than or less than 0. A more elegant solution would be:

int CALLBACK CBoseDayalaNewListCtrl::CompareDates(LPARAM lParam1, LPARAM lParam2, LPARAM lSortParam)
{
CString *str1 = (CString*)(((ItemData*)lParam1)->dwItemData);
CString *str2 = (CString*)(((ItemData*)lParam2)->dwItemData);
CString *temp;
COleDateTime odtTime1;
COleDateTime odtTime2;
BOOL fSortAscending = BOOL(lSortParam);
int nResult = 0;

if (fSortAscending)
{
temp = str1;
str1 = str2;
str2 = temp;
}

TRACE("Comparing %s to %s\n", str1.Format("%c"), str2.Format("%c"));

odtTime1.ParseDateTime( str1, LOCALE_NOUSEROVERRIDE );
odtTime2.ParseDateTime( str2, LOCALE_NOUSEROVERRIDE );

if (odtTime1 < odtTime2)
nResult = -1;
else
nResult = 1;

return nResult;
}


"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen


GeneralTraversing the views Pin
Poorniselva14-Jun-04 18:43
Poorniselva14-Jun-04 18:43 
GeneralRe: Traversing the views Pin
Vadim Tabakman14-Jun-04 19:00
Vadim Tabakman14-Jun-04 19:00 
GeneralRe: Traversing the views Pin
Poorniselva14-Jun-04 19:40
Poorniselva14-Jun-04 19:40 
GeneralRe: Traversing the views Pin
V.15-Jun-04 2:23
professionalV.15-Jun-04 2:23 
QuestionHow to get memory info of a process not using PSAPI, thanks Pin
xingworld14-Jun-04 18:40
xingworld14-Jun-04 18:40 
AnswerRe: How to get memory info of a process not using PSAPI, thanks Pin
David Crow15-Jun-04 2:46
David Crow15-Jun-04 2:46 
AnswerRe: How to get memory info of a process not using PSAPI, thanks Pin
ThatsAlok16-Jun-04 1:46
ThatsAlok16-Jun-04 1:46 
GeneralSOS [about Genetic Algorithms] Pin
onetwone14-Jun-04 17:56
onetwone14-Jun-04 17:56 
GeneralRe: SOS [about Genetic Algorithms] Pin
Vadim Tabakman14-Jun-04 18:10
Vadim Tabakman14-Jun-04 18:10 
GeneralRe: SOS [about Genetic Algorithms] Pin
onetwone14-Jun-04 22:19
onetwone14-Jun-04 22:19 
Questionhow to get these Rect Area Pin
yingkou14-Jun-04 16:50
yingkou14-Jun-04 16:50 
AnswerRe: how to get these Rect Area Pin
Johan Rosengren14-Jun-04 20:53
Johan Rosengren14-Jun-04 20:53 
GeneralException handling - catch(...) Pin
Tom Archer14-Jun-04 16:40
Tom Archer14-Jun-04 16:40 
GeneralRe: Exception handling - catch(...) Pin
Johnny ²14-Jun-04 21:19
Johnny ²14-Jun-04 21:19 
GeneralRe: Exception handling - catch(...) Pin
V.14-Jun-04 21:45
professionalV.14-Jun-04 21:45 
GeneralRe: Exception handling - catch(...) Pin
toxcct14-Jun-04 22:11
toxcct14-Jun-04 22:11 
GeneralSending messages with ::PostMessage Pin
kfaday14-Jun-04 16:32
kfaday14-Jun-04 16:32 

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.