Control.IsKeyLocked(Keys) Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menentukan apakah kunci CAPS LOCK, NUM LOCK, atau SCROLL LOCK berlaku.
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
Parameter
Mengembalikan
true jika kunci atau kunci yang ditentukan berlaku; jika tidak, false.
Pengecualian
Parameter keyVal mengacu pada kunci selain kunci CAPS LOCK, NUM LOCK, atau SCROLL LOCK.
Contoh
Contoh kode berikut menampilkan kotak pesan yang menunjukkan apakah kunci yang ditentukan (kunci Caps Lock dalam hal ini) berlaku.
#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
Keterangan
IsKeyLocked(Keys) Gunakan metode untuk menentukan apakah tombol CAPS LOCK, NUM LOCK, atau SCROLL LOCK aktif, baik secara individual maupun dalam kombinasi.