Hi,
I'm trying to retrieve the date in the first record in a recordset and set the date in CMonthCalCtrl object to the retrieved date. I'm using: TmpDlg.m_mcCal.GetToday(TmpSet.m_Date) but this line is causing a runtime error:
Any insight into what I'm missing
MPSoutine
The Error message
BOOL CMonthCalCtrl::GetToday(COleDateTime& refTime) const
{
ASSERT
:IsWindow(m_hWnd));
// can't use this method on multiple selection controls
ASSERT(!(GetStyle() & MCS_MULTISELECT));
SYSTEMTIME sysTime;
BOOL bResult = (BOOL)
::SendMessage(m_hWnd, MCM_GETTODAY, 0, (LPARAM) &sysTime);
if (bResult)
refTime = COleDateTime(sysTime);
return bResult;
}
This is the function I am using to try and display the retrieved date in the CMonthCalCtrl of a modal dialog box.
void CTimeDlg::OnBtnSettime()
{
//m_mcCal is the CMonthCalCtrl object in CDialogGetDate
//m_Date is a COleDateTime object in CTimeSet.
CDialogGetDate TmpDlg;
CTimeSet TmpSet;
COleDateTime TmpDate;
int nYear;
int nMonth;
int nDay;
TmpSet.m_strSort = "TimeID DESC";
//this will give us the first record in the recordset in descending order.
if(!TmpSet.IsOpen())
TmpSet.Open();
//How do we get the m_Date value from the recordset and set the m_mcCal to that date.
nDay = TmpSet.m_Date.GetDay();
nMonth = TmpSet.m_Date.GetMonth();
nYear = TmpSet.m_Date.GetYear();
CString strDate;
strDate.Format("The date is: %d/ %d/ %d ",nMonth,nDay,nYear);
AfxMessageBox(strDate);
TmpDlg.m_mcCal.GetToday(TmpSet.m_Date);
TmpDlg.DoModal();
}
I'm trying to retrieve the date in the first record in a recordset and set the date in CMonthCalCtrl object to the retrieved date. I'm using: TmpDlg.m_mcCal.GetToday(TmpSet.m_Date) but this line is causing a runtime error:
Any insight into what I'm missing
MPSoutine
The Error message
BOOL CMonthCalCtrl::GetToday(COleDateTime& refTime) const
{
ASSERT
// can't use this method on multiple selection controls
ASSERT(!(GetStyle() & MCS_MULTISELECT));
SYSTEMTIME sysTime;
BOOL bResult = (BOOL)
::SendMessage(m_hWnd, MCM_GETTODAY, 0, (LPARAM) &sysTime);
if (bResult)
refTime = COleDateTime(sysTime);
return bResult;
}
This is the function I am using to try and display the retrieved date in the CMonthCalCtrl of a modal dialog box.
void CTimeDlg::OnBtnSettime()
{
//m_mcCal is the CMonthCalCtrl object in CDialogGetDate
//m_Date is a COleDateTime object in CTimeSet.
CDialogGetDate TmpDlg;
CTimeSet TmpSet;
COleDateTime TmpDate;
int nYear;
int nMonth;
int nDay;
TmpSet.m_strSort = "TimeID DESC";
//this will give us the first record in the recordset in descending order.
if(!TmpSet.IsOpen())
TmpSet.Open();
//How do we get the m_Date value from the recordset and set the m_mcCal to that date.
nDay = TmpSet.m_Date.GetDay();
nMonth = TmpSet.m_Date.GetMonth();
nYear = TmpSet.m_Date.GetYear();
CString strDate;
strDate.Format("The date is: %d/ %d/ %d ",nMonth,nDay,nYear);
AfxMessageBox(strDate);
TmpDlg.m_mcCal.GetToday(TmpSet.m_Date);
TmpDlg.DoModal();
}