HeaderPane
Main
Hide
Share Link
Print

DefaultText

Defines a text such as =Today that sets the value of a date field control.

C

int SftDate_GetDefaultText(HWND hwndCtl, LPTSTR lpszText, int cchMax);
int WINAPI SftDate_GetDefaultText_A(HWND hwndCtl, LPSTR lpszText, int cchMax);
int WINAPI SftDate_GetDefaultText_W(HWND hwndCtl, LPWSTR lpszText, int cchMax);
void SftDate_SetDefaultText(HWND hwndCtl, LPCTSTR lpszText);
void WINAPI SftDate_SetDefaultText_A(HWND hwndCtl, LPCSTR lpszText);
void WINAPI SftDate_SetDefaultText_W(HWND hwndCtl, LPCWSTR lpszText);

C++

int CSftDate::GetDefaultText(LPTSTR lpszText, int cchMax) const;
CString CSftDate::GetDefaultText() const;
void CSftDate::SetDefaultText(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 GetDefaultText and SetDefaultText functions define and retrieve a text that sets the value of a date field control relative to the current date: "=Today", "=Yesterday", "=Tomorrow" (00:00:00 of the day) or "=Now" (the current date and time). Case doesn't matter. The default is an empty text.

The text is applied when it is set; a date outside the range defined using SetMinDate and SetMaxDate is moved into it. A text other than those listed is kept but doesn't change the value. In range selection mode, both dates are set.

The user can type the same texts in free-form editing (SetEditStyle). They always use the computer's date, not the date defined using SetTodayDate. This function applies to the date field control only. For a month calendar control, GetDefaultText returns 0 and SetDefaultText 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.

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


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