Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Visual Basic 6 - Catturare il rilascio del bottone del mouse dopo la pressione
Forum - Visual Basic 6 - Catturare il rilascio del bottone del mouse dopo la pressione

Avatar
dylan666 (Normal User)
Pro


Messaggi: 129
Iscritto: 08/09/2009

Segnala al moderatore
Postato alle 10:35
Mercoledė, 09/09/2009
Mi servirebbe di rilevare il rilascio del bottone sinistro del mouse dopo che lo si č premuto. Per la pressione, grazie all'aiuto che ho avuto su questo forum, sono arrivato al seguente codice:

Codice sorgente - presumibilmente VB.NET

  1. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
  2. Private Sub Form_Load()
  3. Timer1.Enabled = True
  4. Timer1.Interval = 1
  5. End Sub
  6.  
  7. Private Sub Timer1_Timer()
  8. If GetAsyncKeyState(vbKeyLButton) = -32768 Then
  9. MsgBox "premuto"
  10. End If
  11. End Sub



Per il rilascio credevosi potesse fare una cosa cosė:

Codice sorgente - presumibilmente VB.NET

  1. Private Sub Timer2_Timer()
  2. If GetAsyncKeyState(vbKeyLButton) = -32768 Then
  3. 'MsgBox "premuto"
  4. Timer3.Enabled = True
  5. End If
  6. End Sub
  7.  
  8. Private Sub Timer3_Timer()
  9. If GetAsyncKeyState(vbKeyLButton) = 0 Then
  10. MsgBox "lasciato"
  11. Timer3.Enabled = False
  12. End If
  13. End Sub



Ovviamente non funziona... il timer non si ferma e continua a scrivere "Lasciato"... avete suggerimenti?
Vorrei evitare il Timer3.Interval = 0
Grazie

PM Quote
Avatar
dylan666 (Normal User)
Pro


Messaggi: 129
Iscritto: 08/09/2009

Segnala al moderatore
Postato alle 10:50
Mercoledė, 09/09/2009
Mie ero incartato tra i timer attivi ela disattivazione...

Codice sorgente - presumibilmente VB.NET

  1. Private Sub Timer2_Timer()
  2. If GetAsyncKeyState(vbKeyLButton) = -32768 Then
  3. 'MsgBox "premuto"
  4. Timer3.Enabled = True
  5. Timer2.Enabled = False
  6. End If
  7. End Sub
  8.  
  9. Private Sub Timer3_Timer()
  10. If GetAsyncKeyState(vbKeyLButton) = 0 Then
  11. MsgBox "lasciato"
  12. Timer3.Enabled = False
  13. End If
  14. End Sub


PM Quote