Par exemple dans le code ci-dessous, j'aimerais que lorsque l'utilisateur appuie sur le bouton gauche plus d'1 seconde, le compteur défile tant que le bouton reste appuyé, comme le ferait un spingadget.
Code : Tout sélectionner
;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;
Enumeration FormWindow
#Window_1
EndEnumeration
Enumeration FormGadget
#Button_0
#Button_1
#Text_0
EndEnumeration
Procedure OpenWindow_1(x = 0, y = 0, width = 600, height = 400)
OpenWindow(#Window_1, x, y, width, height, "", #PB_Window_SystemMenu)
ButtonGadget(#Button_0, 230, 30, 70, 40, "+")
ButtonGadget(#Button_1, 340, 30, 60, 40, "-")
TextGadget(#Text_0, 260, 90, 110, 30, "0", #PB_Text_Center | #PB_Text_Border)
EndProcedure
OpenWindow_1()
n=0
AddWindowTimer(0, 1, 1000)
Repeat
event = WaitWindowEvent()
gadget = EventGadget()
type = EventType() ;#PB_EventType_LeftClick
TopTimer = EventTimer()
MDown=GetAsyncKeyState_(#VK_LBUTTON & 1) ;button is down
If MDown=32768
Debug "Mouse Down"
EndIf
Select Event
Case #WM_LBUTTONDOWN
If gadget = #Button_0
Debug "ok"
EndIf
Case #PB_Event_Timer
; If TopTimer=1
; Debug "ok"
; ;keybd_event_(#VK_LBUTTON, 0, 0, 0)
; ;keybd_event_(#VK_LBUTTON, 0,#KEYEVENTF_KEYUP, 0)
; EndIf
Case #PB_Event_Gadget
Select gadget
Case #Button_0
n=n+1
SetGadgetText(#Text_0, Str(n))
Case #Button_1
n=n-1
SetGadgetText(#Text_0, Str(n))
EndSelect
EndSelect
Until event = #PB_Event_CloseWindow
End