L
LT
Hello,
I have the following problem. I'm using the CMonthCalCtrl calendar
control. I need to emphasize some of days, so I'm handling the
MCN_GETDAYSTATE event. The problem is when my handler function is
called for the first time during initializing of the application. When
I'm calling the CMonthCalCtrl::GetMonthRange method there is an
assertion error inside that method: ASSERT:IsWindow(m_hWnd));
It seems that my event handler is called before creating a window
handle of the calendar control (when after initializing, there is no
error).
To solve this problem I would call my event handler
OnMcnGetdaystateMonthcalendar2(NMHDR *pNMHDR, LRESULT *pResult) by
hand after the initialization but I don't know what to write as
parameters pNMHDR, pResult. Besides, I don't know if that idea is
appropriate or not.
Has anybody any idea? Maybe although something about how MFC controls
are initialized (I'm newbie in VC++)
There is a bit of code:
void CqweDlg::OnMcnGetdaystateMonthcalendar2(NMHDR *pNMHDR, LRESULT
*pResult)
{
LPNMDAYSTATE pDayState = reinterpret_cast<LPNMDAYSTATE>(pNMHDR);
SYSTEMTIME timeFrom;
SYSTEMTIME timeUntil;
SYSTEMTIME timeDay;
timeDay.wDay = 28;
timeDay.wMonth = 7;
timeDay.wYear = 2004;
nCount = Calendar.GetMonthRange(&timeFrom, &timeUntil,
GMR_DAYSTATE);//inside this line there is an assertion error!!!
memset(states,0x00, sizeof(MONTHDAYSTATE)*nCount);
int iDay, iFrom, iUntil;
iDay = timeDay.wYear * 10000 + timeDay.wMonth * 100 + timeDay.wDay;
iFrom = timeFrom.wYear * 10000 + timeFrom.wMonth * 100 +
timeFrom.wDay;
iUntil = timeUntil.wYear * 10000 + timeUntil.wMonth * 100 +
timeUntil.wDay;
if ( iDay >= iFrom && iDay <= iUntil )
{
int index = timeDay.wMonth - timeFrom.wMonth;
if (index<0) index+=12;
states[index] |= 1<< (timeDay.wDay - 1);//emphasize
}
memcpy(pDayState->prgDayState, states,
nCount*sizeof(MONTHDAYSTATE));//copy
*pResult = 0;
}
Lt
I have the following problem. I'm using the CMonthCalCtrl calendar
control. I need to emphasize some of days, so I'm handling the
MCN_GETDAYSTATE event. The problem is when my handler function is
called for the first time during initializing of the application. When
I'm calling the CMonthCalCtrl::GetMonthRange method there is an
assertion error inside that method: ASSERT:IsWindow(m_hWnd));
It seems that my event handler is called before creating a window
handle of the calendar control (when after initializing, there is no
error).
To solve this problem I would call my event handler
OnMcnGetdaystateMonthcalendar2(NMHDR *pNMHDR, LRESULT *pResult) by
hand after the initialization but I don't know what to write as
parameters pNMHDR, pResult. Besides, I don't know if that idea is
appropriate or not.
Has anybody any idea? Maybe although something about how MFC controls
are initialized (I'm newbie in VC++)
There is a bit of code:
void CqweDlg::OnMcnGetdaystateMonthcalendar2(NMHDR *pNMHDR, LRESULT
*pResult)
{
LPNMDAYSTATE pDayState = reinterpret_cast<LPNMDAYSTATE>(pNMHDR);
SYSTEMTIME timeFrom;
SYSTEMTIME timeUntil;
SYSTEMTIME timeDay;
timeDay.wDay = 28;
timeDay.wMonth = 7;
timeDay.wYear = 2004;
nCount = Calendar.GetMonthRange(&timeFrom, &timeUntil,
GMR_DAYSTATE);//inside this line there is an assertion error!!!
memset(states,0x00, sizeof(MONTHDAYSTATE)*nCount);
int iDay, iFrom, iUntil;
iDay = timeDay.wYear * 10000 + timeDay.wMonth * 100 + timeDay.wDay;
iFrom = timeFrom.wYear * 10000 + timeFrom.wMonth * 100 +
timeFrom.wDay;
iUntil = timeUntil.wYear * 10000 + timeUntil.wMonth * 100 +
timeUntil.wDay;
if ( iDay >= iFrom && iDay <= iUntil )
{
int index = timeDay.wMonth - timeFrom.wMonth;
if (index<0) index+=12;
states[index] |= 1<< (timeDay.wDay - 1);//emphasize
}
memcpy(pDayState->prgDayState, states,
nCount*sizeof(MONTHDAYSTATE));//copy
*pResult = 0;
}
Lt