I have a button on a form with the two lines:

DO FORM frmFindRef TO dlcRef
dllReturn = thisform.FindPersonbyRef(dlcRef)

I want to set up function key F2 so that it emulates the click of this
button. I have tried ON KEY LABEL F2 but of course I can't put a reference
to THISFORM.CMDBUTTON.CLICK() so I am not sure how to go about this.

Many thanks

Stephen

Re: Using F2 to emulate a button click by Man-wai

Man-wai
Mon Aug 07 07:57:22 CDT 2006

> DO FORM frmFindRef TO dlcRef
> dllReturn = thisform.FindPersonbyRef(dlcRef)
> I want to set up function key F2 so that it emulates the click of this
> button. I have tried ON KEY LABEL F2 but of course I can't put a reference
> to THISFORM.CMDBUTTON.CLICK() so I am not sure how to go about this.

You should use the form.keypress() event, and set form.keypreview=.t. to
enable the event.

--
.~. Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Ubuntu 6.06) Linux 2.6.17.8
^ ^ 20:56:01 up 1:52 0 users load average: 1.00 1.03 1.03
news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk

Re: Using F2 to emulate a button click by Dan

Dan
Mon Aug 07 10:15:00 CDT 2006

In your OKL routine, you can refer to _Screen.Activeform.Whatever()

Dan

Stephen Ibbs wrote:
> I have a button on a form with the two lines:
>
> DO FORM frmFindRef TO dlcRef
> dllReturn = thisform.FindPersonbyRef(dlcRef)
>
> I want to set up function key F2 so that it emulates the click of this
> button. I have tried ON KEY LABEL F2 but of course I can't put a
> reference to THISFORM.CMDBUTTON.CLICK() so I am not sure how to go
> about this.
>
> Many thanks
>
> Stephen



Re: Using F2 to emulate a button click by Stephen

Stephen
Mon Aug 07 10:44:49 CDT 2006

Many thanks both - I will try both suggestions

Sincerely

Stephen

"Dan Freeman" <spam@microsoft.com> wrote in message
news:ev0SBRjuGHA.4160@TK2MSFTNGP06.phx.gbl...
> In your OKL routine, you can refer to _Screen.Activeform.Whatever()
>
> Dan
>
> Stephen Ibbs wrote:
>> I have a button on a form with the two lines:
>>
>> DO FORM frmFindRef TO dlcRef
>> dllReturn = thisform.FindPersonbyRef(dlcRef)
>>
>> I want to set up function key F2 so that it emulates the click of this
>> button. I have tried ON KEY LABEL F2 but of course I can't put a
>> reference to THISFORM.CMDBUTTON.CLICK() so I am not sure how to go
>> about this.
>>
>> Many thanks
>>
>> Stephen
>
>



Re: Using F2 to emulate a button click by veiko

veiko
Wed Aug 09 03:14:38 CDT 2006

On the FORM KeyPress Event use code
DO CASE
CASE nKeyCode=-1 && F2
NODEFAULT
THIS.CMDBUTTON.CLICK()
endCASE
and
On the FORM KeyPreview set .T.


"Stephen Ibbs" <stephen@datadevelopments.co.uk> wrote in message
news:O9Yk9AiuGHA.5032@TK2MSFTNGP04.phx.gbl...
>I have a button on a form with the two lines:
>
> DO FORM frmFindRef TO dlcRef
> dllReturn = thisform.FindPersonbyRef(dlcRef)
>
> I want to set up function key F2 so that it emulates the click of this
> button. I have tried ON KEY LABEL F2 but of course I can't put a reference
> to THISFORM.CMDBUTTON.CLICK() so I am not sure how to go about this.
>
> Many thanks
>
> Stephen
>
>



Re: Using F2 to emulate a button click by Stephen

Stephen
Wed Aug 09 06:22:26 CDT 2006

I am sorry everybody - I am clearly missing something.

I have created a brand new form, nothing on it, no code anywhere.

I set Keypreview = .T.

In the Keypress method I have:

LPARAMETERS nKeyCode, nShiftAltCtrl
MESSAGEBOX(nKeyCode)

When I run the form the messagebox appears for each key: Alphanumeric,
Enter, Tab, Delete etc, but not for any of the function keys. This is vfp9
straight out of the box with nothing fancy done with function key defaults
etc etc.

What am I missing?

Many thanks

Stephen


"veiko vanatoa" <theeba@hot.ee> wrote in message
news:44d99973$1_2@news.estpak.ee...
> On the FORM KeyPress Event use code
> DO CASE
> CASE nKeyCode=-1 && F2
> NODEFAULT
> THIS.CMDBUTTON.CLICK()
> endCASE
> and
> On the FORM KeyPreview set .T.
>
>
> "Stephen Ibbs" <stephen@datadevelopments.co.uk> wrote in message
> news:O9Yk9AiuGHA.5032@TK2MSFTNGP04.phx.gbl...
>>I have a button on a form with the two lines:
>>
>> DO FORM frmFindRef TO dlcRef
>> dllReturn = thisform.FindPersonbyRef(dlcRef)
>>
>> I want to set up function key F2 so that it emulates the click of this
>> button. I have tried ON KEY LABEL F2 but of course I can't put a
>> reference to THISFORM.CMDBUTTON.CLICK() so I am not sure how to go about
>> this.
>>
>> Many thanks
>>
>> Stephen
>>
>>
>
>



Re: Using F2 to emulate a button click by Carlos

Carlos
Wed Aug 09 07:51:05 CDT 2006


"Stephen Ibbs" <stephen@datadevelopments.co.uk> escribió en el mensaje
news:OMLpZY6uGHA.976@TK2MSFTNGP05.phx.gbl...
>I am sorry everybody - I am clearly missing something.
>
> I have created a brand new form, nothing on it, no code anywhere.
>
> I set Keypreview = .T.
>
> In the Keypress method I have:
>
> LPARAMETERS nKeyCode, nShiftAltCtrl
> MESSAGEBOX(nKeyCode)
>
> When I run the form the messagebox appears for each key: Alphanumeric,
> Enter, Tab, Delete etc, but not for any of the function keys. This is vfp9
> straight out of the box with nothing fancy done with function key defaults
> etc etc.
>
> What am I missing?
>
> Many thanks
>
> Stephen
>

You are missing that your F2 key is being eaten by a default menu keypress
assignment. Just do SET SYSMENU TO before running the form, and the SET
SYSMENU TO DEFAULT after. This way you will see that F2 is -1 for nKeyCode.

--
Carlos Alloatti




Re: Using F2 to emulate a button click by Carlos

Carlos
Wed Aug 09 07:52:46 CDT 2006

By the way, thats the Edit-Bookmarks-Next Shortcut/Bookmark menu that has
the F2 key assigned to it.

--
Carlos Alloatti


"Stephen Ibbs" <stephen@datadevelopments.co.uk> escribió en el mensaje
news:OMLpZY6uGHA.976@TK2MSFTNGP05.phx.gbl...
>I am sorry everybody - I am clearly missing something.
>
> I have created a brand new form, nothing on it, no code anywhere.
>
> I set Keypreview = .T.
>
> In the Keypress method I have:
>
> LPARAMETERS nKeyCode, nShiftAltCtrl
> MESSAGEBOX(nKeyCode)
>
> When I run the form the messagebox appears for each key: Alphanumeric,
> Enter, Tab, Delete etc, but not for any of the function keys. This is vfp9
> straight out of the box with nothing fancy done with function key defaults
> etc etc.
>
> What am I missing?
>
> Many thanks
>
> Stephen
>
>
> "veiko vanatoa" <theeba@hot.ee> wrote in message
> news:44d99973$1_2@news.estpak.ee...
>> On the FORM KeyPress Event use code
>> DO CASE
>> CASE nKeyCode=-1 && F2
>> NODEFAULT
>> THIS.CMDBUTTON.CLICK()
>> endCASE
>> and
>> On the FORM KeyPreview set .T.
>>
>>
>> "Stephen Ibbs" <stephen@datadevelopments.co.uk> wrote in message
>> news:O9Yk9AiuGHA.5032@TK2MSFTNGP04.phx.gbl...
>>>I have a button on a form with the two lines:
>>>
>>> DO FORM frmFindRef TO dlcRef
>>> dllReturn = thisform.FindPersonbyRef(dlcRef)
>>>
>>> I want to set up function key F2 so that it emulates the click of this
>>> button. I have tried ON KEY LABEL F2 but of course I can't put a
>>> reference to THISFORM.CMDBUTTON.CLICK() so I am not sure how to go about
>>> this.
>>>
>>> Many thanks
>>>
>>> Stephen
>>>
>>>
>>
>>
>
>