How to implement GETACTIVE()?

User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: How to implement GETACTIVE()?

Post by cnavarro »

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

#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
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: How to implement GETACTIVE()?

Post by Enrico Maria Giordano »

This is my last code. Please try it.

Code: Select all

#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
mauri.menabue
Posts: 89
Joined: Thu Apr 17, 2008 2:38 pm

Re: How to implement GETACTIVE()?

Post by mauri.menabue »

hi Enrico
try this code whit 2 gets of different type does not work

Code: Select all

#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
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: How to implement GETACTIVE()?

Post by Enrico Maria Giordano »

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

Code: Select all

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
hmpaquito
Posts: 1200
Joined: Thu Oct 30, 2008 2:37 pm

Re: How to implement GETACTIVE()?

Post by hmpaquito »

Enrico,

Esa solución sólo funcionará si se avanza al siguiente Get. Probablemente no funcione si se retrocede al anterior Get
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: How to implement GETACTIVE()?

Post by Enrico Maria Giordano »

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

Any ideas about how to solve the problem?

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

Re: How to implement GETACTIVE()?

Post by mauri.menabue »

Hi Enrico
It's OK GREAT ! :D
bye
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: How to implement GETACTIVE()?

Post by Enrico Maria Giordano »

This is slightly better but still not perfect:

Code: Select all

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
mauri.menabue
Posts: 89
Joined: Thu Apr 17, 2008 2:38 pm

Re: How to implement GETACTIVE()?

Post by mauri.menabue »

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
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: How to implement GETACTIVE()?

Post by Enrico Maria Giordano »

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

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

Re: How to implement GETACTIVE()?

Post by mauri.menabue »

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
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: How to implement GETACTIVE()?

Post by Enrico Maria Giordano »

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

Code: Select all

#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
Post Reply