How to implement GETACTIVE()?

Re: How to implement GETACTIVE()?

Postby cnavarro » Tue Oct 27, 2020 3:52 pm

Enrico Maria Giordano wrote:You are not trying my last code. Try it, please. It is not working.

EMG

There is no difference between both codes in their operation.
Anyway, I have used your code to test it and it works fine.

Code: Select all  Expand view  RUN

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVr1 := SPACE( 30 )
    LOCAL cVr2 := SPACE( 30 )

    DEFINE DIALOG oDlg

    @ 1,  1 GET cVr1 OF oDlg VALID !EMPTY( GETACTIVE( oDlg ):VarGet() ) SIZE 50, 18 PIXEL
    @ 25, 1 GET cVr2 OF oDlg  SIZE 50, 18 PIXEL

    ACTIVATE DIALOG oDlg CENTER

    RETURN NIL


FUNCTION GETACTIVE( oDlg )

    LOCAL i
    Local oObj

    FOR i = 1 TO LEN( oDlg:aControls )
        IF oDlg:aControls[ i ]:HasFocus()
            ? oDlg:aControls[ i - IF( i = 1, 0, 1 ) ]:VarGet()
            RETURN oDlg:aControls[ i - IF( i = 1, 0, 1 ) ]
        ENDIF
    NEXT

RETURN nil
 


Image
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6552
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: How to implement GETACTIVE()?

Postby Enrico Maria Giordano » Tue Oct 27, 2020 3:55 pm

This is my last code. Please try it.

Code: Select all  Expand view  RUN
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVr1 := SPACE( 30 )
    LOCAL cVr2 := SPACE( 30 )

    DEFINE DIALOG oDlg

    @ 1, 1 SAY "Test 1:" GET cVr1 VALID !EMPTY( GETACTIVE( oDlg ):VarGet() )
    @ 3, 1 SAY "Test 2:" GET cVr2

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


FUNCTION GETACTIVE( oDlg )

    LOCAL i

    FOR i = 1 TO LEN( oDlg:aControls )
        IF oDlg:aControls[ i ]:HasFocus()
            RETURN oDlg:aControls[ i - IF( i = 1, 0, 1 ) ]
        ENDIF
    NEXT

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to implement GETACTIVE()?

Postby mauri.menabue » Wed Oct 28, 2020 11:57 pm

hi Enrico
try this code whit 2 gets of different type does not work
Code: Select all  Expand view  RUN

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVr1 := SPACE( 30 )
    LOCAL nVr2 := 100

    DEFINE DIALOG oDlg

    @ 1, 1 GET cVr1 VALID IF( empty(GETACTIVE( oDlg ):VarGet())  , (MsgAlert("Campo obbligatorio", "Errore")        , .F.), .T.)
    @ 3, 1 GET nVr2 VALID IF( GETACTIVE( oDlg ):VarGet() < 0     , (MsgAlert("Valori negativi non validi", "Errore"), .F.), .T.)

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


FUNCTION GETACTIVE( oDlg )

    LOCAL i

    FOR i = 1 TO LEN( oDlg:aControls )
        IF oDlg:aControls[ i ]:HasFocus()
            RETURN oDlg:aControls[ i - IF( i = 1, 0, 1 ) ]
        ENDIF
    NEXT

    RETURN NIL

 

I don't understand why, it seems to change focus before running valid

Application
===========
Path and name: c:\fwh\samples\testright.exe (32 bits)
Size: 4,201,472 bytes
Compiler version: Harbour 3.2.0dev (r2008190002)
FiveWin version: FWH 20.08
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 6 secs
Error occurred at: 10/29/20, 00:44:20
Error description: Error BASE/1073 Argument error: <
Args:
[ 1] = C test
[ 2] = N 0

Stack Calls
===========
Called from: testright.prg => (b)MAIN( 14 )
Called from: .\source\classes\TGET.PRG => TGET:LVALID( 2112 )
Called from: .\source\classes\CONTROL.PRG => TGET:FWLOSTFOCUS( 1205 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1802 )
Called from: .\source\classes\TGET.PRG => TGET:HANDLEEVENT( 1157 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
Called from: => DIALOGBOXINDIRECT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 304 )
Called from: testright.prg => MAIN( 17 )

System
======
CPU type: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz 2808 Mhz
Hardware memory: 16260 megs

Free System resources: 90 %
GDI resources: 90 %
User resources: 90 %

Windows total applications running: 4
1 , c:\fwh\samples\testright.exe
2 DDE Server Window, C:\WINDOWS\System32\OLE32.DLL
3 G, C:\WINDOWS\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.18362.1139_none_17141c90536efd
4 LOGI_RAWINPUT_WND,

Variables in use
================
Procedure Type Value
==========================
(b)MAIN
Param 1: O Class: ERROR
TGET:LVALID
Param 1: O Class: TGET
Local 1: N 0
Local 2: U
Local 3: U
Local 4: S
TGET:FWLOSTFOCUS
Local 1: L .T.
TCONTROL:HANDLEEVENT
Param 1: N 461604
Local 1: U
TGET:HANDLEEVENT
Param 1: N 2057
Param 2: N 461604
Param 3: N 0
Local 1: U
_FWH
Param 1: N 2057
Param 2: N 461604
Param 3: N 0
Local 1: U
Local 2: U
DIALOGBOXINDIRECT
Param 1: N 0
Param 2: N 2057
Param 3: N 461604
Param 4: N 0
Param 5: N 3
Local 1: O Class: TGET
TDIALOG:ACTIVATE
Param 1: N 4194304
Param 2: C "€ È€  Ÿ L € P 
o e E D I T ‚ P  '  f E D I T 1 0 0 "
Param 3: N 0
Param 4: O Class: TDIALOG
MAIN
Param 1: U
Param 2: U
Param 3: U
Param 4: L .T.
Param 5: U
Param 6: L .T.
Param 7: U
Param 8: U
Param 9: U
Param 10: U
Param 11: U
Param 12: L .F.
Param 13: O Class: TDIALOG
Param 14: U
Local 1: N 0
Local 2: S
Local 3: O Class: TDIALOG

Linked RDDs
===========
DBF
DBFFPT
DBFBLOB
DBFNTX

DataBases in use
================

Classes in use:
===============
1 ERROR
2 HBCLASS
3 HBOBJECT
4 TWINDOW
5 TDIALOG
6 TBRUSH
7 TCONTROL
8 TGET
9 GET
10 TCLIPGET
11 TFONT
12 TREG32
13 TRECT
14 TSTRUCT

Memory Analysis
===============
588 Static variables

Dynamic memory consume:
Actual Value: 851968 bytes
Highest Value: 851968 bytes



bye
User avatar
mauri.menabue
 
Posts: 155
Joined: Thu Apr 17, 2008 2:38 pm

Re: How to implement GETACTIVE()?

Postby Enrico Maria Giordano » Thu Oct 29, 2020 8:26 am

I'm using this function that seems to work better:

Code: Select all  Expand view  RUN
FUNCTION GETACTIVE( oDlg )

    LOCAL i

    FOR i = 1 TO LEN( oDlg:aControls )
        IF oDlg:aControls[ i ]:HasFocus()
            RETURN OWNDFROMHWND( NEXTDLGTAB( oDlg:hWnd, oDlg:aControls[ i ]:hWnd, .T. ) )
        ENDIF
    NEXT

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to implement GETACTIVE()?

Postby hmpaquito » Thu Oct 29, 2020 9:04 am

Enrico,

Esa solución sólo funcionará si se avanza al siguiente Get. Probablemente no funcione si se retrocede al anterior Get
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: How to implement GETACTIVE()?

Postby Enrico Maria Giordano » Thu Oct 29, 2020 9:23 am

Yes, I know. That's why I write "better". :-)

Any ideas about how to solve the problem?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to implement GETACTIVE()?

Postby mauri.menabue » Thu Oct 29, 2020 9:40 am

Hi Enrico
It's OK GREAT ! :D
bye
User avatar
mauri.menabue
 
Posts: 155
Joined: Thu Apr 17, 2008 2:38 pm

Re: How to implement GETACTIVE()?

Postby Enrico Maria Giordano » Thu Oct 29, 2020 9:45 am

This is slightly better but still not perfect:

Code: Select all  Expand view  RUN
FUNCTION GETACTIVE()

    LOCAL i

    FOR i = 1 TO LEN( oDlg:aControls )
        IF oDlg:aControls[ i ]:HasFocus()
            RETURN OWNDFROMHWND( NEXTDLGTAB( oDlg:hWnd, oDlg:aControls[ i ]:hWnd, !GETKEYSTATE( VK_SHIFT ) ) )
        ENDIF
    NEXT

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to implement GETACTIVE()?

Postby mauri.menabue » Thu Oct 29, 2020 9:54 am

hi enrico
if you go back thru the controls , the error appears :(
there is no function es.: PREVTDLGTAB ?
or or proceed forward by skipping the controls that are not input up to the previous get,
perhaps the problem of jumping using the mouse would remain.

bye
User avatar
mauri.menabue
 
Posts: 155
Joined: Thu Apr 17, 2008 2:38 pm

Re: How to implement GETACTIVE()?

Postby Enrico Maria Giordano » Thu Oct 29, 2020 1:52 pm

Please try my latest sample that is reported in my previous post. And yes, clicking problem is not solved. :-(

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to implement GETACTIVE()?

Postby mauri.menabue » Thu Oct 29, 2020 6:40 pm

hi Enrico
I try it but unfortunately it doesn't work
when I move backwards with the mouse,
however the get active is always the one I am on, right?
bye
User avatar
mauri.menabue
 
Posts: 155
Joined: Thu Apr 17, 2008 2:38 pm

Re: How to implement GETACTIVE()?

Postby Enrico Maria Giordano » Thu Oct 29, 2020 6:53 pm

Works fine here moving backwards. Please, show a sample of the problem.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to implement GETACTIVE()?

Postby Enrico Maria Giordano » Fri Oct 30, 2020 3:21 pm

Improved version that seems to work fine. How to clean it?

Code: Select all  Expand view  RUN
#include "Fivewin.ch"


STATIC oGet


FUNCTION MAIN()

    LOCAL oDlg, oGt1, oGt2, oGt3

    LOCAL cVr1 := SPACE( 30 )
    LOCAL cVr2 := SPACE( 30 )
    LOCAL cVr3 := SPACE( 30 )

    DEFINE DIALOG oDlg

    @ 1, 1 SAY "Test 1:" GET oGt1 VAR cVr1 VALID ( oGet := oGt1, !EMPTY( GETACTIVE():VarGet() ) )
    @ 2, 1 SAY "Test 2:" GET oGt2 VAR cVr2 VALID ( oGet := oGt2, !EMPTY( GETACTIVE():VarGet() ) )
    @ 3, 1 SAY "Test 3:" GET oGt3 VAR cVr3 VALID ( oGet := oGt3, !EMPTY( GETACTIVE():VarGet() ) )

    oGt1:bGotFocus = { || oGet := oGt1 }
    oGt2:bGotFocus = { || oGet := oGt2 }
    oGt3:bGotFocus = { || oGet := oGt3 }

    oGt1:bKeyDown = { | nKey | If( nKey = VK_F2, MsgInfo( GETACTIVE():VarGet() ), ) }
    oGt2:bKeyDown = { | nKey | If( nKey = VK_F2, MsgInfo( GETACTIVE():VarGet() ), ) }
    oGt3:bKeyDown = { | nKey | If( nKey = VK_F2, MsgInfo( GETACTIVE():VarGet() ), ) }

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


FUNCTION GETACTIVE()

    oGet:Assign()

    RETURN oGet


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to implement GETACTIVE()?

Postby Enrico Maria Giordano » Fri Oct 30, 2020 3:38 pm

No, sorry, still doesn't work fine. :-(

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 8 guests