Exemple #1
0
 internal static extern IntPtr CreateAcceleratorTable(ACCEL[] lpaccl, int cEntries);
Exemple #2
0
        /// <summary>
        ///     Create a new accelerator from the given accelerator key and virtual key combination.
        /// </summary>
        /// <param name="acceleratorKey">
        ///     The accelerator key (Ctrl, Alt, or Shift). Can be combined with | to form more complicated keystrokes
        ///     such as Ctrl + Alt + Space.
        /// </param>
        /// <param name="virtualKey">
        ///     The virtual key code (may not be Ctrl, Alt, or Shift).
        /// </param>
        public Accelerator(AcceleratorKeys acceleratorKey, VirtualKeys virtualKey)
        {
            AcceleratorKey = acceleratorKey;
            VirtualKey = virtualKey;
            Command = Macros.MAKEWORD((byte)AcceleratorKey, (byte)VirtualKey);

            lock(builderLock) {

                //create a string representation of this accelerators keystroke such as "CONTROL + SPACE"
                foreach(var key in acceleratorKeys.Keys) {
                    if(AcceleratorKey.Any(key)) {
                        stringBuilder.Append(acceleratorKeys[key])
                                     .Append(SEPARATOR);
                    }
                }
                stringBuilder.Append(virtualKeys[VirtualKey]);
                str = stringBuilder.ToString();
                stringBuilder.Clear();
            }

            Accel = new ACCEL() {
                fVirt = (byte)(AcceleratorKey | (AcceleratorKeys)VIRTKEY),
                key = (ushort)VirtualKey,
                cmd = Command
            };
        }