SftDate_HitTest returns what is at a location of a control, in client coordinates, in a SFTDATE_HITTEST structure. Its area member tells what is at the location; for a calendar, fHasDate and date return the date there.
For an SftDate control, area is one of these values:
| Value | Location |
|---|---|
| SFTDATE_FIELDHIT_NOWHERE | Outside the field. |
| SFTDATE_FIELDHIT_SEGMENT | A part of the value that can be edited. |
| SFTDATE_FIELDHIT_TEXT | The text area outside a part, the text box of a field with free-form editing, or the text area of an empty field. |
| SFTDATE_FIELDHIT_CHECKBOX | The check box. |
| SFTDATE_FIELDHIT_CLEARBUTTON | The Clear button. |
| SFTDATE_FIELDHIT_DROPDOWNBUTTON | The dropdown button. |
| SFTDATE_FIELDHIT_UPBUTTON, SFTDATE_FIELDHIT_DOWNBUTTON | The up and down buttons. |
The dropdown is a window of its own and is not part of the field's client area.
For an SftCalendar control, area is one of these values:
| Value | Location |
|---|---|
| SFTDATE_CALHIT_NOWHERE | Outside the calendar. |
| SFTDATE_CALHIT_BACKGROUND | The background, outside the other parts. |
| SFTDATE_CALHIT_TITLE | The title of a month, a year, a decade or a century; date is the first date of the period. |
| SFTDATE_CALHIT_PREVIOUSBUTTON, SFTDATE_CALHIT_NEXTBUTTON | The previous and next buttons. |
| SFTDATE_CALHIT_DAYOFWEEK | The name of a day of the week. |
| SFTDATE_CALHIT_WEEKNUMBER | A week number; date is the first date of the week's row. |
| SFTDATE_CALHIT_DAY | A day of a month; date is the day. |
| SFTDATE_CALHIT_TRAILINGDAY | A day of the previous or next month; date is the day. |
| SFTDATE_CALHIT_PERIOD | A month, a year or a decade in the larger views; date is the first date of the period. |
| SFTDATE_CALHIT_TODAYBUTTON, SFTDATE_CALHIT_CLEARBUTTON | The Today and Clear buttons. |
This example shows a context menu when the user right-clicks a day:
case WM_CONTEXTMENU:
if ((HWND) wParam == hwndCalendar) {
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
SFTDATE_HITTEST hit;
ScreenToClient(hwndCalendar, &pt);
SftDate_HitTest(hwndCalendar, pt, &hit);
if (hit.area == SFTDATE_CALHIT_DAY && hit.fHasDate)
ShowDayMenu(hwndDlg, &hit.date); /* the application's menu */
return TRUE;
}
break;