Bonjour, je suis en train de réaliser un potentiomètre avec un objet image. Mon image représente un cercle sur un fond transparent (d'où l'intéret de l'objet image).
Je voudrais réaliser une variable qui lorsque je clique sur l'image (dans le cercle), la variable m'affiche une valeur avec comme coordonnées x et y.
Voici un extrait de mon code qui fonctionne mais la variable me donne une valeur erronée :
Dim nuRo As Long
Dim Ycapture As Long, Xcapture As Long
Dim variation As Long, bouton0 As Long
Dim btn_down As Boolean
Dim TwipX As Integer
Dim TwipY As Integer
Private Sub Form_Load()
Me.ScaleMode = 3
btn_down = False
Ycapture = -1
TwipX = Screen.TwipsPerPixelX
TwipY = Screen.TwipsPerPixelY
End Sub
Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Ycapture = Y / TwipY
Xcapture = X / TwipX
bouton0 = variation
btn_down = True
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If btn_down Then
If Xcapture = -1 Then Exit Sub
If ((X / TwipX) > 0 And X / TwipX < 246) Then
nuRo = bouton0 - ((180 * (Atn((X / TwipX) / (Y / TwipY))) / 3.14159265358979) - (180 * Atn(Xcapture / Ycapture) / 3.14159265358979))
nuRo = (nuRo + 360) Mod 360
variation = nuRo
End If
End If
End Sub
Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Ycapture = -1
Xcapture = -1
btn_down = False
End Sub
Private Sub Timer1_Timer()
Label1.Caption = variation
End Sub
Pour info ma form est en pixel et j'affiche ma variable dans un label.
J'ai beau chercher sur tous les forum mais je n'ai pas réussi a trouver mon bonheur.
Merci de votre aide. Help !