Is there a way to disable the left click date selection in the CMonthCalCtrl? I want to display a one month calendar but do not need to be able to select days.
Thanks in advance,
Hal
up·grade (up'gräd'),
to take out old bugs
and put in new ones.
Create your own MonthCal class derived from CMonthCalCtrl and handle the WM_LBUTTONDOWN/UP message. See this// header
class CMyMonthCal : public CMonthCalCtrl
{
// Construction
public:
CMyMonthCal();
Now put a MonthCal resource on your dialog (for example) and add a member variable of Control type. Instead using the default CMonthCalCtrl class put CMyMonthCal. Then left button message are disabled.
Thanks for the reply. It does disable the day selection as I want, but I can no longer select another month. Can the WPARAM or LPARAM be used to determine if the click was in the calendar or in the title bar?
Regards,
Hal
up·grade (up'gräd'),
to take out old bugs
and put in new ones.
Two more questions if you don't mind. Now that we have disabled the date selection I would like to know if there is a way to get the control to not display the current date highlighted (not the today circle but the blue oval around the current day). When I change months the same day is highlighed on the new month.
The second question is how can I intercept key presses so I can make the HOME and CTRL-HOME keys return the calendar to the current month. I added a check for the WM_KEYDOWN message in the WindowProc but that did not work.
Thanks again for the help with the previous problem,
Hal
up·grade (up'gräd'),
to take out old bugs
and put in new ones.
For 'not the today circle but the blue oval around the current day' turn off the No Today Circle property from resource or usebRet = m_MyMonthCal.ModifyStyle(0, MCS_NOTODAYCIRCLE);
TRACE("bRet = %d\n", bRet);
Now regarding catching the WM_KEYDOWN message all you have to do is to set the focus on your month calendarm_MyMonthCal.SetFocus();
//
LRESULT CMyMonthCal::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_KEYDOWN)
TRACE("WM_KEYDOWN in CMyMonthCal::WindowProc\n");
I added the SetFocus() to the OnInitDialog function of the dialog that owns the calendar and added the test for WM_KEYDOWN in the calendar's WindowProc and set a breakpoint on the if statement but it never gets control. Here's the function:
LRESULT CCalendar::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if ((message == WM_LBUTTONDOWN) || (message == WM_LBUTTONUP))
{
int xPos = LOWORD(lParam);
int yPos = HIWORD(lParam);
TRACE("xPos = %d, yPos = %d\n", xPos, yPos);
if (yPos > GetSystemMetrics(SM_CYSIZE))
return 1;
}
if (message == WM_KEYDOWN)
TRACE("WM_KEYDOWN in CCalendar:::WindowProc\n");
return CMonthCalCtrl::WindowProc(message, wParam, lParam);
I also clicked in the calendar to make sure it had the focus.
-----
Regarding the blue oval around the current date, I guess my explanation of what I want to do was confussing. I was afraid that you might think I was referring to the red today circle. What I am trying to do is to remove the blue oval that initially highlights the current day and moves when a new date is selected (not the red today circle). Being that I have disabled the ability to select dates, I thought it would be nice if I could get rid of the highlight.
Sorry for the confusion. Regards,
Hal
up·grade (up'gräd'),
to take out old bugs
and put in new ones.
Bookmarks