Defines whether a date field control can be empty.
C
BOOL WINAPI SftDate_GetAllowEmpty(HWND hwndCtl); void WINAPI SftDate_SetAllowEmpty(HWND hwndCtl, BOOL fAllowEmpty);
C++
BOOL CSftDate::GetAllowEmpty() const; void CSftDate::SetAllowEmpty(BOOL fAllowEmpty);
hwndCtl
The window handle of the date field control (SftDate).
fAllowEmpty
TRUE if the field can be empty, otherwise FALSE.
GetAllowEmpty returns TRUE if the field can be empty, otherwise FALSE.
The GetAllowEmpty and SetAllowEmpty functions define and retrieve whether a date field control can be empty. The default is FALSE: the field always has a value.
An empty field shows its placeholder text (SetPlaceholderText) and GetValue returns FALSE. The user empties the field by deleting all parts, by deleting the text in free-form editing, using the Clear button (SetShowClearButton) or the Clear button of the dropdown calendar (SetCalendarClearButton); the application by calling SetValue with NULL.
An empty field that no longer allows an empty value shows its last value again. The check box (SetShowCheckBox) is the other way of letting a field have no value. This function applies to the date field control only. For a month calendar control, GetAllowEmpty returns FALSE and SetAllowEmpty has no effect.
SftDate_SetFormat(GetDlgItem(hwndDlg, IDC_DATETIME), SFTDATE_FORMAT_SHORTDATETIME);
SftDate_SetSelectionMode(GetDlgItem(hwndDlg, IDC_RANGE), SFTDATE_SELECTION_RANGE);
SftDate_SetRange(GetDlgItem(hwndDlg, IDC_RANGE), &now, &weekLater);
SftDate_SetShowCheckBox(GetDlgItem(hwndDlg, IDC_OPTIONAL), TRUE);
SftDate_SetChecked(GetDlgItem(hwndDlg, IDC_OPTIONAL), FALSE);
SftDate_SetAllowEmpty(GetDlgItem(hwndDlg, IDC_EMPTY), TRUE);
SftDate_SetPlaceholderText(GetDlgItem(hwndDlg, IDC_EMPTY), TEXT("No date"));
SftDate_SetShowClearButton(GetDlgItem(hwndDlg, IDC_EMPTY), TRUE);
SftDate_SetValue(GetDlgItem(hwndDlg, IDC_EMPTY), NULL);
SftDate_SetEditStyle(GetDlgItem(hwndDlg, IDC_FREEFORM), SFTDATE_EDIT_FREEFORM);
SftDate_SetCustomFormat(GetDlgItem(hwndDlg, IDC_CUSTOM), TEXT("ddd, MMM d, yyyy 'at' HH:mm"));
m_Fields[4].SetFormat(SFTDATE_FORMAT_SHORTDATETIME);
m_Fields[5].SetSelectionMode(SFTDATE_SELECTION_RANGE);
m_Fields[5].SetRange(&now, &weekLater);
m_Fields[6].SetShowCheckBox(TRUE);
m_Fields[6].SetChecked(FALSE);
m_Fields[7].SetAllowEmpty(TRUE);
m_Fields[7].SetPlaceholderText(_T("No date"));
m_Fields[7].SetShowClearButton(TRUE);
m_Fields[7].SetValue(NULL);
m_Fields[8].SetEditStyle(SFTDATE_EDIT_FREEFORM);
m_Fields[9].SetCustomFormat(_T("ddd, MMM d, yyyy 'at' HH:mm"));See Also C/C++ API | Categories | Notifications