Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    [VB2010] e.SuppressKeyPress non funziona?

    Nulla di pratico, è solo un esercizio teorico per studiare l' uso di e.SuppressKeyPress.

    Praticamente voglio bloccare la pressione del tasto LWin (quello che equivale a premere Start) quando il mio Form è attivo.

    Ho messo ovviamente la proprietà KeyPreview del form a True.

    codice:
        Private Sub Frm1_KeyDown(sender As Object, _
            e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    
            Debug.Print("In down: " & e.KeyCode.ToString)
            If e.KeyCode = Keys.LWin Then
                Debug.Print("Ok, suppress down")
                e.SuppressKeyPress = True
            End If
    
        End Sub
    
        Private Sub Frm1_KeyUp(sender As Object, _
            e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
    
            Debug.Print("In Up: " & e.KeyCode.ToString)
            If e.KeyCode = Keys.LWin Then
                Debug.Print("Ok, suppress up")
                e.SuppressKeyPress = True
            End If
    
          End Sub
    Risultato:

    In down: LWin
    Ok, suppress down
    In Up: LWin
    Ok, suppress up
    ...................... ed il tasto Start viene tranquillamente premuto ....

    Dove è l' errore teorico??


    Ty

  2. #2
    Utente di HTML.it L'avatar di Vinsent
    Registrato dal
    May 2011
    Messaggi
    314
    Penso perchè è un tasto speciale e viene gestito a livello di SO.
    Ciao

  3. #3
    Confermo... effettivamente leggo che per "intercettarlo" ci vuole un keyboard hook.

    .

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 © 2026 vBulletin Solutions, Inc. All rights reserved.