Click here to Skip to main content
16,009,114 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Using Server Idle Time Pin
Anders Molin14-Nov-01 14:22
professionalAnders Molin14-Nov-01 14:22 
GeneralInteraction Pin
Ever123414-Nov-01 9:26
Ever123414-Nov-01 9:26 
GeneralRe: Interaction Pin
Anders Molin14-Nov-01 14:26
professionalAnders Molin14-Nov-01 14:26 
GeneralRe: Interaction Pin
Mark Terrano16-Nov-01 11:55
Mark Terrano16-Nov-01 11:55 
GeneralStatusBar in a Dialog Pin
14-Nov-01 7:16
suss14-Nov-01 7:16 
GeneralCDC... I wan't the client area HOW TO Pin
Remi Morin14-Nov-01 5:38
Remi Morin14-Nov-01 5:38 
GeneralRe: CDC... I wan't the client area HOW TO Pin
14-Nov-01 7:13
suss14-Nov-01 7:13 
GeneralTIP: Problems comparing COleDateTime objects + COleDateTimeSpan accumulated errors Pin
14-Nov-01 5:28
suss14-Nov-01 5:28 
Hello,

[1]
I detected the following problem with the COleDateTime ==, <, >, <=, >= operators.
A COleDateTime object is internally represented by a double. So, when comparing two COleDateTime's it is in fact two doubles that are being compared and this means trouble.
I saw that 2 COleDateTime's that were perfectly equal (in human readable format) were indicated as not equal with the COleDateTime == operator.

Solution is to do the comparing yourself based on a stringcompare of the COleDateTimes.
These are the function's that I am using now.

BOOL DatesEqual(COleDateTime &odt1, COleDateTime &odt2)
{
  CString str1 = odt1.Format();
  CString str2 = odt2.Format();

  return (!str1.Compare(str2));
}

BOOL DateSmallerThan(COleDateTime &odt1, COleDateTime &odt2)
{
  if (DatesEqual(odt1, odt2)) return FALSE;
  else return odt1 < odt2;
}

BOOL DateGreaterThan(COleDateTime &odt1, COleDateTime &odt2)
{
  if (DatesEqual(odt1, odt2)) return FALSE;
  else return odt1 > odt2;
}

BOOL DateSmallerThanOrEqual(COleDateTime &odt1, COleDateTime &odt2)
{
  if (DatesEqual(odt1, odt2)) return TRUE;
  else return odt1 < odt2;
}

BOOL DateGreaterThanOrEqual(COleDateTime &odt1, COleDateTime &odt2)
{
  if (DatesEqual(odt1, odt2)) return TRUE;
  else return odt1 > odt2;
}


[2]
Another aid in programming more accurate when using COleDateTimeSpan's is the following.
Suppose you want to produce a sequence of 15 minute ColeDateTime's, starting at some point in time. Normally, one would program this something like:

COleDateTimeSpan span;
span = COleDateTimeSpan(0,0,15,0);
ColeDateTime StartTime, DateTimeWalker;
StartTime = ...; //init with the first moment
DateTimeWalker = StartTime;
for(int i=0; i<NR_OF_QUARTERS; i++)
{
  //do something with DateTimeWalker
  ...
  DateTimeWalker += span;
}


However, it is more accurate to replace the body of the loop by:
{
  COleDateTimeSpan dtsSpan(0,0,i*15,0);
  COleDateTime TimeToUse = StartTime + dtsSpan;
  //do something with TimeToUse
  ...
}

This way, no error is accumulated during the loop, resulting in an almost perfect value for the variable TimeToUse even for the last loop iteration.

Anyone (dis)agrees with this?
Other ideas?

Bye
Geert
GeneralRe: TIP: Problems comparing COleDateTime objects + COleDateTimeSpan accumulated errors Pin
Bill Wilson15-Nov-01 14:05
Bill Wilson15-Nov-01 14:05 
QuestionIs it possible to change style only of some region in dialog? Pin
14-Nov-01 5:22
suss14-Nov-01 5:22 
AnswerRe: I guess not Pin
Paolo Messina14-Nov-01 7:12
professionalPaolo Messina14-Nov-01 7:12 
AnswerRe: Is it possible to change style only of some region in dialog? Pin
Nish Nishant14-Nov-01 16:56
sitebuilderNish Nishant14-Nov-01 16:56 
GeneralRe: Is it possible to change style only of some region in dialog? Pin
14-Nov-01 22:24
suss14-Nov-01 22:24 
GeneralToolbar alignment ! Pin
Hadi Rezaee14-Nov-01 5:05
Hadi Rezaee14-Nov-01 5:05 
GeneralOPEN DIALOG BOX Pin
14-Nov-01 4:22
suss14-Nov-01 4:22 
GeneralRe: OPEN DIALOG BOX Pin
Roger Allen14-Nov-01 6:32
Roger Allen14-Nov-01 6:32 
GeneralRe: OPEN DIALOG BOX Pin
14-Nov-01 7:14
suss14-Nov-01 7:14 
Generalfread size problems Pin
Aviv Halperin14-Nov-01 3:22
Aviv Halperin14-Nov-01 3:22 
Generalfread size problems Pin
Aviv Halperin14-Nov-01 3:10
Aviv Halperin14-Nov-01 3:10 
GeneralRe: fread size problems Pin
Aviv Halperin14-Nov-01 3:18
Aviv Halperin14-Nov-01 3:18 
GeneralMulti-language application with resource DLL Pin
14-Nov-01 3:08
suss14-Nov-01 3:08 
Generalgetstyle Pin
confalonieri14-Nov-01 1:33
confalonieri14-Nov-01 1:33 
GeneralMulti Line List View Pin
13-Nov-01 23:23
suss13-Nov-01 23:23 
GeneralRe: Multi Line List View Pin
Nish Nishant13-Nov-01 23:58
sitebuilderNish Nishant13-Nov-01 23:58 
GeneralGrabbing contents of whole large window Pin
13-Nov-01 22:40
suss13-Nov-01 22:40 

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.