CDateTimeCtrl
-
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
-
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
Well I worked around it so that I can use it the way I want!:-D:-D:-D Basically I added an invisible Month Calendar control which I then set to the same space as the DateTimePickers rect in the DropDown handler. I also set a flag for bMonthShowing. In the OnPaint method I use the bMonthShowing flag to let me know to reposition the windows m_pMonth->SetWindowPos(&wndNoTopMost, 0, 0, 1, 1, SWP_NOMOVE | SWP_SHOWWINDOW); m_ctlMonth.SetWindowPos(&wndTopMost, 0, 0, 1, 1, SWP_NOMOVE | SWP_SHOWWINDOW); In the CloseUp handler I set the MonthCalendar invisible. For the month calendar I handle the GetDayStates to set which days I want bold. In the OnSelect for the month calendar I do the following: COleDateTime t; SYSTEMTIME tt; BOOL ret = m_ctlMonth.GetCurSel(&tt); t.SetDate(tt.wYear, tt.wMonth, tt.wDay); m_ctlDatePicker.SetTime(t); (If I did the GetCurSel directly into a COleDateTime it comes back with an invalid status :confused: ) And everything works! All right I missed one or two (or more) things. oops What a kludge! If you want I can send you the whole dialog project. Let me know. Dave