Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Catching F9 and F10 keys in modal form
Message
From
11/03/2017 05:08:39
 
 
To
11/03/2017 01:25:06
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01648923
Message ID:
01648934
Views:
40
this is a test code for keypress on modal form you can run :
local oform
oform=newObject("asup")
oform.show
retu

DEFINE CLASS asup AS form
	Top = 0
	Left = 0
	Height = 243
	Width = 375
	Caption = "Test keypress on modal form"
	MaxButton = .F.
	MinButton = .F.
	KeyPreview = .T.
	WindowType = 1  &&modal
	Name = "Form1"

	ADD OBJECT text1 AS textbox WITH ;
		Height = 37, ;
		Left = 156, ;
		TabIndex = 2, ;
		Top = 24, ;
		Width = 205, ;
		Name = "Text1"

	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 36, ;
		Left = 36, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		TabIndex = 1, ;
		Name = "Command1"

	ADD OBJECT label1 AS label WITH ;
		AutoSize = .T., ;
		WordWrap = .T., ;
		Caption = "F9 works as well in keypress but f10 is a public windows key and select the first menu.dont work in vfp as print screen...", ;
		Height = 32, ;
		Left = 12, ;
		Top = 180, ;
		Width = 332, ;
		BackColor = RGB(255,255,128), ;
		Name = "Label1"

	ADD OBJECT ylab AS label WITH ;
		FontSize = 11, ;
		Caption = "", ;
		Height = 37, ;
		Left = 12, ;
		Top = 108, ;
		Width = 337, ;
		ForeColor = RGB(255,0,0), ;
		Name = "yLab"

	PROCEDURE KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl
		thisform.ylab.caption=""
		if nkeycode=-8  
		thisform.ylab.caption=this.name+"  "+trans(nkeycode)+"  f9 pressed"
		endi

		if nkeycode=-9  
		thisform.ylab.caption=this.name+"  "+trans(nkeycode)+"  f10 pressed"
		endi
	ENDPROC

	PROCEDURE text1.KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl
		thisform.ylab.caption=""
		if nkeycode=-8  
		thisform.ylab.caption=this.name+"  "+trans(nkeycode)+"  f9 pressed"
		endi

		if nkeycode=-9  
		thisform.ylab.caption=this.name+"  "+trans(nkeycode)+"  f10 pressed"
		endi
	ENDPROC


ENDDEFINE
*
*-- EndDefine: asup
as you can see the keypress event (form,textbox) runs as well for f9 key
for f10 key its a windows reserved key (public key) and cannot coded from vfp (as key prtscreen...)
if you press f10 you can see the file menu selected.
dont retain what i said in my first answer please.
this is available for modal or modeless vfp forms(showwindow=0,1).for showwindow=2 f9 and f10 work with keypress event.
Previous
Reply
Map
View

Click here to load this message in the networking platform