The SftDate and SftCalendar controls use GDI+ for features not otherwise available:
GDI+ ships with all supported Windows versions (Windows 10 and above).
SftDate/DLL provides four functions which load and free GDI+ images, so the application does not have to initialize GDI+ or use GDI+ classes directly. Each load function returns an image pointer, which is used in a SFT_PICTURE structure of type SFT_PICTURE_GDIPLUS (see Sft_SetPictureGDIPlusImage).
| Function | Description |
|---|---|
| SftDate_LoadGDIPlusImageFromResource | Loads an image from an application resource. |
| SftDate_LoadGDIPlusImageFromFile | Loads an image from a file. |
| SftDate_FreeGDIPlusImageLoadedFromResource | Frees an image returned by SftDate_LoadGDIPlusImageFromResource. |
| SftDate_FreeGDIPlusImageLoadedFromFile | Frees an image returned by SftDate_LoadGDIPlusImageFromFile. |
LPVOID lpImage = SftDate_LoadGDIPlusImageFromResource(hInst, TEXT("PNG"), MAKEINTRESOURCE(IDR_MEETING)); SFTDATE_SPECIALDATE sd; memset(&sd, 0, sizeof(sd)); sd.cbSize = sizeof(SFTDATE_SPECIALDATE); GetLocalTime(&sd.date); sd.recurrence = SFTDATE_RECURRENCE_WEEKLY; sd.colorBg = sd.colorFg = SFTDATE_NOCOLOR; sd.fEnabled = TRUE; Sft_SetPictureGDIPlusImage(&sd.Picture, lpImage); SftDate_AddSpecialDate(hwndCalendar, &sd); . . . SftDate_ClearSpecialDates(hwndCalendar); /* the image is no longer used */ SftDate_FreeGDIPlusImageLoadedFromResource(lpImage);
The load function and the matching free function must always be paired. An image must not be freed while a control still uses it.