Link to home
Start Free TrialLog in
Avatar of gbzhhu
gbzhhuFlag for United Kingdom of Great Britain and Northern Ireland

asked on

two simple questions

I have two simple questions:

1.  I have two spin controls.  One of them works fine, the other also works OK except when you click the down arrow the value goes up and when you click the up arrow the value goes down.  It should be doing the other way round and I don't know why it is doing this.

2. I have a CString variable str1 and int variable int1.  int 1 contains say 193.  The 193 is seconds and I would like convert this to minutes so that it becomes 3 minutes and 13 seconds. then I want str1 to display "time remainig: 3 minutes and 13 second" just like when you download things.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of mikeblas
mikeblas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ernest022699
Ernest022699

Well done, mikeblas.  Personally, I do not want to see "minutes" displayed unless they are non-zero.  (And I'd really like to see one minute as "1 minute" rather than "1 minutes".)  But I'm really picky.
Avatar of gbzhhu

ASKER

mikeblas,

I agree with ernest, but your answer will do me fine.  thanks.

Getting rid of "minutes" if they're zero is trivial.

CString FormatRemainingSeconds(int nTime)
{
   ASSERT(nTime > 0);
   CString strReturn;
   int nSeconds = nTime % 60;
   int nMinutes = nTime / 60;

   if (nMinutes > 0)
   {
      strReturn.Format("%d minute%s, ", nMinutes,
         (nMinutes == 1) ? "" : "s");
   }

   CString strTemp;
   strTemp.Format("%d second%s remaining", nSeconds,
      (nSeconds == 1) ? "" : "s");

   strReturn += strTemp;
   return strReturn;
}