StrataFrame Forum

Ability to setup hotkeys....

http://forum.strataframe.net/Topic16129.aspx

By StarkMike - 5/5/2008

Is there a way that I could setup a hotkey so that when a user presses ALT-N? Like a hotkey I could bind to the New button on the MaintenanceToolstrip?
By Trent L. Taylor - 5/5/2008

The easiest thing to do here is to override the ProcessCmd method and insert your override logic.  This is something that we commonly do to add hotkey functionality...and this is the root level so it will trump anything else.

This is a method on any control, so you could either inherit the MaintenanceFormToolstrip and add it there...or if this is more of a one time thing then you could just do it in the form.  In either case, the code would be the same:

Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
Select Case keyData
    Case Keys.Alt Or Keys.N
 '-- It is always a good idea to supply a result in the message
        msg.Result = IntPtr.Zero
 
 '-- Perform your logic
        ' TODO

 '-- Return out of the method
        Return True

End Select

'-- Perform the default logic here
Return MyBase.ProcessCmdKey(msg, keyData)
End Function