Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it L'avatar di giacomino_jack
    Registrato dal
    Feb 2002
    residenza
    Italy
    Messaggi
    202

    [VB6] Intercettare un tasto non visto da KeyDown e KeyUp



    Non riesco ad intercettare che tasto ho premuto su di un oggetto, tipo CheckBox, se il tasto premuto è un tasto che mi sposta il fuoco tipo TAB e le frecce di movimento.



    Esiste forse qualche API che mi puo' aiutare?

    GRAZIE.

  2. #2
    prova l'evento keypress o keyup...

    le frecce vengono riconosciute e mi sembra (mi sembra anche il TAB)
    Let's your dream came true!

  3. #3
    Utente bannato
    Registrato dal
    Sep 2003
    Messaggi
    1,012
    No, il TAB nn viene riconosciuto.

    Puoi usare questa API:

    codice:
    Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
    
    Private Sub Command1_Click()
    Dim Buffer(255) As Byte
    Call GetKeyboardState(Buffer(0))
    If Buffer(Asc(vbTab)) <> 0 Then
        MsgBox "Tasto Tab Premuto!"
    End If
    End Sub

  4. #4
    Utente di HTML.it L'avatar di giacomino_jack
    Registrato dal
    Feb 2002
    residenza
    Italy
    Messaggi
    202
    prova l'evento keypress o keyup...

    le frecce vengono riconosciute e mi sembra (mi sembra anche il TAB)
    E' la prima cosa che ho fatto ma su di un CheckBox non ha nessun effetto. ( NON SONO COSI' IMBRANATO. )

    Sto provando con l'API segnalata da IGUANA13 ma non riesco a capire cosa non va:
    La GetKeyboardState sembra valorizzare un buffer di tipo posizionale con il codice ascii del taso per indice ma, visualizzando l'intero buffer vengono valorizzati parecchi elementi che non c'entrano niente con il tasto premuto. Con il tasto TAB sembra funzionare ma con le frecce di movimento no.

    Provate questo esempio incollando in un form 2 oggetti Check e 2 oggetti TextBox in queste posizioni:
    Check1 Text1
    Check2 Text2
    La mia intenzione è imtercettare sul Check1 la pressione del tasto FrecciaGiu per poter scendere al Check2 saltando Text1

    Option Explicit

    Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long

    Private Sub Check1_KeyDown(KeyCode As Integer, Shift As Integer)
    MsgBox "Evento KeyDown"
    End Sub

    Private Sub Check1_KeyPress(KeyAscii As Integer)
    MsgBox "Evento KeyPress"
    End Sub

    Private Sub Check1_KeyUp(KeyCode As Integer, Shift As Integer)
    MsgBox "Evento KeyUP"
    End Sub

    Private Sub Check1_LostFocus()
    Dim i As Integer
    Dim Buffer(255) As Byte

    Call GetKeyboardState(Buffer(0))

    For i = 0 To 255 Step 2
    Debug.Print "idx(" & CStr(i) & ") = " & CStr(Buffer(i)) & " " & "idx(" & CStr(i + 1) & ") = " & CStr(Buffer(i + 1))
    Next i

    If Buffer(Asc(vbTab)) <> 0 Then
    MsgBox "Tasto TAB premuto!"
    End If
    End Sub
    Premendo il TAB sul Check1 viene visualizzato correttamente il messaggio ma, sostiuendo la IF di verifica con questa

    ...
    If Buffer(Asc(vbKeyDown)) <> 0 Then
    MsgBox "Tasto FrecciaGiu premuto!"
    End If
    non riesco ad intercettare un bel niente.

    SBAGLIO QUALCOSA


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.