none
WndProc 里面怎么识别是关机事件 RRS feed

  • 问题

  • /// <summary>    
    /// 重载     当窗体即将销毁时引发Quit 事件
    /// </summary>    
    /// <param name="m">The <see cref="Message"/> send to this procedure</param>    
    [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.LinkDemand, Name = "FullTrust")]
    protected override void WndProc(ref Message m)
    {
    if (m.Msg == Convert.ToInt32(WindowsMessages.WM_PARENTNOTIFY)) {
    //int lp = m.LParam.ToInt32();    
    int wp = m.WParam.ToInt32();
    int X = wp & 0xffff;
    //int Y = (wp >> 16) & 0xFFFF;    
    if (X == Convert.ToInt32(WindowsMessages.WM_DESTROY)) {
    if (Quit != null) {
    Quit(this, EventArgs.Empty);
    }
    }
    }
    base.WndProc(m);
    }

    private event EventHandler Quit;

    这是在网上找的避免WebBrowser被JS关闭  

    但是用了 这个点关机的时候也会触发这个事件,就关不了机了,要怎么识别是不是关机事件,如果是就不触发这个事件  以免关不了机

    2013年6月10日 1:41

答案