Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2054 connectés 

 


Dernière réponse
Sujet : Connaitre position souris [VB]
karlkox Dans un bas :
-----------
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
 
Public Const WM_LBUTTONUP = &H202
Public Const WM_MBUTTONUP = &H208
Public Const WM_RBUTTONUP = &H205
Public Const WM_LBUTTONDOWN = &H201
 
Public OldWindowProc As Long, OldWindowProc2 As Long
 
Public Function NewWindowProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    If Msg = WM_LBUTTONDOWN Then
    Debug.Print "CLICK"
    Exit Function
    End If
     
    NewWindowProc = CallWindowProc( _
        OldWindowProc, hwnd, Msg, _
        wParam, lParam)
End Function
 
Dans le Form :
-------------
Private Sub Form_Load()
    OldWindowProc = SetWindowLong(hwnd, _
       GWL_WNDPROC, AddressOf NewWindowProc)
end Sub
 
Private Sub Form_Unload(Cancel As Integer)
SetWindowLong hwnd, GWL_WNDPROC, _
        OldWindowProc
End Sub
 
En gros c'est ca.

Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
karlkox Dans un bas :
-----------
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
 
Public Const WM_LBUTTONUP = &H202
Public Const WM_MBUTTONUP = &H208
Public Const WM_RBUTTONUP = &H205
Public Const WM_LBUTTONDOWN = &H201
 
Public OldWindowProc As Long, OldWindowProc2 As Long
 
Public Function NewWindowProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    If Msg = WM_LBUTTONDOWN Then
    Debug.Print "CLICK"
    Exit Function
    End If
     
    NewWindowProc = CallWindowProc( _
        OldWindowProc, hwnd, Msg, _
        wParam, lParam)
End Function
 
Dans le Form :
-------------
Private Sub Form_Load()
    OldWindowProc = SetWindowLong(hwnd, _
       GWL_WNDPROC, AddressOf NewWindowProc)
end Sub
 
Private Sub Form_Unload(Cancel As Integer)
SetWindowLong hwnd, GWL_WNDPROC, _
        OldWindowProc
End Sub
 
En gros c'est ca.
HelloWorld Arg ...
C'est ce que je redoutais ...
Bah tant pis ...
Merci de votre aide
Ventilo Il faudrait que tu utilse un HOOK, va voir dans la MSDN sur microsoft, va voir les functions sur les shell hook....
HelloWorld Oui mais ...
COMMENT JE FAIT POUR SAVOIR QUAND IL CLIQUE AVEC LA SOURIS ?
(je rappelle que mon programme tourne en tache de fond (genre minimisé dans le systay) et qu'il bosse à chaque clic de souris n'importe ou sur l'écran/dans n'importe quel programme ...)
darkoli ben le plus simple c'est pour chaque evenement "clic de la souris" tu memorise les coordonnées x et y et des le 2° clic tu calcules la distances.
 
tu veux la formule ?
  x=x1-x2
  y=y1-y2
  d=racine_carré((x*x)+(y*y))
HelloWorld viv merci ...
mais ca je l'avais trouvé tout seul en fouinant un peu ...;)
ce qui m'interresse ... c'est savoir pour le click ...
Kyle_Katarn GetCursorPos
HelloWorld Je pense qu'il faut passer par les API mais je sais pas laquelle ...
(je cherche à connaitre la position et l'état de la souris/ses boutons sur l'écran ; en fait pouvoir mesurer la distance qui sépare 2 clics n'importe où sur l'écran)
thx

Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)