Beispiel #1
0
 private void TextBox_KeyDown(object sender, KeyEventArgs e)
 {
     e.SuppressKeyPress = true;
     this.Text          = string.Empty;
     this.KeyisSet      = false;
     if (e.Modifiers == Keys.None && this.forcemodifier)
     {
         int num = (int)MessageBox.Show("快捷键必须包含Ctrl或者Alt或Shift");
         this.Text = string.Empty;
     }
     else
     {
         string str1    = e.Modifiers.ToString();
         char[] chArray = new char[1] {
             ','
         };
         foreach (string str2 in str1.Split(chArray))
         {
             if (str2 != Keys.None.ToString())
             {
                 HotKeyControl hotKeyControl = this;
                 hotKeyControl.Text = hotKeyControl.Text + str2 + " + ";
             }
         }
         if (e.KeyCode == Keys.ShiftKey | e.KeyCode == Keys.ControlKey | e.KeyCode == Keys.Menu)
         {
             this.KeyisSet = false;
         }
         else
         {
             this.Text    += e.KeyCode.ToString();
             this.KeyisSet = true;
         }
     }
 }
Beispiel #2
0
        private void updateWatermark()
        {
            if (!this.IsHandleCreated)
            {
                return;
            }
            IntPtr hglobalUni = Marshal.StringToHGlobalUni("在此输入快捷键");

            HotKeyControl.SendMessage(this.TextBox.Handle, 5377, (IntPtr)1, hglobalUni);
            Marshal.FreeHGlobal(hglobalUni);
        }