private void screensaverWindow_Load(object sender, System.EventArgs e)
{
this.BringToFront();
this.Focus();
this.KeyPreview = true;
this.KeyDown += new KeyEventHandler(onkeyDown);
}
Run Code Online (Sandbox Code Playgroud)
onKeyDown()永远不会被称为.知道为什么吗?
编辑:这在发布模式下工作!?我想它必须是视觉工作室调试器干扰某处
Jan*_*gge 12
似乎为我工作:
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.BringToFront();
this.Focus();
this.KeyPreview = true;
this.KeyDown += new KeyEventHandler(Form1_KeyDown);
}
void Form1_KeyDown(object sender, KeyEventArgs e)
{
Console.WriteLine("test");
}
Run Code Online (Sandbox Code Playgroud)
您的表单上是否有任何子控件?