System.Windows.Forms.Kyes
The spelling mistake in the title is intentional :)
Why? Just check out the System.Windows.Forms.Keys enumeration in the .NET (WinForm) Fx. This enum enumerates all the keys on your keyboard. However, someone seems to have made spelling mistakes while creating the enum. Instead of HangulMode we have HanguelMode which got corrected later by introducing the right enum name with the same value. There is one more a bit lower in the same page. This time its IMEAceept instead of IMEAccept.
Well these are small things. What I don't like is marking enums like these with [FlagsAttribute]. I have blogged about this before and its highly confusing as it indicates that these can be used as flags and OR'ed AND'ed. Sometime back someone had written code to pass around the keys the user had pressed at the same time. When user had Ctrl+Shift pressed he kept getting Ctrl only and the shift was dropped. The reason is simple the value of ControlKey is 17 and that of ShiftKey is 16 so the following expression is true
Keys.ControlKey == (Keys.ShiftKey | Keys.ControlKey);
This was fixed later with the System.Windows.Input.ModifierKey enum which is a true flags enum and can be OR'ed without issue. The only problem is that if you are effected in your WinForm code you need to take a reference to ModifierKey which is a WPF (.NET 3.0) assembly.
Comments
- Anonymous
February 15, 2007
The values ControlKey and ShiftKey are not for combining. One should write:Keys.F5 | Keys.Controlinstead:Keys.F5 | Keys.ControlKeyI believe those XyzControl values may be used in KeyDown/KeyUp when they are pressed alone. And modifier values without 'Key' suffix may be used to combine accords. - Anonymous
April 20, 2007
I read most of your blogs and found them really interesting. keep the good work going - Anonymous
September 18, 2007
free music videos myspace codes