because of our needs I created this function
- Code: Select all Expand view RUN
#include <hbapi.h>
#include <hbdate.h>
#include <windows.h>
#include <commctrl.h>
HB_FUNC( DATETIME_SETRANGE ) // ( hWnd, dMin, dMax)
{
SYSTEMTIME range[2];
long dMin = hb_pardl(2);
long dMax = hb_pardl(3);
int y,m,d;
HWND hWnd = ( HWND ) hb_parfw( 1 );
hb_dateDecode(dMin, &y, &m, &d);
range[0].wYear = (WORD)y;
range[0].wMonth = (WORD)m;
range[0].wDay = (WORD)d;
range[0].wDayOfWeek = 0;
range[0].wHour = 0;
range[0].wMinute = 0;
range[0].wSecond = 0;
range[0].wMilliseconds = 0;
hb_dateDecode(dMax, &y, &m, &d);
range[1].wYear = (WORD)y;
range[1].wMonth = (WORD)m;
range[1].wDay = (WORD)d;
range[1].wDayOfWeek = 0;
range[1].wHour = 0;
range[1].wMinute = 0;
range[1].wSecond = 0;
range[1].wMilliseconds = 0;
DateTime_SetRange(hWnd,
(dMin!=0? GDTR_MIN : 0) |
(dMax!=0? GDTR_MAX : 0), range);
hb_ret();
}
I am using a very old version of fivewin (18-01), so I don't know if it is already present in newer versions, but It looks useful so I shared it.
samples of use:
- Code: Select all Expand view RUN
DateTime_SetRange(oDTPicker:hWnd, Date()-10, Date()+10) // enable only from 10 days before to 10 days after today
DateTime_SetRange(oDTPicker:hWnd, Date(), nil) // enable only future dates
DateTime_SetRange(oDTPicker:hWnd, nil, Date()) // enable only past dates
It works on Harbour and Visual Studio
can someone try it on xHarbour and bcc?