示例#1
0
        private void BtnChangeHotkey_Click(object sender, System.EventArgs e)
        {
            byte minMod            = (byte)NumMinMod.Value;
            Keys k                 = (TxtKeyEnumValue.Text.Length > 0) ? (Keys)Int32.Parse(TxtKeyEnumValue.Text) : Keys.None;
            FrmSpecifyShortcut frm = new FrmSpecifyShortcut(minMod, k);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                bool success = FrmMain.RegisterHotKey(this.Handle, this.GetType().GetHashCode(), frm.ShortcutInput1.Win32Modifiers, frm.ShortcutInput1.CharCode);
                if (success)
                {
                    TxtKeyEnumValue.Text = ((int)frm.ShortcutInput1.Keys).ToString();
                    StreamWriter writer = File.CreateText(Application.StartupPath + "\\HotkeyValue.txt");
                    writer.Write(TxtKeyEnumValue.Text);
                    writer.Close();
                }
                else
                {
                    MessageBox.Show("Could not register Hotkey - there is probably a conflict.  ", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#2
0
 private void BtnChangeHotkey_Click(object sender, System.EventArgs e)
 {
     byte minMod = (byte)NumMinMod.Value;
     Keys k = (TxtKeyEnumValue.Text.Length > 0) ? (Keys)Int32.Parse(TxtKeyEnumValue.Text) : Keys.None;
     FrmSpecifyShortcut frm = new FrmSpecifyShortcut(minMod, k);
     if (frm.ShowDialog() == DialogResult.OK)
     {
         bool success = FrmMain.RegisterHotKey(this.Handle, this.GetType().GetHashCode(), frm.ShortcutInput1.Win32Modifiers, frm.ShortcutInput1.CharCode);
         if (success)
         {
             TxtKeyEnumValue.Text = ((int)frm.ShortcutInput1.Keys).ToString();
             StreamWriter writer = File.CreateText(Application.StartupPath + "\\HotkeyValue.txt");
             writer.Write(TxtKeyEnumValue.Text);
             writer.Close();
         }
         else
             MessageBox.Show("Could not register Hotkey - there is probably a conflict.  ", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }