473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Insert/overwrite key state

AC
Hi all, I'm using .NET 2003 and trying to use the status bar to display
current key states, as so very many apps do - like num lock, caps lock,
etc. I'm using the following code (in c sharp but equally applicable
to vb, c++ etc.):

[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true,
CallingConvention=CallingConvention.Winapi)]
private static extern short GetKeyState(int keyCode);

private const int VK_CAPITAL = 0x14;
private const int VK_INSERT = 0x2D;
private const int VK_OVERWRITE = 0x2D;
private const int VK_NUMLOCK = 0x90;
private const int VK_SCROLL = 0x91;

public bool IsKeyOn(int nKey)
{
return (GetKeyState(nKey) & 1) > 0;
}

....

string strBob = (IsKeyOn(VK_INSERT) ? "INS" : "OVR");

This works great for NUM lock & CAPS lock (haven't bothered with SCROLL
lock) but doesn't appear to work properly with INSERT/OVERWRITE -
sometimes it's right, sometimes not - switching apps affects it, etc.
Also, while it's right just after building on my PC, install the
packaged app onto an NT4 machine and it seems consitently wrong.

I've tried just about everything I can think of with this and it's
making my head hurt as the (limited) documentation appears to tell me
it should work. Any ideas very gratefully received.

Or if I've posted it into the completely wrong group, it'd be helpful
to know that too.

Thanks for your time,
Toot.

Nov 17 '05 #1
0 1755

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: johngilmer | last post by:
By default, when I type into a text box, it inserts the text into the existing text rather than overwriting the existing text. If I hit the "insert" key on my keyboard, it switches the mode to...
1
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
0
by: **Developer** | last post by:
I have a RichTextBox and I want to programmatically change the Insert/Overwrite mode. I tried the following but it doesn't appear to change the mode. Pressing the Insert or Ins key does change...
3
by: Developer | last post by:
I use the RichTextBox and sometimes put it into overwrite mode. I'd like the cursor to show whether its in overwrite or insert mode. I often use Cursor.Current = Cursors.WaitCursor and...
1
by: Istvan | last post by:
Hi ! Can somebody tell me if it's possible to overwrite an element definition when I derive an complexType (with extension, or something like this ) ? The base complexType looks like: ...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
5
by: =?Utf-8?B?Sm9obiBBdXN0aW4=?= | last post by:
I want to ensure that the Insert Key state is 'Insert' rather than 'Overwrite' in a particular textbox (or possibly for the whole form). How can I go about this? -- John Austin
0
by: magnolia | last post by:
i created a trigger that will record the changes made to a table .everything works fine except the insert query.whenerever i try to insert a record it fires insert and update triger at the same time...
8
by: Joe Duchtel | last post by:
Hello - I have the following code to detemine a file name when my application is saving a file. The problem is that if the file already exists and I select the Yes button in the "Do you want to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.