C# 如何停止Wndproc()循环?

C# 如何停止Wndproc()循环?,c#,hotkeys,wndproc,C#,Hotkeys,Wndproc,我已重写wndproc()以使用热键。但是表单将不再关闭。一旦关闭,程序就卡在wndproc()中的无限循环中 我已将e.cancel设置为true,并在OnFoemClosing方法中添加了以下代码` e.Cancel = false; base.OnFormClosing(e); 但是什么也没有发生。消息框可能是所有问题的关键。如果您尝试设置KeyPreview属性=true并管理keyPress事件来调整WndProc,那么KeyPreview的问题是关联的发件人必须打开才能工作。如

我已重写wndproc()以使用热键。但是表单将不再关闭。一旦关闭,程序就卡在wndproc()中的无限循环中

我已将e.cancel设置为true,并在OnFoemClosing方法中添加了以下代码`

 e.Cancel = false;
 base.OnFormClosing(e);

但是什么也没有发生。

消息框可能是所有问题的关键。如果您尝试设置KeyPreview属性=true并管理keyPress事件来调整WndProc,那么KeyPreview的问题是关联的发件人必须打开才能工作。如果表单最小化或未选中,则无法工作。但是我需要一个与中断服务例程一起工作的热键。您设置为e.Cancel的是什么?在OnClosingForm方法的主体中,我设置了“e.Cancel=false”
[DllImport("user32.dll")]
static extern bool DestroyWindow(IntPtr hWnd);

//Closes the form
btnCloseWindow_Click(object sender, EventArgs e)
{
     DestroyWindow(this.Handle);
}`[DllImport("user32.dll")]
static extern bool DestroyWindow(IntPtr hWnd);

//Closes the form
btnCloseWindow_Click(object sender, EventArgs e)
{
     DestroyWindow(this.Handle);
}`
[DllImport("user32.dll")]
static extern bool DestroyWindow(IntPtr hWnd);

//Closes the form
btnCloseWindow_Click(object sender, EventArgs e)
{
     DestroyWindow(this.Handle);
}`[DllImport("user32.dll")]
static extern bool DestroyWindow(IntPtr hWnd);

//Closes the form
btnCloseWindow_Click(object sender, EventArgs e)
{
     DestroyWindow(this.Handle);
}`