After adding a date picker control, I wanted to use a custom format using:
hCtl = pWindow.AddControl("DATETIMEPICKER", hwndMain, IDC_DATEPICKER, "Date", 60, 25 ,126, 27)
DateTime_SetFormat(hCtl,"yyyy.MM.dd")
I'm thinking I need to set a format property to custom first and don't see a way to do this with AfxNova.
To use the Window's DateTime_SetFormat macro:
DIM fmt AS WSTRING * 260 = "yyyy.MM.dd"
DateTime_SetFormat(hCtl, @fmt)
or
DateTime_SetFormat(hCtl, @WSTR("yyyy.MM.dd"))
You can use instead my CDtPicker static class (available adding #INCLUDE ONCE "AfxNova/CDtPicker.inc")
CDtPicker.SetFormat(hCtl, "yyyy.MM.dd")
Please note that in FreeBasic, @ is equivalent to VARPTR, unlike with PowerBasic, that was used to deference a pointer.
Thank you Jose for your speedy assistance. What worked was:
CDtPicker.SetFormat(hCtl, @"yyyy.MM.dd")
No, CDtPicker.SetFormat(hCtl, @"yyyy.MM.dd") is incorrect. If you use the CDtPicker static class, the correct way is CDtPicker.SetFormat(hCtl, "yyyy.MM.dd")
#INCLUDE ONCE "AfxNova/CDtPicker.inc"
CDtPicker.SetFormat(hCtl, "yyyy.MM.dd")
When I use the string "yyyy.MM.dd" directly, the control only shows the two digit year. I had to add:
#DEFINE UNICODE
and now it works as you provided.
You're right. I was using DTM_SETFORMAT. Changed to use DTM_SETFORMATW. Now it doesn't need #define UNICODE.
PRIVATE SUB CDtPicker.SetFormat (BYVAL hDtp AS HWND, BYVAL pwsz AS WSTRING PTR)
SendMessageW(hDtp, DTM_SETFORMATW, 0, cast(LPARAM, pwsz))
END SUB