How to convert ACCELERATOR to Shortcut?

Posted by rbf on 14-Dec-2012 03:13

When embedding a GUI window in .NET I am converting the GUI menu to an UltraWinToolbar.

Everything can be converted dynamically except for the accelerators afaik. Beside the fact that the names are different, in Infragistics the shortcuts are (of course) static members (of System.Windows.Forms.Shortcut).

Can I dynamically convert my Progress accelerators to these shortcuts or is the only way to create a gigantic case statement?

All Replies

Posted by Admin on 14-Dec-2012 07:45

You may also try to do some clever processing around

System.Enum:Parse ("ShiftF1") .

http://msdn.microsoft.com/en-us//library/system.enum.parse.aspx

And this may help you in cases where the Shortcut Enum is not complete enough:

http://blog.consultingwerk.de/consultingwerkblog/2011/10/create-custom-shortcuts-not-contained-in-the-system-windows-forms-shortcut-enumeration/

Posted by rbf on 16-Dec-2012 06:16

Thanks Mike that looks very promising I will look into this!

Posted by rbf on 03-Jan-2013 06:51

Hi Mike,

mikefe wrote:

You may also try to do some clever processing around

System.Enum:Parse ("ShiftF1") .

http://msdn.microsoft.com/en-us//library/system.enum.parse.aspx

I am trying to do this but unfortunately the syntax is not so easy.

System.Enum:Parse has at least two parameters of which the first

has to be a System.Type and I have no clue what to enter there.

I tried a lot of things and saw in Marco's article that he is also doing strange

conversions in a similar case such as "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."

I suppose something similar needs to be done here, but to me it is rocket science.

What I need to do is something along these lines:

MyTool:SharedProps:Shortcut = System.Enum:Parse(System.Windows.Forms.Shortcut, hMenuItem:ACCELERATOR) no-error.

Can you help me out?

-peter

Posted by Admin on 03-Jan-2013 08:48

I am trying to do this but unfortunately the syntax is not so easy.

System.Enum:Parse has at least two parameters of which the first

has to be a System.Type and I have no clue what to enter there.

CAST (System.Enum:Parse (Progress.Util.TypeHelper:GetType ("yourEnumTypeGoesHere"), "your string value goes here"),

           yourEnumTypeGoesHere) 

Posted by rbf on 03-Jan-2013 09:44

Thanks Mike it works now generically with the following expression (for anyone else who is interested):

              otool#:SharedProps:Shortcut = cast(System.Enum:Parse(Progress.Util.TypeHelper:GetType("System.Windows.Forms.Shortcut"), replace(hitem#:ACCELERATOR,"-",""), true),System.Windows.Forms.Shortcut) no-error.

Posted by WJCPvanBeek on 11-Jun-2013 08:19

Thx Peter, just needed that.

Posted by Wouter Dupré on 11-Jun-2013 08:28

Hi,

Thank you for your email. I'm currently out of the office on a business trip. I will return on June 13, 2013. During my absence I will have no or very limited access to email and phone. For urgent matters, please call our office general number +32 15 30 77 00.

Warm regards,

Wouter

--

Wouter Dupré

Sr. Systems Engineer

Progress Software NV

A. Stocletlaan 202 B | B-2570 Duffel | Belgium

Office +32 (0) 15 30 77 46 | Mobile +32 (0) 478 50 00 49

This thread is closed