Page 1 of 2
Like clipper readvar()
Posted: Wed Aug 14, 2013 11:45 pm
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.
Re: Like clipper readvar()
Posted: Thu Aug 15, 2013 2:29 am
by James Bott
Try oGet:bKeyDown or oGet:bKeyChar
James
Re: Like clipper readvar()
Posted: Thu Aug 15, 2013 9:32 am
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
Re: Like clipper readvar()
Posted: Fri Aug 16, 2013 3:27 pm
by Wanderson
James Bott wrote:Try oGet:bKeyDown or oGet:bKeyChar
James
Thanks Jame I will try.
Re: Like clipper readvar()
Posted: Fri Aug 16, 2013 3:28 pm
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?
Re: Like clipper readvar()
Posted: Fri Aug 16, 2013 8:38 pm
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
Re: Like clipper readvar()
Posted: Sat Aug 17, 2013 12:01 am
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.
Re: Like clipper readvar()
Posted: Sun Aug 18, 2013 3:49 am
by James Bott
Did you try bKeydown or bkeyChar?
Or you could put a small button next to the Get.
James
Re: Like clipper readvar()
Posted: Sun Aug 18, 2013 9:54 am
by Antonio Linares
Wanderson,
Simply do:
SET KEY VK_F5 TO Man_Vei()
DEFINE DIALOG ...
ACTIVATE DIALOG ...
Re: Like clipper readvar()
Posted: Mon Aug 19, 2013 4:05 pm
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.
Re: Like clipper readvar()
Posted: Mon Aug 19, 2013 6:11 pm
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
===============================================================================================================================================
Re: Like clipper readvar()
Posted: Mon Aug 19, 2013 6:56 pm
by Gale FORd
Couldn't you use the cargo variable to store the name.
Re: Like clipper readvar()
Posted: Tue Aug 20, 2013 8:48 pm
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,
Re: Like clipper readvar()
Posted: Tue Aug 20, 2013 9:17 pm
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
Re: Like clipper readvar()
Posted: Thu Aug 22, 2013 2:33 pm
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.