Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Continuous mousedown
Message
From
28/09/2006 15:47:39
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01157829
Message ID:
01157963
Views:
23
>Thierry,
>
>
>* cmd.MouseDown()
>
>do while mdown()
>   * do repetitive thing for example
>   thisform.text1.Value = thisform.text1.Value + 1
>   thisform.text1.Refresh()
>enddo
>
>

David:

The "problem" I see with your code is that there is no "buffer" between the time the user presses the button and the moment the repetitive task begins. I tested it with for example, creating a GUID, I managed to get 10-20 GUIDS created by clicking the button once really fast. This can be bad or good, it depends.

Depending on what needs to be done, a 500 to 1000 milliseconds wait time before the repetitive task starts works like a kind if "implicit" "Are you shure? messagebox".

Also adding some time between each repetitive task could be good, or bad, depends on whats needs to be done. The interval could be adjusted in the timer event to make things "accelerate" over time, for example (stealing some of your code):
Public oForm

oForm = Newobject("repeatsample2")

oForm.Show()

Define Class repeatsample2 As Form


	Height = 67
	Width = 242
	DoCreate = .T.
	AutoCenter = .T.
	Caption = "Form1"
	AllowOutput = .F.
	Name = "Form1"


	Add Object Command1 As CommandButton With ;
		Top = 24, ;
		Left = 144, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command1"


	Add Object Timer1 As Timer With ;
		Top = 24, ;
		Left = 0, ;
		Height = 23, ;
		Width = 23, ;
		Interval = 0, ;
		Name = "Timer1"


	Add Object Text1 As TextBox With ;
		Height = 23, ;
		Left = 24, ;
		Top = 24, ;
		Width = 108, ;
		Name = "Text1"

	Procedure Command1.MouseDown
	Lparameters nButton, nShift, nXCoord, nYCoord
	Thisform.Text1.Value = 1
	Thisform.Text1.Refresh()

	*!* Single task here
	Thisform.Timer1.Interval = 1000
	Thisform.Timer1.Reset()
	Thisform.Timer1.Enabled = .T.
	Endproc

	Procedure Command1.MouseUp
	Lparameters nButton, nShift, nXCoord, nYCoord
	Thisform.Timer1.Enabled = .F.
	Endproc

	Procedure Timer1.Timer
	Thisform.Text1.Value = Thisform.Text1.Value + 1
	Thisform.Text1.Refresh()

	*!* Repetitive task here
	If This.Interval > 200 Then
		This.Interval = This.Interval - 200
	Else
		If This.Interval > 10 Then
			This.Interval = This.Interval - 10
		Endif
	Endif
	Endproc

Enddefine
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform