[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 666
  • Last Modified:

Keyboard Insert / Overwrite Mode

How can I programmatically detect whether the keyboard is in insert mode or in overwrite mode?

I know that one way of doing this is to have an ActiveX StatusBar control with a Panel with Style = sbrIns. The Panel is Enabled if the keyboard is in insert mode, but only if the StatusBar is Enabled and physically visible. I do not want a StatusBar on the Form. So I would like to know how to do this with the Win32 API.
0
SimonORorke
Asked:
SimonORorke
1 Solution
 
GGRUNDYCommented:
BOOL isInsert =  ::GetKeyState(VK_INSERT)&1;
0
 
robpittCommented:
Insert/overwrite are application specific concepts, hence every app must keep track of this itself.

Whilst using GetKeyState(VK_INSERT)&1 might appear to work, this isn't advisable because this state toggles for all presses of Insert not just the ones you want to listen to.

A better solution is to have your editing window (where you type the text to) handle the WM_KEYDOWN message and toggle a variable.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now