473,513 Members | 2,514 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert Key State

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
May 31 '07 #1
5 4200
Hi John,

My.Computer.Keyboard object exposes several properties about keyboard key
status, such as Ctrl key, Caps Lock key, Alt key and Scroll Lock key.
However, it does not contain a property for checking insert key status. So
we have to p/invoke Win32 API for this task. You may use GetKeyState() API
by passing VK_INSERT:

<DllImport("User32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)_
Friend Shared Function GetKeyState(ByVal KeyCode As Integer) As Short
End Function

Private VK_INSERT As Integer = &H2D

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If ((GetKeyState(VK_INSERT) And 1) 0) Then
MessageBox.Show("Insert key")
Else
MessageBox.Show("No Insert key")
End If
End Sub

Actually, this API is what My.Computer.Keyboard object called internally
for its properties. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 1 '07 #2
Thank you very much Jeffry, just what I wanted.

Perhaps Microsoft can add InsertState to My.Computer.Keyboard !

If the InsertStatus is wrong (I want to make sure it is not overwriting),
how do I go about changing it - I can't find a SetKeyState API call?

Thanks,
--
John Austin
""Jeffrey Tan[MSFT]"" wrote:
Hi John,

My.Computer.Keyboard object exposes several properties about keyboard key
status, such as Ctrl key, Caps Lock key, Alt key and Scroll Lock key.
However, it does not contain a property for checking insert key status. So
we have to p/invoke Win32 API for this task. You may use GetKeyState() API
by passing VK_INSERT:

<DllImport("User32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)_
Friend Shared Function GetKeyState(ByVal KeyCode As Integer) As Short
End Function

Private VK_INSERT As Integer = &H2D

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If ((GetKeyState(VK_INSERT) And 1) 0) Then
MessageBox.Show("Insert key")
Else
MessageBox.Show("No Insert key")
End If
End Sub

Actually, this API is what My.Computer.Keyboard object called internally
for its properties. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 1 '07 #3
Hi John,

Yes, I agree with you. You may submit a suggestion to the product team at
the link below:
https://connect.microsoft.com/VisualStudio

Regarding your further question, there is no SetKeyState API. You should
use SendKeys.Send() method to toggle the insert key with parameter
"{INSERT}".

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 4 '07 #4
I think I have have been dafter than usual! I placed your code on a form
containing a textbox and button (your code fires when the button is pressed).
Regardless of the state of the Insert key (correctly displayed by your
procedure), the textbox appeared to always be in insert mode!

Best regards,
--
John Austin
""Jeffrey Tan[MSFT]"" wrote:
Hi John,

Yes, I agree with you. You may submit a suggestion to the product team at
the link below:
https://connect.microsoft.com/VisualStudio

Regarding your further question, there is no SetKeyState API. You should
use SendKeys.Send() method to toggle the insert key with parameter
"{INSERT}".

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 4 '07 #5
Hi John,

Yes, this is a by design behavior. The .Net TextBox will not recognize the
INSERT key status to switch between overwrite and insert modes. If you want
to support these 2 modes, you have to code yourself to support them, please
refer to the link below:
"27.11 How can I place a TextBox in overwrite mode instead of insert mode?"
http://www.syncfusion.com/FAQ/Window...94c.aspx#q829q

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 5 '07 #6

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

Similar topics

0
2475
by: Rajesh Kapur | last post by:
I have a master slave configuration on linux machines running MySQL 4.0.21. Once every hour, a process deletes about 9000 rows and re-inserts fresh data on the master. The master process completes...
1
2912
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;
1
5389
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. ...
2
3169
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
9
4027
by: cavassinif | last post by:
I need to dynamic select a column in which insert a vale based on a parameter value, I have this code, but it throws an incorrect syntax error. How do I dinamically select a column to insert...
11
28283
by: Ted | last post by:
OK, I tried this: USE Alert_db; BULK INSERT funds FROM 'C:\\data\\myData.dat' WITH (FIELDTERMINATOR='\t', KEEPNULLS, ROWTERMINATOR='\r\n');
3
5143
by: mahajanvit | last post by:
Hi one and all I got this problem during my project. So in order to solve this I made a very small application. I am trying to insert using SP and sqldatasource control. I know that while using...
6
3440
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...
4
3110
by: Bob | last post by:
Hi all, I'm trying to import data, modify the data then insert it into a new table. The code below works fine for it but it takes a really long time for 15,000 odd records. Is there a way I...
0
2275
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...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7539
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
5686
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,...
1
5090
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.