簡體   English   中英

如何停止 Wndproc() 循環?

[英]How to stop Wndproc() loop?

我已覆蓋 wndproc() 以使用熱鍵。 但表格將不再關閉。 並關閉程序在 wndproc() 中陷入無限循環。

 protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);

        if (m.Msg == 0x0312)
        {


            Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF);                  

            int id = m.WParam.ToInt32();                                        


            MessageBox.Show("Hotkey has been pressed!");
            // do something
        }

    }

我已將 e.cancel 設置為 true 並在 OnFoemClosing 方法中添加以下代碼`

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

但什么也沒有發生。

[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);
}`

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM