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
LVL 12
gbzhhuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mikeblasCommented:
1) It's doing that because your low limit value is higher than your high limit value. Such a setting makes the control work upside-down. Also, note that the default setting for the control is for the low value to be 100 and the high value to be zero.  You need to call SetRange() or SetRange32() on the object.

2) See this code:

int nSeconds = 193;
CString str;
str.Format("%d minutes, %d seconds", nSeconds / 60, nSeconds % 60);


And that's that.

..B ekiM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ernest022699Commented:
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.
0
gbzhhuAuthor Commented:
mikeblas,

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

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;
}
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.