【发布时间】:2017-07-28 18:08:53
【问题描述】:
我被要求在有两个组合框的地方创建 winform 应用程序。
第一个框包含 Ctrl+Alt、Ctrl+Shift 和 Alt+Shift 等选项。第二个框包含 a-z 中的字母和数字 0-9..
该表单还包含一个名为“注册”的按钮。我的任务是,当我单击注册按钮时,组合框中选择的选项必须被视为热键并且应该注册。请帮助我编写代码,因为我是这项技术的新手。
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);
}
这是我到目前为止所做的
【问题讨论】:
-
请给出一个起点,你的进步和你遇到困难的地方。到目前为止,问题描述过于宽泛。人们不会在这里为您编写整个代码
-
这些热键应该只注册到您的应用程序还是全局热键?
-
是的..它应该只在我的应用程序中使用..我已经注册了密钥,但我不知道如何将它作为 Wndproc 消息传递..