我怎么使用的WinForms
问题描述:
我被要求要创造一个有两个组合框WinForm应用程序创建自定义的热键。
第一个框包含像按Ctrl + Alt键的选项,按Ctrl + Shift和ALT + SHIFT。第二个框中包含来自a-z和数字0-9 ..
的字母表格还包含一个名为“Register”的按钮。我的任务是,当我点击注册按钮时,组合框中选择的选项必须被视为热键,并且它应该被注册。请帮助我解决这个问题,因为我对这项技术很陌生。我怎么使用的WinForms
private void button1_Click(object sender, EventArgs e)
{
if (comboBox1.SelectedItem.ToString() != str && comboBox3.SelectedItem.ToString() != s)
{
str = comboBox1.SelectedItem.ToString();
byte str1 = (byte)(str)[0];
s = comboBox3.SelectedItem.ToString();
byte s1 = (byte)(s)[0];
RegisterHotKey(this.Handle, this.GetType().GetHashCode(), Win32Modifiers, s1);
}
base.WndProc(ref msg);
}
protected override void WndProc(ref Message m)
{
if(m.Msg == )
base.WndProc(ref m);
}
这是我到目前为止
的可能的复制【最佳方式来实现键盘快捷键在Windows窗体应用程序?(http://*.com/questions/400113/best-way-to-implement-keyboard-shortcuts-in-a-windows -forms-application) –
亲切,给出一个出发点,你的进步和遇到困难的点。到目前为止,问题描述过于宽泛。人们不会在这里为你写整个代码 –
这些热键应该只注册到你的应用程序还是全局热键? –