Defines how the user edits the value of a date field control.
C
int WINAPI SftDate_GetEditStyle(HWND hwndCtl); BOOL WINAPI SftDate_SetEditStyle(HWND hwndCtl, int style);
C++
int CSftDate::GetEditStyle() const; BOOL CSftDate::SetEditStyle(int style);
hwndCtl
The window handle of the date field control (SftDate).
style
The edit style. style can be one of the following values:
| SFTDATE_EDIT_SEGMENTS | The parts of the value (day, month, year, hour, ...) are edited one at a time, using digits, the arrow keys and the first letters of names. This is the default. |
| SFTDATE_EDIT_FREEFORM | The value is typed freely as text, which is parsed when the user presses Enter or leaves the field. |
GetEditStyle returns the edit style, one of the values listed above.
SetEditStyle returns TRUE if the style is valid, otherwise FALSE.
The GetEditStyle and SetEditStyle functions define and retrieve the edit style of a date field control.
In free-form editing, the field holds an edit control. The text is parsed in the format of the field, then leniently in the formats of the culture; "=Today", "=Yesterday", "=Tomorrow" and "=Now" are accepted as well. The application can parse the text itself in the NM_SFTDATE_TEXTPARSING notification, for example to accept "+3" for three days from today. Text that cannot be parsed restores the value, with a beep.
See Editing for the keys of both styles. This function applies to the date field control only. For a month calendar control, GetEditStyle returns SFTDATE_EDIT_SEGMENTS and SetEditStyle has no effect and returns FALSE.
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"));
SftDate_SetFormat(GetDlgItem(hwndDlg, IDC_CUSTOM), SFTDATE_FORMAT_CUSTOM);
SftDate_SetMonthsAcross(hwndCal, 2);
SftDate_GetMinDate(hwndCal, &g_minDate);
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"));
m_Fields[9].SetFormat(SFTDATE_FORMAT_CUSTOM);
m_Calendar.SetMonthsAcross(2);
m_Calendar.GetMinDate(&m_minDate);See Also C/C++ API | Categories | Notifications