Fading in and fading out for a form

Posted by karthik on Stack Overflow See other posts from Stack Overflow or by karthik
Published on 2010-05-28T09:40:39Z Indexed on 2010/05/28 9:52 UTC
Read the original article Hit count: 220

Filed under:
|

hi

i have a requirement in which my form is transparent,if my mouse enters into it the form should became visible,if my mouse leaves out of the form it becomes transparent, i have three different controls placed in my form , each controls mouse leave and mouse enter is the same that of the form . if my mouse enters into the form and enters into a control form_mouseleaveevent and control_mouseenterd gets fired so iam not able to achieve it,how to overcome this.

below is the piece of code for this:

  private void TransToOpac()
    {  
        if (!isTransparent)
            return;

       if (TtoOON == false )
        {
            TtoOON = true;
            for (i = this.Opacity; i <= 1; i = i + 0.02)
            {
                this.Opacity = i;
                Thread.Sleep(50);
            }
            isTransparent = false;
            TtoOON = false;
        }
    }
    private void OpacToTrans()
    {
        if (isTransparent)
            return;

        if (OtoTON == false )
        {
            OtoTON = true;
            for (i = this.Opacity; i >= 0.5; i = i - 0.02)
            {
                this.Opacity = i;
                Thread.Sleep(50);
            }
            isTransparent = true;
            OtoTON = false;
        }
    }

private void OnMouseEntered(object sender, EventArgs e) { TransToOpac(); } private void OnMouseLeft(object sender, EventArgs e) { OpacToTrans(); }

© Stack Overflow or respective owner

Related posts about c#

Related posts about 2.0