HeaderPane
Main
Hide
Share Link
Print

PlaceholderText

Defines the text an empty date field control shows.

C

int SftDate_GetPlaceholderText(HWND hwndCtl, LPTSTR lpszText, int cchMax);
int WINAPI SftDate_GetPlaceholderText_A(HWND hwndCtl, LPSTR lpszText, int cchMax);
int WINAPI SftDate_GetPlaceholderText_W(HWND hwndCtl, LPWSTR lpszText, int cchMax);
void SftDate_SetPlaceholderText(HWND hwndCtl, LPCTSTR lpszText);
void WINAPI SftDate_SetPlaceholderText_A(HWND hwndCtl, LPCSTR lpszText);
void WINAPI SftDate_SetPlaceholderText_W(HWND hwndCtl, LPCWSTR lpszText);

C++

int CSftDate::GetPlaceholderText(LPTSTR lpszText, int cchMax) const;
CString CSftDate::GetPlaceholderText() const;
void CSftDate::SetPlaceholderText(LPCTSTR lpszText);

Parameters

hwndCtl

The window handle of the date field control (SftDate).

lpszText

Get: a pointer to the buffer that receives the text, or NULL to retrieve the length of the text.
Set: a pointer to the new text. NULL is the same as an empty text.

cchMax

The size of the buffer in characters, including the terminating null character.

Returns

The Get function returns the number of characters copied to the buffer, not including the terminating null character. If the buffer is NULL or cchMax is 0, it returns the length of the text instead, so an application can allocate a buffer of the required size (the length plus one). A text longer than the buffer is truncated.

Comments

The GetPlaceholderText and SetPlaceholderText functions define and retrieve the text shown in an empty date field control (SetAllowEmpty), for example "No date". The default is an empty text.

The placeholder is shown in the color SFTDATE_COLOR_PLACEHOLDERFORE (SetColor) while the field is empty. In segment editing (SetEditStyle) it is hidden while the field has the input focus, so the user sees the parts being typed. In free-form editing, the text box shows it as its cue banner, in the system's gray, also while it has the input focus. This function applies to the date field control only. For a month calendar control, GetPlaceholderText returns 0 and SetPlaceholderText has no effect.

SftDate.h maps the name without suffix to the _A (ANSI) or _W (Unicode) function, depending on whether UNICODE or _UNICODE is defined. The ANSI functions convert the text using the system code page.

Examples

C View entire sample code

    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"));
    SftDate_SetFormat(GetDlgItem(hwndDlg, IDC_CUSTOM), SFTDATE_FORMAT_CUSTOM);

C++ View entire sample code

    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"));
    m_Fields[9].SetFormat(SFTDATE_FORMAT_CUSTOM);

See Also C/C++ API | Categories | Notifications


Last Updated 11/26/2026 - (email)
© 2026 Softel vdm, Inc.