Create custom shortcut combination not contained in the System.Windows.Forms.Shortcut enumeration

The usage of shortcuts is one of the key features to enable the user to use an application completely using the keyboard. When using the OpenEdge Architect we all know that Ctrl + S saves the current changes from for example code files. In an ABL GUI for .NET application this is typically achieved by assigning a shortcut key from the System.Windows.Forms.Shortcut enumeration to a menu item or ribbon tool – no matter if you are using the toolbar and menu components from Microsoft or Infragistics. A common concern of developers moving from the ABL GUI to the GUI for .NET is that the ABL GUI seems to support more combinations of the modifier keys (CTRL, ALT, SHIFT) and regular keys or cursor keys.

Within C# you just combine the desired keys using a bitwise or operator and then cast the result to System.Windows.Forms.Shortcut.

To achieve the same in the ABL you first have to combine the desired key enum values using the bitwise or operator (Progress.Util.EnumHelper:Or) and cast the result to Int32 (Progress.Util.CastUtil:ToInt32) and convert that into an Enum object of the type (System.Windows.Forms.Shortcut)  using (System.Enum:ToObject). Finally you can cast that object reference to the System.Windows.Forms.Shortcut type.

The object referenced in the instance variable oShortcut can then be assigned to for example the Infragistics.Win.UltraWinToolbars.SharedProps:Shortcut property related to a ButtonTool object.

As a slightly more usual example is the following code which creates a shortcut ALT + A, which is typically used by menu mnemonics and thus not foreseen in the Shortcuts collection.

Marko Rüterbories

About Marko Rüterbories

Marko Rüterbories has 18 years of experience as developer, administrator, consultant and trainer on various technologies including Windows and Web Application development, various databases including Progress OpenEdge, MySQL and Oracle as well as Linux and Windows server administration. He started using the .NET framework for development just after it was released about 9 years ago. He started using Progress and OpenEdge more than 8 years ago. Marko started using the OpenEdge GUI for .NET while it was still in beta three years ago. Marko currently provides consulting and training services for OpenEdge ABL and GUI for .NET related subjects and uses his experience as a developer and software architect of many successful applications in the international projects he is involved in as a consultant working for Consultingwerk Ltd.. Marko is co-architect of our successful SmartComponent Library developer framework.
This entry was posted in GUI for .NET and tagged , , . Bookmark the permalink.

2 Responses to Create custom shortcut combination not contained in the System.Windows.Forms.Shortcut enumeration

  1. Anne says:

    Interesting, Marko, thank you.

  2. Gerd says:

    Great topic ! Thanks !

Leave a Reply

Your email address will not be published. Required fields are marked *



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>