Page 1 of 1

strange date get

Posted: Sun Apr 24, 2022 8:48 am
by Detlef
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: Select all | Expand

#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
}
 

prg file

Code: Select all | Expand

#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

Re: strange date get

Posted: Sun Apr 24, 2022 10:58 am
by Antonio Linares
Dear Detlef,

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

You are just defining an ACTION for it

Re: strange date get

Posted: Sun Apr 24, 2022 12:31 pm
by Detlef
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

Re: strange date get

Posted: Sun Apr 24, 2022 1:45 pm
by Antonio Linares
It seems to behave fine. When you modify the GET then the other values are updated.

What is wrong ?

Re: strange date get

Posted: Sun Apr 24, 2022 2:03 pm
by Detlef
Antonio,
when I type in a 5 for month of the date and press enter the following value for stat-month is not updated.

Re: strange date get

Posted: Sun Apr 24, 2022 5:18 pm
by Antonio Linares
Please try this:

Code: Select all | Expand

ON CHANGE (;
                  oDate:Assign(),;
                  hData[ "stat_month" ] := month( hData[ "date" ] ),;
                  hData[ "stat_year"  ] :=  year( hData[ "date" ] ),;
                  oStatMonth:Refresh(), oStatYear:Refresh() )

Re: strange date get

Posted: Sun Apr 24, 2022 5:28 pm
by Detlef
Many thanks Antonio for your support, even on Sunday.
Antonio Linares wrote:Please try this: .. oDate:Assign()

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