Page 3 of 4
Re: Set function key to a Value
Posted: Mon Jul 25, 2016 4:22 pm
by franco
Still having problems. Can not get ctrl+f2 to work.
In clipper language ctrl+f2 = F22.
Is there such a thing as ON KEY Ctrl+f2 OF Form_1 ACTION Somefunction().
I tried (#define VK_F22 133) from include folder but does not work. I do not know what 133 is or the value of ctrl+F2.
I have everything worked out if I can Get ctrl+F2 to..... ctrl+F10 to work. Very simple
ON KEY F22 OF FORM_1 ACTION MSGBOX('123').
And is there a global way at start of main program so F22 is set through complete program.
Franco.
Re: Set function key to a Value
Posted: Mon Jul 25, 2016 4:42 pm
by trmpluym
Franco,
Try:
ON KEY CONTROL+F2 OF Form_1 ACTION ( Somefunction() )
But it is not a good idea to combine CONTROL+F2 with the _Pushkey function like _Pushkey(VK_1) (elseway CTRL-1 is pressed if you do not release the CTRL key quick enough).
But you can use it in combination with the solution Roberto described.
Re: Set function key to a Value
Posted: Tue Jul 26, 2016 4:11 pm
by franco
Have it figured but still only works in a single window. Takes a lot of program lines to put it in all windows.
If I could figure how to make it globel through whole program it would be great.
here is how it works.
=====================================================================
Procedure Main
use file1 // File1 is table with macros in it. Field2 := '123'
define window win1
ON KEY CONTROL+F2 OF Win1 ACTION ( Somefunction(File1->Field2) )
Close file1
Return
Procedure somefunction
public a
parameters mf1
a:= Inputbox('Enter Item', 'Enter Item', mf1)
(Do Something With a)
return
======================================================================
Now I can do what I want with variable a .
I would like to set it in MAIN procedure (First Procedure) so it works throughout program.
Franco
Re: Set function key to a Value
Posted: Tue Jul 26, 2016 4:21 pm
by mol
franco wrote:Have it figured but still only works in a single window. Takes a lot of program lines to put it in all windows.
If I could figure how to make it globel through whole program it would be great.
here is how it works.
=====================================================================
Procedure Main
use file1 // File1 is table with macros in it. Field2 := '123'
define window win1
ON KEY CONTROL+F2 OF Win1 ACTION ( Somefunction(File1->Field2) )
Close file1
Return
Procedure somefunction
public a
parameters mf1
a:= Inputbox('Enter Item', 'Enter Item', mf1)
(Do Something With a)
return
======================================================================
Now I can do what I want with variable a .
I would like to set it in MAIN procedure (First Procedure) so it works throughout program.
Franco
The only way, I think, is to modify sources\h_textbox.prg to be sensitive on function keys.
But, this solution is dirty...
Re: Set function key to a Value
Posted: Tue Jul 26, 2016 4:37 pm
by CalScot
Have it figured but still only works in a single window. Takes a lot of program lines to put it in all windows.
If I could figure how to make it globel through whole program it would be great.
Have you tried making it a function, called (with just one line of code) from within any window where it's needed?
Re: Set function key to a Value
Posted: Tue Jul 26, 2016 4:45 pm
by franco
This is my next thought.
send window parameter and function parameter to a seperate procedure . I will try and let you know.
thanks Franco
Re: Set function key to a Value
Posted: Wed Jul 27, 2016 1:00 am
by andyglezl
No entiendo aquí.. Si el parámetro, mf1 es igual a "123" y lo estas asignando a la variable "a",
para que necesitas la funcion Inputbox() ?
------------------------------------------------------------------------------------------------------------------
I do not understand here .. If, mf1 parameter is equal to "123" and those assigned to the variable "a",
why you need the Inputbox() function ?
Code: Select all
Procedure somefunction
public a
parameters mf1
// a:= Inputbox('Enter Item', 'Enter Item', mf1)
// (Do Something With a)
Do Something With mf1 // <=================
return
Re: Set function key to a Value
Posted: Wed Jul 27, 2016 1:11 am
by andyglezl
Tal vez esto... (en teoría)
-----------------------
Maybe this... (in theory)
Code: Select all
Procedure Main
Public CodBlck_1, CodBlck_2, CodBlck_3, CodBlck_x
use file1
CodBlck_1 := { || Somefunction( Field2 ) }
CodBlck_2 := { || Somefunction( Field3 ) }
CodBlck_3 := { || Somefunction( Field4 ) }
CodBlck_x := { || Somefunction( Fieldx ) }
Close file1
define window win1
ON KEY CONTROL+F2 OF Win1 ACTION ( CodBlck_1 )
//.........
end window
Return
Procedure Win2
define window win2
ON KEY CONTROL+Fx OF Win2 ACTION ( CodBlck_2 )
//.........
end window
Return
Procedure Win3
define window win3
ON KEY CONTROL+Fx OF Win3 ACTION ( CodBlck_3 )
//.........
end window
Return
Procedure somefunction
parameters mf1
Do Something With mf1
return
Re: Set function key to a Value
Posted: Wed Jul 27, 2016 5:26 am
by mol
franco wrote:Have it figured but still only works in a single window. Takes a lot of program lines to put it in all windows.
If I could figure how to make it globel through whole program it would be great.
here is how it works.
=====================================================================
Procedure Main
use file1 // File1 is table with macros in it. Field2 := '123'
define window win1
ON KEY CONTROL+F2 OF Win1 ACTION ( Somefunction(File1->Field2) )
Close file1
Return
Procedure somefunction
public a
parameters mf1
a:= Inputbox('Enter Item', 'Enter Item', mf1)
(Do Something With a)
return
======================================================================
Now I can do what I want with variable a .
I would like to set it in MAIN procedure (First Procedure) so it works throughout program.
Franco
Hi!
You can define one function, eg:
Code: Select all
function SetupFunctionKeys
param cFormName
ON KEY CONTROL+F1 OF &cFormName ACTION ( Somefunction(File1->Field1) )
ON KEY CONTROL+F2 OF &cFormName ACTION ( Somefunction(File1->Field2) )
.
.
.
return .t.
When the function will be defined, you need to modify all your window forms by calling this function in ON INIT phrase.
It should be easy and quick to do, even if you have a lot of defined forms.
Re: Set function key to a Value
Posted: Thu Jul 28, 2016 12:58 am
by franco
I wrote
Procedure Main
use file1 // File1 is table with macros in it. Field2 := '123'
define window win1
ON KEY CONTROL+F2 OF Win1 ACTION ( Somefunction(File1->Field2) )
Close file1
Return
Procedure somefunction
public a
parameters mf1
a:= Inputbox('Enter Item', 'Enter Item', mf1)
(Do Something With a)
what I do with a in this situation is Mf1 it entered in the inputbox for me
if Mf1 is (" " = nothing) I need to enter they entry manually .
use table2
seek a and so on.
The only thing is now I would also like to use Mf1 in a textbox of the window.
** This is where Roberto`s code could work.
** Something like
if Win1 is focused
Roberto`s code
else
inputbox has focus
do Franco code
endif
How can I check which window has focus
return
Really what I need is really simple and we may have got of track.
my control+F2 is a word
at start of main program
instead of on key which does action I need Set KEY which types a word
Set Key Control+F2 to '123' then when I press ctrl+F2 program enters '123' for me. Macro
Like F1 is set to help no matter where you are
Thanks Franco