Control.IsKeyLocked(Keys) Methode

Definitie

Bepaalt of de CAPS LOCK-, NUM LOCK- of SCROLL LOCK-toets van kracht is.

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

Parameters

keyVal
Keys

Het CAPS LOCK-, NUM LOCK- of SCROLL LOCK-lid van de Keys opsomming.

Retouren

true indien de opgegeven sleutel of sleutels van kracht zijn; anders, false.

Uitzonderingen

De keyVal parameter verwijst naar een andere sleutel dan caps lock, NUM LOCK of SCROLL LOCK.

Voorbeelden

In het volgende codevoorbeeld wordt een berichtvak weergegeven dat aangeeft of de opgegeven sleutel (in dit geval de Caps Lock-toets) van kracht is.

#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

Opmerkingen

Gebruik de IsKeyLocked(Keys) methode om te bepalen of de TOETSEN CAPS LOCK, NUM LOCK of SCROLL LOCK afzonderlijk of in combinatie zijn ingeschakeld.

Van toepassing op