TGET losing the focus

TGET losing the focus

Postby driessen » Thu Oct 02, 2008 10:31 am

Hello,

I have this code which is used in a dialog box :
Code: Select all  Expand view
   REDEFINE GET oGET[01] VAR cAGDOS1    ID 101 OF AgeDlg PICTURE REPLICATE("!",5) UPDATE
   REDEFINE GET oGET[02] VAR cAGDOS2    ID 102 OF AgeDlg PICTURE REPLICATE("9",5) UPDATE
   REDEFINE GET oGET[03] VAR cAGSDOS    ID 103 OF AgeDlg PICTURE "9" UPDATE VALID ZoekAP()
   REDEFINE GET oGET[04] VAR cAGNAAMV   ID 104 OF AgeDlg PICTURE REPLICATE("X", 50) UPDATE WHEN .F.
   REDEFINE GET oGET[05] VAR cAGNAAMT   ID 105 OF AgeDlg PICTURE REPLICATE("X", 50) UPDATE WHEN .F.
   REDEFINE GET oGET[06] VAR cAGNAAMI   ID 106 OF AgeDlg PICTURE REPLICATE("X", 50) UPDATE WHEN .F.
   REDEFINE GET oGET[07] VAR cAGSRTNRN  ID 107 OF AgeDlg PICTURE REPLICATE("X", 40) UPDATE WHEN .F.
   REDEFINE GET oGET[08] VAR cAGGROEP   ID 108 OF AgeDlg PICTURE REPLICATE("X",  6) UPDATE WHEN .F.
   REDEFINE GET oGET[09] VAR cAGOMSCH   ID 109 OF AgeDlg PICTURE REPLICATE("X",100) UPDATE
   REDEFINE GET oGET[10] VAR cAGVERGNRN ID 110 OF AgeDlg PICTURE REPLICATE("X", 40) UPDATE WHEN !cAGAGRAP


After the input of cAGSDOS, the function ZoekAP() is automatically called. This function switches to another dialog box to select the data which has to be placed into cAGSRTNRN and cAGGROEP.

In FWH 8.04, after having ended the second dialog box, the focus was automatically given to cAGOMSCH but since FWH 8.09 the focus returns to the first line, i.e. cAGDOS1 although I didn't change one single character in the code.

What causes this behaviour ? Can the behaviour of FWH 8.04 be restored in FWH 8.09 ?

If that isn't the case, I have a lot of work to do to arrange all the focusses since my application uses about 200 dialog boxes. That means at least a whole week of work for me.

I sincerely hope somebody can help me to lose that amount of time.

Thanks a lot in advance.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby driessen » Thu Oct 02, 2008 11:26 am

Hello,

I rebuild my application with FWH 8.04, 8.05, 8.06, 8.07, 8.08 and 8.09.

Only in FWH 8.09 the problem occurs. Until FWH 8.08, everything is doing fine.

Has there been made a change in the update of a dialog box ?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby James Bott » Thu Oct 02, 2008 12:09 pm

Michel,

There are several things you can do to answer your own question. First look at the file dates of the new dialog.prg and an older one. This will tell you if there have been changes.

To find what the changes are, get a utility like WinMerge which will show the exact differences in the two files.

http://www.winmerge.org

If dialog.prg has been changed, the first thing I would do is compile your application with a copy of dialog.prg from the last FWH version. If the problem goes away, then the dialog source is indeed the problem. If not, then you need to look elsewhere.

Of course, the changes may not have been in TDialog--they could have been in TWindow from which TDialog inherits. Or, they might be in the control that is in focus when you open the new dialog, so you need to check that code for changes also.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby driessen » Thu Oct 02, 2008 2:36 pm

James,

You are great. Your suggestion of finding out by exclusion, did it.

I found out that the problem is caused by the button class.

In FWH 8.08 the code is :
Code: Select all  Expand view
METHOD Click() CLASS TButton

   if ! ::lProcessing

      ::lProcessing = .t.

      if ::bWhen != nil .and. ! Eval( ::bWhen )
         ::lProcessing = .f.
         return nil
      endif

      ::oWnd:lValidating = .T.
      if GetFocus() != ::hWnd
         SetFocus( ::hWnd )
      endif

In FWH 8.09 the code is :
Code: Select all  Expand view
METHOD Click() CLASS TButton

   if ! ::lProcessing

      ::lProcessing = .t.

      if ::bWhen != nil .and. ! Eval( ::bWhen )
         ::lProcessing = .f.
         return nil
      endif

      if GetFocus() != ::hWnd
         ::oWnd:lValidating = .T.
         SetFocus( ::hWnd )
         ::oWnd:lValidating = .F.   
      endif


Notice the difference in the last paragraph.

If I use the button class of FWH 8.08, everything is working fine.

Thanks a lot James.

To Antonio : what is the reason for the change ?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Antonio Linares » Thu Oct 02, 2008 4:09 pm

Michel,

If ::oWnd:lValidating = .T. is set and not restored later on, then next clicks on the button will not fire the VALID of the control where the focus is.

But in the portion of your code, that you shows, there are no push buttons. Are they located in the second called dialogbox ?

Could you reproduce the problem on a example that we could test ? Thanks,
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby driessen » Fri Oct 03, 2008 12:50 pm

Antonio,

It is rather difficult to send you a working example, since it is a part of a big dialog box.
First of all, I'll send you the code again, but now with the button defined.
Code: Select all  Expand view
   REDEFINE GET oGET[01] VAR cAGDOS1    ID 101 OF AgeDlg PICTURE REPLICATE("!",5) UPDATE
   REDEFINE GET oGET[02] VAR cAGDOS2    ID 102 OF AgeDlg PICTURE REPLICATE("9",5) UPDATE
   REDEFINE GET oGET[03] VAR cAGSDOS    ID 103 OF AgeDlg PICTURE "9" UPDATE VALID ZoekAP()
   REDEFINE GET oGET[04] VAR cAGNAAMV   ID 104 OF AgeDlg PICTURE REPLICATE("X", 50) UPDATE WHEN .F.
   REDEFINE GET oGET[05] VAR cAGNAAMT   ID 105 OF AgeDlg PICTURE REPLICATE("X", 50) UPDATE WHEN .F.
   REDEFINE GET oGET[06] VAR cAGNAAMI   ID 106 OF AgeDlg PICTURE REPLICATE("X", 50) UPDATE WHEN .F.
   REDEFINE GET oGET[07] VAR cAGSRTNRN  ID 107 OF AgeDlg PICTURE REPLICATE("X", 40) UPDATE WHEN .F.
   REDEFINE GET oGET[08] VAR cAGGROEP   ID 108 OF AgeDlg PICTURE REPLICATE("X",  6) UPDATE WHEN .F.
   REDEFINE GET oGET[09] VAR cAGOMSCH   ID 109 OF AgeDlg PICTURE REPLICATE("X",100) UPDATE
   REDEFINE GET oGET[10] VAR cAGVERGNRN ID 110 OF AgeDlg PICTURE REPLICATE("X", 40) UPDATE WHEN !cAGAGRAP

   REDEFINE BUTTON ID 901 OF AgeDlg ACTION(ZoekAp())


In the main dialog box there is indeed a push button, using the VALID clause of cAGSDOS as an action, which is ZoekAP().

The user can click on the button to go to the second dialog box or he will go automatically to the second dialog box after having pushed ENTER on his keyboard in the GET of cAGSDOS.

After the selection of cAGSRTNRN has been done, the focus has to go to the next field, i.e. cAGOMSCH.

As I already told you, I could find out that the BUTTON class caused the problem. I did this by excluding the classes used one by one and replacing them with the classes from FWH 8.08, which resulted in finding out that the BUTTON class caused the problem.

Thanks and have a nice weekend.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Antonio Linares » Fri Oct 03, 2008 2:08 pm

Michel,

Please try this test. Here it is working fine.

test.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg, oGet5, oBtn, cOne, cTwo, cThree, cFour, cFive
   
   cOne := cTwo := cThree := cFour := cFive := Space( 10 )

   DEFINE DIALOG oDlg TITLE "Test" SIZE 300, 200

   @ 1, 2 GET cOne
   @ 2, 2 GET cTwo
   @ 3, 2 GET cThree VALID Another()
   @ 4, 2 GET cFour WHEN .F.
   @ 5, 2 GET oGet5 VAR cFive
   
   @ 4.5, 10 BUTTON oBtn PROMPT "Action" ACTION ( Another(), oBtn:oJump := oGet5, oDlg:GoNextCtrl() )

   ACTIVATE DIALOG oDlg CENTERED

return nil

function Another()

   local oDlg
   
   DEFINE DIALOG oDlg
   
   @ 2, 10 BUTTON "Ok" ACTION oDlg:End()
   
   ACTIVATE DIALOG oDlg CENTERED
   
return .T.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby driessen » Fri Oct 03, 2008 7:18 pm

Antonio,

Thanks a lot for your efforts.

Your example is doing everything like it should be.

But I notice an extra which I have never used before :
Code: Select all  Expand view
oBtn:oJump := oGet5, oDlg:GoNextCtrl()


Never seen it before.

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby driessen » Tue Oct 07, 2008 4:43 pm

Antonio,

Adapting my application to your proposal is a hell lot of work because there are a few hundred occasion where this procedure is used.

But I agree that using the TButton class of FWH 8.08 is a problem cocerning the VALID clause if the button has been pressed.

Meanwhile, I tried something else by changing the TButton class.

I changed that part to :
Code: Select all  Expand view
METHOD Click() CLASS TButton

   if ! ::lProcessing

      ::lProcessing = .t.

      if ::bWhen != nil .and. ! Eval( ::bWhen )
         ::lProcessing = .f.
         return nil
      endif

      if GetFocus() != ::hWnd
         //::oWnd:lValidating = .T.
         SetFocus( ::hWnd )
         //::oWnd:lValidating = .F.   
      endif

So I excluded the ::Wnd:lValidating.

It seems to work fine now.

But what is the effect of excluding ::Wnd:lValidating ?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby driessen » Wed Oct 08, 2008 2:19 pm

Antonio,

Where you already able to read my question ?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby driessen » Thu Oct 09, 2008 12:17 am

Antonio ?
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Antonio Linares » Thu Oct 09, 2008 11:18 am

Michel,

It is related to buttons accelerators. If you press a button accelerator, the focus is given to the button so the VALID of the current focused control is fired.

Changing lValidating we avoid to execute the current VALID. It is somehow similar to the CANCEL clause.

But if we all agree that the current VALID should be processed, then it would be ok to remove that code as you have done.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Oct 09, 2008 11:20 am

Michel,

Please review this thread:

http://forums.fivetechsoft.com/viewtopic.php?t=12257
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby driessen » Thu Oct 09, 2008 12:05 pm

Antonio,

Thanks a lot for your answer.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Antonio Linares » Thu Oct 09, 2008 12:15 pm

Michel,

You are welcome :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 64 guests