OVH Cloud OVH Cloud

Question sur postion souris / evenement bouton

2 réponses
Avatar
Daniel
Salut
Je dois creer un bouton qui incremente et decremente une valeur dans un
textbox a l'aide de bouton car ceux fourni dans VB (updown,et spinner) ne me
conviennent pas.

Tout fonctionne excepté que si on déplace le curseur a l'extérieur des zones
du bouton le textbox continue a s'incrémenté malgré tout.

Alors ma question, est que je voudrais vérifier si ma souris est toujours
sur le bouton lorsque j'incrémente

Merci

Voici un exemple

Private Sub BUPValue_MouseDown(Index As Integer, Button As Integer, Shift As
Integer, x As Single, y As Single)
Dim t#
MouseDown = True
If Val(Batcher(Index).Text) + 0.01 <= 1.5 Then
Batcher(Index).Text = Format(Val(Batcher(Index).Text) + 0.01, "0.00")
End If
While MouseDown = True And Timer - t < 0.4 And Timer >= t
DoEvents
Wend

While MouseDown = True
If Val(Batcher(Index).Text) + 0.01 <= 1.5 Then
Batcher(Index).Text = Format(Val(Batcher(Index).Text) + 0.01, "0.00")
End If
t = Timer
Do While Timer - t < 0.04 And Timer >= t
DoEvents
Loop
Wend

'suite de mon code une fois le bouton relaché
End Sub

Private Sub BUPValue_MouseUp(Index As Integer, Button As Integer, Shift As
Integer, x As Single, y As Single)
MouseDown = False

End Sub

2 réponses

Avatar
X
Bonjour,

Voix l'évènement:

Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As
Single)
' X et Y sont la position
End Sub

--
Merci beaucoup, au revoir et à bientôt :o)
------
Site logiciels
http://irolog.free.fr
Mail
http://irolog.free.fr/ecrire/index.htm
Site perso
http://irolog.free.fr/joe/index.htm
Principe d'utilisation des news Groups
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
------------------------------------------------------------------------------------
"Daniel" a écrit dans le message de news:
%
Salut
Je dois creer un bouton qui incremente et decremente une valeur dans un
textbox a l'aide de bouton car ceux fourni dans VB (updown,et spinner) ne
me
conviennent pas.

Tout fonctionne excepté que si on déplace le curseur a l'extérieur des
zones
du bouton le textbox continue a s'incrémenté malgré tout.

Alors ma question, est que je voudrais vérifier si ma souris est toujours
sur le bouton lorsque j'incrémente

Merci

Voici un exemple

Private Sub BUPValue_MouseDown(Index As Integer, Button As Integer, Shift
As
Integer, x As Single, y As Single)
Dim t#
MouseDown = True
If Val(Batcher(Index).Text) + 0.01 <= 1.5 Then
Batcher(Index).Text = Format(Val(Batcher(Index).Text) + 0.01, "0.00")
End If
While MouseDown = True And Timer - t < 0.4 And Timer >= t
DoEvents
Wend

While MouseDown = True
If Val(Batcher(Index).Text) + 0.01 <= 1.5 Then
Batcher(Index).Text = Format(Val(Batcher(Index).Text) + 0.01, "0.00")
End If
t = Timer
Do While Timer - t < 0.04 And Timer >= t
DoEvents
Loop
Wend

'suite de mon code une fois le bouton relaché
End Sub

Private Sub BUPValue_MouseUp(Index As Integer, Button As Integer, Shift As
Integer, x As Single, y As Single)
MouseDown = False

End Sub




Avatar
Daniel
Merci mais ca fonctionne pas comme je le veux cet evenement
j'ai finalement trouvé

j'ai utilisé 2 fonction API pour lire la position de la souris

public Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As
Long
Public Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long,
lpPoint As PointAPI) As Long

Type PointAPI
X As Long
Y As Long
End Type


While MouseDown = True
Call GetCursorPos(MousePos)
ScreenToClient BDownValue(Index).hwnd, MousePos
If MousePos.X >= 0 And MousePos.X < BDownValue(Index).Width / 15 _
And MousePos.Y >= 0 And MousePos.Y < BDownValue(Index).Height / 15 Then
If Val(Batcher(Index).Text) - 0.01 >= 0.5 Then
Batcher(Index).Text = Format(Val(Batcher(Index).Text) - 0.01, "0.00")
End If
t = Timer
While Timer - t < 0.04 And Timer >= t
DoEvents
Wend
End If
DoEvents
Wend

"X" a écrit dans le message de news:

Bonjour,

Voix l'évènement:

Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As
Single)
' X et Y sont la position
End Sub

--
Merci beaucoup, au revoir et à bientôt :o)
------
Site logiciels
http://irolog.free.fr
Mail
http://irolog.free.fr/ecrire/index.htm
Site perso
http://irolog.free.fr/joe/index.htm
Principe d'utilisation des news Groups
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
--------------------------------------------------------------------------


----------
"Daniel" a écrit dans le message de news:
%
> Salut
> Je dois creer un bouton qui incremente et decremente une valeur dans un
> textbox a l'aide de bouton car ceux fourni dans VB (updown,et spinner)


ne
> me
> conviennent pas.
>
> Tout fonctionne excepté que si on déplace le curseur a l'extérieur des
> zones
> du bouton le textbox continue a s'incrémenté malgré tout.
>
> Alors ma question, est que je voudrais vérifier si ma souris est


toujours
> sur le bouton lorsque j'incrémente
>
> Merci
>
> Voici un exemple
>
> Private Sub BUPValue_MouseDown(Index As Integer, Button As Integer,


Shift
> As
> Integer, x As Single, y As Single)
> Dim t#
> MouseDown = True
> If Val(Batcher(Index).Text) + 0.01 <= 1.5 Then
> Batcher(Index).Text = Format(Val(Batcher(Index).Text) + 0.01, "0.00")
> End If
> While MouseDown = True And Timer - t < 0.4 And Timer >= t
> DoEvents
> Wend
>
> While MouseDown = True
> If Val(Batcher(Index).Text) + 0.01 <= 1.5 Then
> Batcher(Index).Text = Format(Val(Batcher(Index).Text) + 0.01, "0.00")
> End If
> t = Timer
> Do While Timer - t < 0.04 And Timer >= t
> DoEvents
> Loop
> Wend
>
> 'suite de mon code une fois le bouton relaché
> End Sub
>
> Private Sub BUPValue_MouseUp(Index As Integer, Button As Integer, Shift


As
> Integer, x As Single, y As Single)
> MouseDown = False
>
> End Sub
>
>