joe_pool_is
Contributor
I have created some code to try to capture the Print Screen key, but I never have been able to get it to fire for either my MDI form nor any of the Child forms.
Here's what I have written:
Anyway, other fires needed attention, and I forgot about it. I left a breakpoint on the Screen Capture line.
Today, while inputting some text in one of the Child forms, I had to insert an underscore ("_"). Imagine my shock when I hit that breakpoint!
I did a little debugging, and found that the Key Code contains the following:
e.KeyCode = LButton | MButton | Back | ShiftKey | Space | F17
The Key Data displays this whenever I mouse over it:
e.KeyData = LButton | MButton | Back | ShiftKey | Space | F17 | Shift
The Print Screen identifier contains this:
Keys.PrintScreen = MButton | Back | Space
From System.Windows.Forms.Keys (Using VS2008):
I have coded some formatting fixes for lazy people and my program inserts and/or deletes some text, so I initially wasn't surprised by the Space and Back character being in the mix. It turns out, however, that my formatting is not what happens first.
Could someone tell me why I get this strange data instead of a Print Screen keypress?
At the least, whenever I press the Print Screen button, I would expect the MButton, Back, and Space values to all be included in the Key Code or Key Data - and certainly not whenever I call underscore (Shift + Hyphen).
Here's what I have written:
Code:
void MdiForm_KeyDown(object sender, KeyEventArgs e) {
if ((e.KeyCode == Keys.PrintScreen) || ((e.KeyData & Keys.PrintScreen) == Keys.PrintScreen)) {
ScreenCapture(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
e.Handled = true;
}
}
Today, while inputting some text in one of the Child forms, I had to insert an underscore ("_"). Imagine my shock when I hit that breakpoint!
I did a little debugging, and found that the Key Code contains the following:
e.KeyCode = LButton | MButton | Back | ShiftKey | Space | F17
The Key Data displays this whenever I mouse over it:
e.KeyData = LButton | MButton | Back | ShiftKey | Space | F17 | Shift
The Print Screen identifier contains this:
Keys.PrintScreen = MButton | Back | Space
From System.Windows.Forms.Keys (Using VS2008):
LButton = 1
RButton = 4
Back = 8
ShiftKey = 16
Space = 32
PrintScreen = 44
F17 = 128
RButton = 4
Back = 8
ShiftKey = 16
Space = 32
PrintScreen = 44
F17 = 128
I have coded some formatting fixes for lazy people and my program inserts and/or deletes some text, so I initially wasn't surprised by the Space and Back character being in the mix. It turns out, however, that my formatting is not what happens first.
Could someone tell me why I get this strange data instead of a Print Screen keypress?
At the least, whenever I press the Print Screen button, I would expect the MButton, Back, and Space values to all be included in the Key Code or Key Data - and certainly not whenever I call underscore (Shift + Hyphen).