strange date get

strange date get

Postby Detlef » Sun Apr 24, 2022 8: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: Select all  Expand view
#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 view
#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
Last edited by Detlef on Sun Apr 24, 2022 12:28 pm, edited 2 times in total.
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: strange date get

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: strange date get

Postby Detlef » 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
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: strange date get

Postby Antonio Linares » Sun Apr 24, 2022 1: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: strange date get

Postby Detlef » Sun Apr 24, 2022 2: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.
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: strange date get

Postby Antonio Linares » Sun Apr 24, 2022 5:18 pm

Please try this:

Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: strange date get

Postby Detlef » Sun Apr 24, 2022 5: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. :D
-Detlef
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 107 guests