Like clipper readvar()

Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Like clipper readvar()

Post by Wanderson »

Hi all,

I want to create a function to process some datas depending that get comes, like readvar() clipper function, I explain below

Set Key VK_F5 to Man_Pro()

...

REDEFINE GET oGet27 VAR oArqCto:ENOME ID 4040 of Folder1:aDialogs[1] Picture "@!" Color Frente,Fundo update
REDEFINE GET oGet28 VAR oArqCto:EEND ID 4041 of Folder1:aDialogs[1] Picture "@!" Color Frente,Fundo update

...

Static Function Man_Pro()

Here I want to know if i press F5 in oGet27 or oGet28

Thanks in advance.
Wanderson.
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Like clipper readvar()

Post by James Bott »

Try oGet:bKeyDown or oGet:bKeyChar

James
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Like clipper readvar()

Post by Antonio Linares »

Wanderson,

You could also do:

nAt := AScan( Folder1:aDialogs[1]:aControls, { | oCtrl | GetFocus() == oCtrl:hWnd } )
Folder1:aDialogs[1]:aControls[ nAt ] // this is the focused control
regards, saludos

Antonio Linares
www.fivetechsoft.com
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: Like clipper readvar()

Post by Wanderson »

James Bott wrote:Try oGet:bKeyDown or oGet:bKeyChar

James
Thanks Jame I will try.
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: Like clipper readvar()

Post by Wanderson »

Antonio Linares wrote:Wanderson,

You could also do:

nAt := AScan( Folder1:aDialogs[1]:aControls, { | oCtrl | GetFocus() == oCtrl:hWnd } )
Folder1:aDialogs[1]:aControls[ nAt ] // this is the focused control
Thanks Antonio, I think in another way, In my function how i can get a id of the get control when i press the function key?
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Like clipper readvar()

Post by James Bott »

Wanderson,
In my function how i can get a id of the get control when i press the function key?
oGet:end()
oDlg:refresh()

However, this is not standard behavior so users will most likely be confused by it. I would suggest that irrelevant controls should be shown as disabled. This disabling should be under program control not user control.

Perhaps if you explained in more detail what you are trying to do, we could be of more help.

Regards,
James
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: Like clipper readvar()

Post by Wanderson »

James Bott wrote:Wanderson,
In my function how i can get a id of the get control when i press the function key?
oGet:end()
oDlg:refresh()

However, this is not standard behavior so users will most likely be confused by it. I would suggest that irrelevant controls should be shown as disabled. This disabling should be under program control not user control.

Perhaps if you explained in more detail what you are trying to do, we could be of more help.

Regards,
James
Hi James I think you dont understand. I have many gets in dialog. If I press F5 in any get the function Man_Vei() is called. Inside this function I want to know
in which get it was tight f5, because I want to treat and return some results depending on who gets came.

Thanks.
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Like clipper readvar()

Post by James Bott »

Did you try bKeydown or bkeyChar?

Or you could put a small button next to the Get.

James
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Like clipper readvar()

Post by Antonio Linares »

Wanderson,

Simply do:

SET KEY VK_F5 TO Man_Vei()

DEFINE DIALOG ...

ACTIVATE DIALOG ...
regards, saludos

Antonio Linares
www.fivetechsoft.com
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: Like clipper readvar()

Post by Wanderson »

Antonio Linares wrote:Wanderson,

Simply do:

SET KEY VK_F5 TO Man_Vei()

DEFINE DIALOG ...

ACTIVATE DIALOG ...
Hi Antonio,
Yes I already do this in my program, I Explain

SET KEY VK_F5 TO Man_Vei()

...
REDEFINE GET oGet01 ID 101 VAR Test1 of odlg
REDEFINE GET oGet02 ID 102 VAR Test2 of odlg

...

Static Function Man_Vei()
Here I need know if i pressed F5 in oGet01 or oGet02 cause i have to return diferent results

... If I pressed F5 in oGet01
VarRet := "XXXXX"
Endif
If I pressed F5 in oGet02
VarRet := "YYYYY"
Endif

Return .t.
yury
Posts: 56
Joined: Wed May 23, 2007 2:01 pm

Re: Like clipper readvar()

Post by yury »

Wanderson

so that the object tget contains the "name" of the edited variable is necessary to pass the name of this variable for the fourth parameter GetNew

currently (as my version of FW) class tget sends this null parameter, see the class tget (GetNew (20,20, bSetGet, cPict))

in the example that you mentioned would have to do so:

GetNew (20,20, bSetGet, "Test1", cPict)

this way you would oGet01: oGet: cVarName = "Test1"

for this to be done in a transparent manner you would have to change the class tget to receive a new parameter (cVarName, for example) and change the include the Get command to send the same this parameter

hugs

===============================================================================================================================================

Wanderson

para que o objeto TGet contenha o "nome" da variável editada é necessário passar o nome desta variável para o GetNew no quarto parâmetro

atualmente (até a minha versão do FW) a classe TGet envia este parâmetro nulo, veja na classe TGet ( GetNew(20,20,bSetGet,,cPict) )

no exemplo que voce citou teria que fazer assim:

GetNew(20,20,bSetGet,"Test1",cPict)

desta forma voce teria oGet01:oGet:cVarName = "Test1"

para que isso seja feito de forma transparente voce teria que alterar a classe TGet para receber um novo parâmetro (cVarName, por exemplo) e alterar o include do comando Get para que o mesmo envie este parâmetro

abraços

===============================================================================================================================================
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Re: Like clipper readvar()

Post by Gale FORd »

Couldn't you use the cargo variable to store the name.
User avatar
avista
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: Like clipper readvar()

Post by avista »

You can try this 2 samples

Code: Select all

#Include "FiveWin.Ch"

static nGet := 0

Function Main()
   Local oDlg
   Local oGet1,oGet2,oGet3
   local cVar1 := space(10)
   local cVar2 := space(10)
   local cVar3 := space(10)

   SET KEY VK_F5 TO Man_Vei()

   DEFINE DIALOG oDlg FROM 0,0 to 200,200 PIXEL

   @ 15,15 GET oGet1 VAR cVar1 OF oDlg SIZE 50,12 PIXEL
   oGet1:bKeyDown := { | nKey | IIF( nKey == VK_F5, nGet := 1, ) }

   @ 30,15 GET oGet2 VAR cVar2 OF oDlg SIZE 50,12 PIXEL
   oGet2:bKeyDown := { | nKey | IIF( nKey == VK_F5, nGet := 2, ) }

   @ 45,15 GET oGet3 VAR cVar3 OF oDlg SIZE 50,12 PIXEL

   ACTIVATE DIALOG oDlg

RETURN NIL

// ----------------------

Static Function Man_Vei()

local VarRet := ""

DO CASE
   CASE nGet == 1
        VarRet := "XXXXX"
        MsgInfo( VarRet )
   CASE nGet == 2
        VarRet := "YYYYY"
        MsgInfo( VarRet )
ENDCASE

nGet := 0

Return VarRet

Code: Select all

#Include "FiveWin.Ch"

static nGet := 0

Function Main()
   Local oDlg
   Local oGet1,oGet2,oGet3
   local cVar1 := space(10)
   local cVar2 := space(10)
   local cVar3 := space(10)

   SET KEY VK_F5 TO Man_Vei()

   DEFINE DIALOG oDlg FROM 0,0 to 200,200 PIXEL

   @ 15,15 GET oGet1 VAR cVar1 OF oDlg SIZE 50,12 PIXEL
   oGet1:bGotFocus  := { || nGet := 1 }
   oGet1:bLostFocus := { || nGet := 0 }

   @ 30,15 GET oGet2 VAR cVar2 OF oDlg SIZE 50,12 PIXEL
   oGet2:bGotFocus  := { || nGet := 2 }
   oGet2:bLostFocus := { || nGet := 0 }

   @ 45,15 GET oGet3 VAR cVar3 OF oDlg SIZE 50,12 PIXEL

   ACTIVATE DIALOG oDlg

RETURN NIL

// ----------------------

Static Function Man_Vei()

local VarRet := ""

DO CASE
   CASE nGet == 1
        VarRet := "XXXXX"
        MsgInfo( VarRet )
   CASE nGet == 2
        VarRet := "YYYYY"
        MsgInfo( VarRet )
ENDCASE

Return VarRet
 
Regards,
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Re: Like clipper readvar()

Post by Gale FORd »

Here is a version using cargo

Code: Select all

#Include "FiveWin.Ch"

Function Main()
   Local oDlg
   Local oGet1,oGet2,oGet3
   local cVar1 := space(10)
   local cVar2 := space(10)
   local cVar3 := space(10)

   //SET KEY VK_F5 TO Man_Vei( )
   SetKey( VK_F5, {|p, l, v| Man_Vei( oDlg )} )

   DEFINE DIALOG oDlg FROM 0,0 to 200,200 PIXEL

   @ 15,15 GET oGet1 VAR cVar1 OF oDlg SIZE 50,12 PIXEL
   oGet1:cargo := 'XXXXX'

   @ 30,15 GET oGet2 VAR cVar2 OF oDlg SIZE 50,12 PIXEL
   oGet2:cargo := 'YYYYY'

   @ 45,15 GET oGet3 VAR cVar3 OF oDlg SIZE 50,12 PIXEL

   ACTIVATE DIALOG oDlg

RETURN NIL

// ----------------------

static function Man_Vei( oDlg )
   local nCounter, cVarRet
   for nCounter := 1 TO LEN( oDlg:aControls )
      if oDlg:aControls[ nCounter ]:lFocused
         cVarRet := oDlg:aControls[ nCounter ]:cargo
         exit
      endif
   next
   if cVarRet != nil
      msginfo( cVarRet )
   endif
return cRetVar

 
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: Like clipper readvar()

Post by Wanderson »

avista wrote:You can try this 2 samples

Code: Select all

#Include "FiveWin.Ch"

static nGet := 0

Function Main()
   Local oDlg
   Local oGet1,oGet2,oGet3
   local cVar1 := space(10)
   local cVar2 := space(10)
   local cVar3 := space(10)

   SET KEY VK_F5 TO Man_Vei()

   DEFINE DIALOG oDlg FROM 0,0 to 200,200 PIXEL

   @ 15,15 GET oGet1 VAR cVar1 OF oDlg SIZE 50,12 PIXEL
   oGet1:bKeyDown := { | nKey | IIF( nKey == VK_F5, nGet := 1, ) }

   @ 30,15 GET oGet2 VAR cVar2 OF oDlg SIZE 50,12 PIXEL
   oGet2:bKeyDown := { | nKey | IIF( nKey == VK_F5, nGet := 2, ) }

   @ 45,15 GET oGet3 VAR cVar3 OF oDlg SIZE 50,12 PIXEL

   ACTIVATE DIALOG oDlg

RETURN NIL

// ----------------------

Static Function Man_Vei()

local VarRet := ""

DO CASE
   CASE nGet == 1
        VarRet := "XXXXX"
        MsgInfo( VarRet )
   CASE nGet == 2
        VarRet := "YYYYY"
        MsgInfo( VarRet )
ENDCASE

nGet := 0

Return VarRet

Code: Select all

#Include "FiveWin.Ch"

static nGet := 0

Function Main()
   Local oDlg
   Local oGet1,oGet2,oGet3
   local cVar1 := space(10)
   local cVar2 := space(10)
   local cVar3 := space(10)

   SET KEY VK_F5 TO Man_Vei()

   DEFINE DIALOG oDlg FROM 0,0 to 200,200 PIXEL

   @ 15,15 GET oGet1 VAR cVar1 OF oDlg SIZE 50,12 PIXEL
   oGet1:bGotFocus  := { || nGet := 1 }
   oGet1:bLostFocus := { || nGet := 0 }

   @ 30,15 GET oGet2 VAR cVar2 OF oDlg SIZE 50,12 PIXEL
   oGet2:bGotFocus  := { || nGet := 2 }
   oGet2:bLostFocus := { || nGet := 0 }

   @ 45,15 GET oGet3 VAR cVar3 OF oDlg SIZE 50,12 PIXEL

   ACTIVATE DIALOG oDlg

RETURN NIL

// ----------------------

Static Function Man_Vei()

local VarRet := ""

DO CASE
   CASE nGet == 1
        VarRet := "XXXXX"
        MsgInfo( VarRet )
   CASE nGet == 2
        VarRet := "YYYYY"
        MsgInfo( VarRet )
ENDCASE

Return VarRet
 
Regards,
Thank you avista.
Post Reply