Control.IsKeyLocked(Keys) Méthode

Définition

Détermine si la touche Verr. maj, Verr. Num ou Arrêt défil est activée.

public:
 static bool IsKeyLocked(System::Windows::Forms::Keys keyVal);
public static bool IsKeyLocked (System.Windows.Forms.Keys keyVal);
static member IsKeyLocked : System.Windows.Forms.Keys -> bool
Public Shared Function IsKeyLocked (keyVal As Keys) As Boolean

Paramètres

keyVal
Keys

Membre Verr. maj, Verr. Num ou Arrêt défil de l'énumération Keys.

Retours

Boolean

true si la ou les touches spécifiées sont activées ; sinon, false.

Exceptions

Le paramètre keyVal fait référence à une touche autre que Verr. maj, Verr. Num ou Arrêt défil.

Exemples

L’exemple de code suivant affiche une boîte de message indiquant si la clé spécifiée (la clé de verrouillage des majuscules dans ce cas) est en vigueur.

#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::Windows::Forms;
int main()
{
   if (Control::IsKeyLocked( Keys::CapsLock )) {
      MessageBox::Show( "The Caps Lock key is ON." );
   }
   else { 
      MessageBox::Show( "The Caps Lock key is OFF." );
   }

}
using System;
using System.Windows.Forms;

public class CapsLockIndicator
{
    public static void Main()
    {
        if (Control.IsKeyLocked(Keys.CapsLock)) {
            MessageBox.Show("The Caps Lock key is ON.");
        }
        else {
            MessageBox.Show("The Caps Lock key is OFF.");
        }
    }
}

' To compile and run this sample from the command line, proceed as follows:
' vbc controliskeylocked.vb /r:System.Windows.Forms.dll /r:System.dll 
' /r:System.Data.dll /r:System.Drawing.dll

Imports System.Windows.Forms

Public Class CapsLockIndicator
   
    Public Shared Sub Main()
        if Control.IsKeyLocked(Keys.CapsLock) Then
            MessageBox.Show("The Caps Lock key is ON.")
        Else
            MessageBox.Show("The Caps Lock key is OFF.")
        End If
    End Sub
End Class

Remarques

Utilisez la IsKeyLocked propriété pour déterminer si les touches CAPS LOCK, NUM LOCK ou SCROLL LOCK sont activées, qu’elles soient individuelles ou combinées.

S’applique à