Ask the Expert

How do I test and set the insert/overwrite keyboard mode from VB.NET?

How do I test and set the insert/overwrite keyboard mode from VB.NET?
You need to call the Win32 GetKeyState function. The following program snippet shows how to call it. Note that I did not include the form layout code in the sample.
Imports System.Runtime.InteropServices

Public Class Win32
    Declare Auto Function GetKeyState Lib "user32.dll" _
        (ByVal nVirtKey As Integer) As Integer
End Class

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Button1_Click(ByVal sender As System.Object, _
                              ByVal e As System.EventArgs) _
                              Handles Button1.Click
        ' &H2D is VK_INSERT.
        Dim x As Integer = Win32.GetKeyState(&H2D)
        If (&H1 = (&H1 And x)) Then
            Label1.Text = "Insert key down"
        Else
            Label1.Text = "Insert key up"
        End If
    End Sub
End Class

This was first published in May 2003

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: