Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
KEYPRESS Property
Message
From
04/04/2016 04:49:11
 
 
To
03/04/2016 11:57:00
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01634227
Message ID:
01634241
Views:
70
*When you press mouse (any button) this fires an EVENT.it occurs after an action (by user or by code)
*in this sample click on any control or form with any mouse button and you see some properties returned by this event.
*Instead of distributing codes in any "mousedown" , can use bindevent to bind all controls concerned by same event.

Publi oform
oform=Newobject("asup")
oform.Show
Read Events
Retu
*
Define Class asup As Form
	Top = 11
	Left = 85
	Height = 350
	Width =600
	ShowWindow=2
	Caption = "Mousedown everyWhere on the form (any mouse button)"
	Name = "Form1"

	Add Object text1 As TextBox With ;
		Height = 37, ;
		Left = 12, ;
		Top = 24, ;
		Width = 121, ;
		Name = "Text1"

	Add Object edit1 As EditBox With ;
		Height = 139, ;
		Left = 140, ;
		Top = 24, ;
		Width = 300, ;
		forecolor=255,;
		readonly=.T.,;
		Name = "Edit1"

	Add Object command1 As CommandButton With ;
		Top = 36, ;
		Left = 460, ;
		Height = 25, ;
		Width = 97, ;
		Caption = "Command1", ;
		Name = "Command1"

	Add Object pageframe1 As PageFrame With ;
		ErasePage = .T., ;
		PageCount = 2, ;
		Top = 200, ;
		Left = 24, ;
		Width = 157, ;
		Height = 77, ;
		Name = "Pageframe1", ;
		Page1.Caption = "Page1", ;
		Page1.Name = "Page1", ;
		Page2.Caption = "Page2", ;
		Page2.Name = "Page2"

	Add Object image1 As Image With ;
		Picture = Home(1)+"graphics\gifs\morphfox.gif", ;
		Height = 120, ;
		Left = 400, ;
		Top = 190, ;
		Width = 116, ;
		Name = "Image1"


	Procedure my
	Lparameters nButton, nShift, nXCoord, nYCoord
*--- aevent create an array laEvents
	Aevents( myArray, 0)
*--- reference the calling object
	loObject = myArray[1]

	Local m.myvar
	TEXT to m.myvar textmerge  noshow
		-Event on Object : <<loObject.name>>
		-button pressed : <<trans(nbutton)>>
		-position on form: x=<<trans(nxcoord)>> , y=<<trans(nycoord)>>
*can put your custom code here with testing the values of parameters
	ENDTEXT

	Messagebox(m.myvar,0+32+4096,"",1200)
	Endproc

	Procedure Destroy
	Clea Events
	Endproc

	Procedure Init
	With Thisform
		TEXT to .edit1.value noshow
the mouseDown event occurs when the user presses a mouse button.
You must include an LPARAMETERS or PARAMETERS statement in the event procedure and specify a name
for each parameter. Visual FoxPro passes the MouseDown event parameters in  order :
nButton, nShift, nXCoord, nYCoord
		ENDTEXT
		For i=1 To .ControlCount
			Try
				Bindevent(.Controls(i),"mousedown",Thisform,"my")
			Catch
			Endtry
		Endfor
	Endwith
	Bindevent(Thisform,"mousedown",Thisform,"my")
	Endproc

Enddefine
*
*-- EndDefine: asup
Previous
Reply
Map
View

Click here to load this message in the networking platform