怎么样设置窗体属性使得窗体隐藏,当鼠标进入窗体范围时显示窗体....应该对窗体的哪个事件写代码...谢谢....

解决方案 »

  1.   


    private void Form1_MouseLeave(object sender, EventArgs e)
            {
                
                this.Opacity = 0;
            }        private void Form1_MouseHover(object sender, EventArgs e)
            {
                
                this.Opacity = 100;
            }
    我定制了两个事件...为什么感觉Form1_MouseHover好像没有发生....就是当鼠标停留在窗体上的时候窗体没有再现出来....
      

  2.   

    挺有趣的问题我试过了
    private void Form1_MouseLeave(object sender, EventArgs e) 
    { this.Opacity = 0.1; } 
    private void Form1_MouseHover(object sender, EventArgs e)
     { this.Opacity = 1; }效果还可以
    用MouseMove代替Hover事件更敏感
      

  3.   

    private void Form1_MouseLeave(object sender, EventArgs e)
            {
                
                this.Opacity = 0.1;//如果等于0,隐藏之后再不响应了
                                       //MouseEnter,MouseHover,MouseMove      
            }
      

  4.   

    没错,而且,Opacity 越小,MouseHover好像也越不敏感,你这个问题比较偏门,不怎么好搞
      

  5.   

    http://www.swigger.net/archives/114.html这篇文章 对透明窗口的鼠标事件可能有帮助(需要你逆向思考了)
      

  6.   

     [DllImport("user32.dll")]
            [return: MarshalAs(UnmanagedType.Bool)]
            public static extern bool GetWindowRect(HandleRef hwnd, out RECT lpRect);        [DllImport("user32.dll")]
            public static extern bool GetCursorPos(out System.Drawing.Point lpPoint);        [DllImport("user32.dll")]
            public static extern bool PtInRect(ref RECT lprc, System.Drawing.Point pt);        [StructLayout(LayoutKind.Sequential)]
            public struct RECT
            {
                public int Left; 
                public int Top;
                public int Right;
                public int Bottom;
            }        private RECT m_rect = new RECT();
     
            private void Form1_MouseLeave(object sender, EventArgs e)
            {
                GetWindowRect(new HandleRef(this, this.Handle), out m_rect);
                timer1.Enabled = true;
                this.Hide();
            }        private void timer1_Tick(object sender, EventArgs e)
            {
                if(m_rect.Left<=0 || m_rect.Top<=0 || m_rect.Right<=0 || m_rect.Bottom<=0)
                    return;            System.Drawing.Point point = new Point();
                GetCursorPos(out point);
                if (PtInRect(ref m_rect, point))
                {
                    this.Visible = true;
                    timer1.Enabled = false;                m_rect.Left = 0;
                    m_rect.Top = 0;
                    m_rect.Right = 0;
                    m_rect.Bottom = 0;
                }
            }
      

  7.   

    QQ不是一移到 原窗口位置就出现,而是缩在顶上或者边上,靠近(MOVE in)就出现
      

  8.   


    这个说的对,如果hide的话,第一次隐藏之后,再到原位置上估计就没反应了
      

  9.   


    http://www.cnblogs.com/hnNet/articles/1511232.html仅供参考!
      

  10.   

    就是的,Opacity 等于 0 ,就捕获不到那些事件了!0.1也看不到的~~![align=center]********************************************************
    本内容用 CSDN小秘书 回复
    每天回帖即可获得10分可用分!
    ********************************************************
    [/align]
      

  11.   

    就是的,Opacity 等于 0 ,就捕获不到那些事件了!0.1也看不到的~~![align=center]********************************************************
    本内容用 CSDN小秘书 回复
    每天回帖即可获得10分可用分!
    ********************************************************
    [/align]