I'm trying to override the SHIFT-SPACE "negative feature" in the Winforms
datagrid, to only be a space.
The following link describes this:
http://www.dotnet247.com/247referenc...52/262224.aspx
In this procedure, MS suggested to use SendKeys.Send(" "), but I am finding
that this locks my machine, and SendWait() causes an infinite loop of
messages (stack overflow). How to convert a SHIFT-SPACE message to be just
a SPACE? Below is what I have.
------------------------------------
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
Keys keyCode = (Keys) msg.WParam.ToInt32() & Keys.KeyCode;
if (msg.Msg == WM_KEYDOWN && keyCode == Keys.Space && Control.ModifierKeys
== Keys.Shift) {
byte[] keyStates = new byte[255];
GetKeyboardState(keyStates[0]); //load the keyboard
keyStates[16] = 0; // turn off the shift key
SetKeyboardState(keyStates[0]); //set the new keyboard state
// //**************
// // SendKeys doesn't work here. Locks the machine
// //**************
SendKeys.Send(" "); //boom
return true;
}
else
return base.ProcessCmdKey (ref msg, keyData);
}