CDateTimeCtrl
-
I am responding to an DTN_DROPDOWN message from a CDateTimeCtrl in order to set the day states for the Month Calendar Control that appears when you click the dropdown button. I am using the following code to set the day states, where pCalCtrl is a pointer to the Calender Control that I obtained using CDateTimeCtrl::GetMonthCalCtrl(): pCalCtrl->SetDayState(nMonths,pStates); The problem is that I get the following line asserts from the SetDayState Function: ASSERT(GetStyle()&MCS_DAYSTATE); Why is this happening and how can I resolve it? Thanks
-
I am responding to an DTN_DROPDOWN message from a CDateTimeCtrl in order to set the day states for the Month Calendar Control that appears when you click the dropdown button. I am using the following code to set the day states, where pCalCtrl is a pointer to the Calender Control that I obtained using CDateTimeCtrl::GetMonthCalCtrl(): pCalCtrl->SetDayState(nMonths,pStates); The problem is that I get the following line asserts from the SetDayState Function: ASSERT(GetStyle()&MCS_DAYSTATE); Why is this happening and how can I resolve it? Thanks
sschilachi wrote: Why is this happening and how can I resolve it? The control does not have the
MCS_DAYSTATE
style, therefore setting the day states makes no sense.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
sschilachi wrote: Why is this happening and how can I resolve it? The control does not have the
MCS_DAYSTATE
style, therefore setting the day states makes no sense.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
How can I set the MCS_DAYSTATE flag, i have tried but i have had no luck?
-
How can I set the MCS_DAYSTATE flag, i have tried but i have had no luck?
void CMyDialog::OnClick( UINT uId, LPNMHDR, LRESULT * )
{
CDateTimeCtrl *pDateTimeCtrl;
CMonthCalCtrl *pMonthCalCtrl;pDateTimeCtrl = (CDateTimeCtrl \*) GetDlgItem(uId); pMonthCalCtrl = pDateTimeCtrl->GetMonthCalCtrl(); pMonthCalCtrl->ModifyStyle(0, MCS\_DAYSTATE); ...
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
How can I set the MCS_DAYSTATE flag, i have tried but i have had no luck?
I think this should work:
// Get handle to MonthCalendar control
HWND hwndDP = pCalCtrl->GetSafeHwnd();
ASSERT (hwndDP != NULL);
HWND hwndMC = DateTime_GetMonthCal (hwndDP);
ASSERT (hwndMC != NULL);
CWnd* pMCCtrl = CWnd::FromHandle (hwndMC);
ASSERT (pMCCtrl != NULL);// Set its style
DWORD dwStyle = pMCCtrl->GetStyle();
dwStyle |= MCS_DAYSTATE;
pMCCtrl->SetStyle (dwStyle);/ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com
-
I think this should work:
// Get handle to MonthCalendar control
HWND hwndDP = pCalCtrl->GetSafeHwnd();
ASSERT (hwndDP != NULL);
HWND hwndMC = DateTime_GetMonthCal (hwndDP);
ASSERT (hwndMC != NULL);
CWnd* pMCCtrl = CWnd::FromHandle (hwndMC);
ASSERT (pMCCtrl != NULL);// Set its style
DWORD dwStyle = pMCCtrl->GetStyle();
dwStyle |= MCS_DAYSTATE;
pMCCtrl->SetStyle (dwStyle);/ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com
-
The intent was to show every step in detail. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com
-
The intent was to show every step in detail. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com
-
pMCCtrl->SetStyle (dwStyle);
No such function as CWnd::SetStyle()
"No matter where you go, there your are." - Buckaroo Banzai
-pete
Gak! What was I thinking!? :-O Thank you! /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com
-
void CMyDialog::OnClick( UINT uId, LPNMHDR, LRESULT * )
{
CDateTimeCtrl *pDateTimeCtrl;
CMonthCalCtrl *pMonthCalCtrl;pDateTimeCtrl = (CDateTimeCtrl \*) GetDlgItem(uId); pMonthCalCtrl = pDateTimeCtrl->GetMonthCalCtrl(); pMonthCalCtrl->ModifyStyle(0, MCS\_DAYSTATE); ...
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
The Modify style returned true, but it did not work as the line still asserted. Can anyone find the code that creates the CMonthCalCtrl object when the dropdown button is clicked, because then I will create my own instance of CMonthCalCtrl, it is just I cannot find the code to mimic its behaviour? Thanks
-
void CMyDialog::OnClick( UINT uId, LPNMHDR, LRESULT * )
{
CDateTimeCtrl *pDateTimeCtrl;
CMonthCalCtrl *pMonthCalCtrl;pDateTimeCtrl = (CDateTimeCtrl \*) GetDlgItem(uId); pMonthCalCtrl = pDateTimeCtrl->GetMonthCalCtrl(); pMonthCalCtrl->ModifyStyle(0, MCS\_DAYSTATE); ...
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
I just checked the result of pMonthCalCtrl->GetStyle() before and after the use of the ModifyStyle function and the result is the same. (The ModifyStyle seems to be affecting the wrong style?) Thanks for all your help so far
-
void CMyDialog::OnClick( UINT uId, LPNMHDR, LRESULT * )
{
CDateTimeCtrl *pDateTimeCtrl;
CMonthCalCtrl *pMonthCalCtrl;pDateTimeCtrl = (CDateTimeCtrl \*) GetDlgItem(uId); pMonthCalCtrl = pDateTimeCtrl->GetMonthCalCtrl(); pMonthCalCtrl->ModifyStyle(0, MCS\_DAYSTATE); ...
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
I also tried ModifyStyleEx and that had no effect either.
-
The Modify style returned true, but it did not work as the line still asserted. Can anyone find the code that creates the CMonthCalCtrl object when the dropdown button is clicked, because then I will create my own instance of CMonthCalCtrl, it is just I cannot find the code to mimic its behaviour? Thanks
sschilachi wrote: Can anyone find the code that creates the CMonthCalCtrl object when the dropdown button is clicked... The code I provided was from a working project that does just that, except that it adds the
MCS_NOTODAY
style. Remember thatGetMonthCalCtrl()
will only return a pointer to the month calendar control while the control actually exists--that is, while it has been dropped-down by the user. Once it has been dismissed (e.g., selecting a date), the control does not actually exist.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
sschilachi wrote: Can anyone find the code that creates the CMonthCalCtrl object when the dropdown button is clicked... The code I provided was from a working project that does just that, except that it adds the
MCS_NOTODAY
style. Remember thatGetMonthCalCtrl()
will only return a pointer to the month calendar control while the control actually exists--that is, while it has been dropped-down by the user. Once it has been dismissed (e.g., selecting a date), the control does not actually exist.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
I know that, I am using the following code in an OnDtnDropdown() message handler for my own wrapper of the CTimeDateCtrl object that is an object in my own custom Toolbar:
CMonthCalCtrl* pCtrl = (CMonthCalCtrl*) GetMonthCalCtrl(); ASSERT(pCtrl != NULL); pCtrl->ModifyStyle(0, MCS_DAYSTATE); SYSTEMTIME timeFrom; SYSTEMTIME timeUntil; int nCount = pCtrl->GetMonthRange(&timeFrom, &timeUntil, GMR_DAYSTATE); LPMONTHDAYSTATE pDayState; pDayState = new MONTHDAYSTATE[nCount]; memset(pDayState, 0, sizeof(MONTHDAYSTATE) * nCount); int nIndex = (timeFrom.wDay == 1) ? 0 : 1; pDayState[nIndex] |= BIT4; pDayState[nIndex] |= BIT19; pDayState[nIndex] |= BIT25; pCtrl->SetDayState(nCount, pDayState); delete [] pDayState;
However when I call pCtrl->SetDayState(), it is there that the problem occurs and it directs me to the line that asserts that i previously mentioned. TheModifyStyle
function used in the third line seems to have no effect, as I checked the return value from pCtrl->GetStyle() before and after the call to ModifyStyle and the result was the same. By the code to create the CMonthCalCtrl I meant the code that is prewritten in the source code provided with Visual C++, not the code the user writes. Thanks -
I know that, I am using the following code in an OnDtnDropdown() message handler for my own wrapper of the CTimeDateCtrl object that is an object in my own custom Toolbar:
CMonthCalCtrl* pCtrl = (CMonthCalCtrl*) GetMonthCalCtrl(); ASSERT(pCtrl != NULL); pCtrl->ModifyStyle(0, MCS_DAYSTATE); SYSTEMTIME timeFrom; SYSTEMTIME timeUntil; int nCount = pCtrl->GetMonthRange(&timeFrom, &timeUntil, GMR_DAYSTATE); LPMONTHDAYSTATE pDayState; pDayState = new MONTHDAYSTATE[nCount]; memset(pDayState, 0, sizeof(MONTHDAYSTATE) * nCount); int nIndex = (timeFrom.wDay == 1) ? 0 : 1; pDayState[nIndex] |= BIT4; pDayState[nIndex] |= BIT19; pDayState[nIndex] |= BIT25; pCtrl->SetDayState(nCount, pDayState); delete [] pDayState;
However when I call pCtrl->SetDayState(), it is there that the problem occurs and it directs me to the line that asserts that i previously mentioned. TheModifyStyle
function used in the third line seems to have no effect, as I checked the return value from pCtrl->GetStyle() before and after the call to ModifyStyle and the result was the same. By the code to create the CMonthCalCtrl I meant the code that is prewritten in the source code provided with Visual C++, not the code the user writes. Thanksfrom MSDN
After creating the control, you can change all of the styles except for MCS_DAYSTATE and MCS_MULTISELECT. To change these styles, you will need to destroy the existing control and create a new one that has the desired styles. To retrieve or change any other window styles, use the GetWindowLong and SetWindowLong functions.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/monthcal/monthcal.asp[^]
"No matter where you go, there your are." - Buckaroo Banzai
-pete
-
from MSDN
After creating the control, you can change all of the styles except for MCS_DAYSTATE and MCS_MULTISELECT. To change these styles, you will need to destroy the existing control and create a new one that has the desired styles. To retrieve or change any other window styles, use the GetWindowLong and SetWindowLong functions.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/monthcal/monthcal.asp[^]
"No matter where you go, there your are." - Buckaroo Banzai
-pete
Thanks, I haven't got time to try that tonight but I will look at it tomorrow
-
from MSDN
After creating the control, you can change all of the styles except for MCS_DAYSTATE and MCS_MULTISELECT. To change these styles, you will need to destroy the existing control and create a new one that has the desired styles. To retrieve or change any other window styles, use the GetWindowLong and SetWindowLong functions.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/monthcal/monthcal.asp[^]
"No matter where you go, there your are." - Buckaroo Banzai
-pete
I have tried to destroy the control using pMonthCalCtrl->DestroyWindow() in response to the user clicking the dropdown button, however, I get an access violation when i run it, how do you destroy the MonthCalCtrl? Thanks
-
I have tried to destroy the control using pMonthCalCtrl->DestroyWindow() in response to the user clicking the dropdown button, however, I get an access violation when i run it, how do you destroy the MonthCalCtrl? Thanks
-
Did you ever fix this problem? I am having the same problem in getting bold dates up. If you managed to destroy and recreate the window and get the dates bold I would love to know how. Hope your still reading. Thanks Dave
No, I looked absolutely everywhere and tried just about everything but I eventually gave up as I couldn't find a solution anywhere. If I do have any success I will let you know, and could you do the same if you find a solution. Thanks
-
No, I looked absolutely everywhere and tried just about everything but I eventually gave up as I couldn't find a solution anywhere. If I do have any success I will let you know, and could you do the same if you find a solution. Thanks