This section describes how to add a date field control or a month calendar control to a dialog using Visual Studio.
To add a SftDate/DLL control to a dialog, use the "Custom Control" item of the Toolbox in the dialog editor. Click on the item and then the dialog being designed to add a control.
Once a custom control has been added to a dialog, you can edit the control properties by using the View, Properties Window menu command.
To define a date field control, enter the class SftDateControl20 in the edit field labeled Class; for a month calendar control, enter SftCalendarControl20. A window caption is not necessary, so the edit field marked Caption can be left blank.
The resulting entries in the resource script (*.rc file) of the application look as follows (taken from the DemoSample):
CONTROL "",IDC_DATE,"SftDateControl20",WS_TABSTOP,80,20,156,14 CONTROL "",IDC_CALENDAR,"SftCalendarControl20",WS_TABSTOP,257,229,280,100
Both controls size themselves by default (SetAutoSize), so the size defined in the dialog resource is only an approximation. A date field control keeps its width and takes the height its font requires; the dialog's font is used. A month calendar control takes the size of the months it shows and keeps its top left corner. To keep the size defined in the dialog resource, call SetAutoSize with FALSE.
The controls use the standard window styles only. Enter the resulting hexadecimal value in the field marked Style, or set the individual properties in the Properties window:
| Style | Value | Description |
|---|---|---|
| WS_CHILD | 0x40000000 | Creates a child window. Required. |
| WS_VISIBLE | 0x10000000 | Creates a control that is initially visible. Usually required. |
| WS_TABSTOP | 0x00010000 | Specifies a control that can receive the keyboard focus when the user presses the TAB key. |
| WS_GROUP | 0x00020000 | Specifies the first control of a group of controls. |
| WS_DISABLED | 0x08000000 | Creates a control that is initially disabled. |
| WS_BORDER | 0x00800000 | Adds a window border to a month calendar control. A date field control draws its own border (SetBorderStyle). |
The extended window styles WS_EX_LAYOUTRTL and WS_EX_RTLREADING lay out a control from right to left (SetRightToLeft).
Format, culture, selection mode and all other attributes are defined at run-time using the SftDate_xxx functions or the C++ classes CSftDate and CSftCalendar. See Using C and Using C++/MFC.
A static control (label) in front of a control in the tab order names the control for screen readers and provides its mnemonic, as for any Windows control. See Accessibility (Screen Readers).