Control.IsKeyLocked(Keys) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Détermine si le verrou CAPS, NUM LOCK ou SCROLL LOCK est en vigueur.
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
Retours
true si la clé ou les clés spécifiées sont en vigueur ; sinon, false.
Exceptions
Le keyVal paramètre fait référence à une clé autre que la touche CAPS LOCK, NUM LOCK ou SCROLL LOCK.
Exemples
L’exemple de code suivant affiche une boîte de message indiquant si la clé spécifiée (la clé de verrouillage caps 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(Keys) méthode pour déterminer si les touches CAPS LOCK, NUM LOCK ou SCROLL LOCK sont activées individuellement ou en combinaison.