FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour strange date get
Posts: 218
Joined: Mon Feb 07, 2022 09:54 PM
strange date get
Posted: Sun Apr 24, 2022 08:48 AM
Hi all,
I have a very strange behaviour of a get object.
The date doesn't fire it's bChange code if editing is made by hand. If the get is changed by action button the bChange block works okay.
I don't find an explanation or solution for this.

Here my code:
rc file
Code (rc): Select all Collapse
<div id="{CB}" style="font-family: monospace;">#include <windows.h>
#include <commctrl.h>

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
1 24 "WindowsXP.Manifest"

DATE_DLG DIALOG DISCARDABLE 6, 18, 158, 70
STYLE WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_VISIBLE
CAPTION "Dialog"
FONT 10, "MS Sans Serif"
{
  CONTROL "Date", -1, "Static", WS_GROUP, 8, 12, 24, 9
  CONTROL "", 10, "Edit", ES_CENTER|WS_BORDER|WS_TABSTOP, 8, 24, 54, 11, WS_EX_RIGHT|0x00010000
  CONTROL "Statistic-Month-Year", -1, "Static", WS_GROUP, 76, 12, 64, 9
  CONTROL "", 20, "Edit", ES_AUTOHSCROLL|WS_VSCROLL|WS_BORDER|WS_TABSTOP, 76, 24, 24, 11
  CONTROL "", 30, "Edit", ES_CENTER|WS_VSCROLL|WS_BORDER|WS_TABSTOP, 108, 24, 40, 11
  CONTROL "Cancel", IDCANCEL, "Button", WS_TABSTOP, 100, 48, 48, 14
}
 </div>

prg file
Code (fw): Select all Collapse
#include "FiveWin.ch"

FUNCTION Main()
//-------------
LOCAL oDlG, oDate, oStatMonth, oStatYear, oBtn
LOCAL hData := { => }


   Set( _SET_EPOCH,   1990 )
   Set( _SET_DATEFORMAT, "dd.mm.yyyy" )

   hData[ "date"       ] := date()
   hData[ "stat_month" ] := month( date() )
   hData[ "stat_year"  ] := year(  date() )

   DEFINE DIALOG oDlg NAME "DATE_DLG"

      REDEFINE GET oDate VAR hData[ "date" ];
         ID 10 OF oDlg PICTURE "@D";
         BITMAP "" ;
         UPDATE         ;
         ACTION ( hData[ "date" ] := dGetCal()                     ,;
                  oDate:Refresh()                                  ,;
                  hData[ "stat_month" ] := month( hData[ "date" ] ),;
                  hData[ "stat_year"  ] :=  year( hData[ "date" ] ),;
                  oStatMonth:Refresh(), oStatYear:Refresh()        ,;
                  oDate:SetFocus();
                );
          ON CHANGE (;
                  hData[ "stat_month" ] := month( hData[ "date" ] ),;
                  hData[ "stat_year"  ] :=  year( hData[ "date" ] ),;
                  oStatMonth:Refresh(), oStatYear:Refresh()        ,;
               )

      REDEFINE GET oStatMonth VAR hData[ "stat_month" ];
         ID 20 OF oDlg PICTURE "99";
         SPINNER MIN 1 MAX 12      ;
         UPDATE

      REDEFINE GET oStatYear  VAR hData[ "stat_year"  ];
         ID 30 OF oDlg PICTURE "9999";
         SPINNER MIN ( year( date() ) - 20 );
                 MAX ( year( date() ) + 20 );
         UPDATE

      REDEFINE BUTTON oBtn ID IDCANCEL OF oDlg ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED
RETURN NIL

STATIC FUNCTION dGetCal()
//-----------------------
RETURN( ctod( "24.12.2008" ) )


Could please, anyone help me?
Thanks, -Detlef
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: strange date get
Posted: Sun Apr 24, 2022 10:58 AM

Dear Detlef,

On your example the ON CHANGE clause of the GET is not implemented

You are just defining an ACTION for it

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 218
Joined: Mon Feb 07, 2022 09:54 PM
Re: strange date get
Posted: Sun Apr 24, 2022 12:31 PM

Dear Antonio,
sorry... I wanted to keep my example short. But I shortened too much. :oops:
Now the ON CHANGE clause is added.
But the effect is still the same.

Regards, Detlef

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: strange date get
Posted: Sun Apr 24, 2022 01:45 PM

It seems to behave fine. When you modify the GET then the other values are updated.

What is wrong ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 218
Joined: Mon Feb 07, 2022 09:54 PM
Re: strange date get
Posted: Sun Apr 24, 2022 02:03 PM

Antonio,
when I type in a 5 for month of the date and press enter the following value for stat-month is not updated.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: strange date get
Posted: Sun Apr 24, 2022 05:18 PM
Please try this:

Code (fw): Select all Collapse
ON CHANGE (;
                  oDate:Assign(),;
                  hData[ "stat_month" ] := month( hData[ "date" ] ),;
                  hData[ "stat_year"  ] :=  year( hData[ "date" ] ),;
                  oStatMonth:Refresh(), oStatYear:Refresh() )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 218
Joined: Mon Feb 07, 2022 09:54 PM
Re: strange date get
Posted: Sun Apr 24, 2022 05:28 PM
Many thanks Antonio for your support, even on Sunday.
Antonio Linares wrote:Please try this: .. oDate:Assign()

With this it's working fine. :-)
-Detlef

Continue the discussion