A timely fix
-
So it's 4:00am and I'm spending the last few minutes of my wake cycle to add some prettiness to my GUI. The underlying code works, it's fast, and things are looking good. So before I call it a night (or day), I figure why not add a "Reset" button to reset the time interval (specified by a pair of
CDateTimeCtrl
s) in the GUI. Clicking "Reset" is supposed to set the time interval to (365-days-ago to today). Easy enough. Wiping the last few crumbs of a ham sandwich from my face, I start typing furiously.void CMyDlg::OnBnClickedResetInterval()
{
// Compute interval
CTime tmZero = 0;
CTime tmEnd = CTime::GetCurrentTime();
CTimeSpan tmTimeInterval (365, 0, 0, 0);
CTime tmStart = tmEnd - tmTimeInterval;// Set "Start" date selector
CString strFormat = "dd MMM yyyy";
m_dtCtrlStart.SetFormat (strFormat);
VERIFY (m_dtCtrlStart.SetTime (&tmStart));
VERIFY (m_dtCtrlStart.SetRange (&tmZero, &tmEnd));// Set "End" date selector
m_dtCtrlEnd.SetFormat (strFormat);
VERIFY (m_dtCtrlEnd.SetTime (&tmEnd));
VERIFY (m_dtCtrlEnd.SetRange (&tmZero, &tmEnd));
}Of course it works. Once. :) The fix is easy, but it took a few hours of zzz's and a cuppa joe to see it. Good grief - it's almost lunch time. Time for a ham sandwich... /ravi
This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com
-
So it's 4:00am and I'm spending the last few minutes of my wake cycle to add some prettiness to my GUI. The underlying code works, it's fast, and things are looking good. So before I call it a night (or day), I figure why not add a "Reset" button to reset the time interval (specified by a pair of
CDateTimeCtrl
s) in the GUI. Clicking "Reset" is supposed to set the time interval to (365-days-ago to today). Easy enough. Wiping the last few crumbs of a ham sandwich from my face, I start typing furiously.void CMyDlg::OnBnClickedResetInterval()
{
// Compute interval
CTime tmZero = 0;
CTime tmEnd = CTime::GetCurrentTime();
CTimeSpan tmTimeInterval (365, 0, 0, 0);
CTime tmStart = tmEnd - tmTimeInterval;// Set "Start" date selector
CString strFormat = "dd MMM yyyy";
m_dtCtrlStart.SetFormat (strFormat);
VERIFY (m_dtCtrlStart.SetTime (&tmStart));
VERIFY (m_dtCtrlStart.SetRange (&tmZero, &tmEnd));// Set "End" date selector
m_dtCtrlEnd.SetFormat (strFormat);
VERIFY (m_dtCtrlEnd.SetTime (&tmEnd));
VERIFY (m_dtCtrlEnd.SetRange (&tmZero, &tmEnd));
}Of course it works. Once. :) The fix is easy, but it took a few hours of zzz's and a cuppa joe to see it. Good grief - it's almost lunch time. Time for a ham sandwich... /ravi
This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com
// Set "End" date selector
m_dtCtrlEnd.SetFormat (strFormat);
VERIFY (m_dtCtrlEnd.SetTime (&tmEnd));
VERIFY (m_dtCtrlEnd.SetRange (&tmZero, &tmEnd));
CTime tmEndOfToday (tmEnd.GetYear(), tmEnd.GetMonth(), tmEnd.GetDay(), 23, 59, 59); VERIFY (m_dtCtrlEnd.SetRange (&tmZero, &tmEndOfToday));
Urp. /ravi
This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com
-
So it's 4:00am and I'm spending the last few minutes of my wake cycle to add some prettiness to my GUI. The underlying code works, it's fast, and things are looking good. So before I call it a night (or day), I figure why not add a "Reset" button to reset the time interval (specified by a pair of
CDateTimeCtrl
s) in the GUI. Clicking "Reset" is supposed to set the time interval to (365-days-ago to today). Easy enough. Wiping the last few crumbs of a ham sandwich from my face, I start typing furiously.void CMyDlg::OnBnClickedResetInterval()
{
// Compute interval
CTime tmZero = 0;
CTime tmEnd = CTime::GetCurrentTime();
CTimeSpan tmTimeInterval (365, 0, 0, 0);
CTime tmStart = tmEnd - tmTimeInterval;// Set "Start" date selector
CString strFormat = "dd MMM yyyy";
m_dtCtrlStart.SetFormat (strFormat);
VERIFY (m_dtCtrlStart.SetTime (&tmStart));
VERIFY (m_dtCtrlStart.SetRange (&tmZero, &tmEnd));// Set "End" date selector
m_dtCtrlEnd.SetFormat (strFormat);
VERIFY (m_dtCtrlEnd.SetTime (&tmEnd));
VERIFY (m_dtCtrlEnd.SetRange (&tmZero, &tmEnd));
}Of course it works. Once. :) The fix is easy, but it took a few hours of zzz's and a cuppa joe to see it. Good grief - it's almost lunch time. Time for a ham sandwich... /ravi
This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com