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 last 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.

Start the conversation

Send me notifications when other members comment.

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

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close