Q

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

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

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:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close