FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Set range of a date picker
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Set range of a date picker
Posted: Tue Aug 02, 2022 10:36 AM
Hello,
because of our needs I created this function
<div class="c" id="{CB}" style="font-family: monospace;">
#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();
}
 </div>

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 (fw): Select all Collapse
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?
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Set range of a date picker
Posted: Tue Aug 02, 2022 06:47 PM
hi,

as i can say FiveWin have Function in
c:\fwh\source\classes\tdtpicke.prg
Code (fw): Select all Collapse
METHOD SetRange( dFrom, dUpto ) CLASS TDatePick
greeting,

Jimmy

Continue the discussion