Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8646065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:42:27+00:00 2026-06-12T12:42:27+00:00

Can someone help about create a winform animation like in Win7 Calculator when you

  • 0

Can someone help about create a winform animation like in Win7 Calculator when you hover mouse over button, currently i use bunch of image then looping it in backgroundworker, but i think its wrong, this is my code:

this occur when mouse enter,

private void bgTurnOn_DoWork(object sender, DoWorkEventArgs e)
{
    Label labelSender = (Label)e.Argument;
    int ii = labelSender.ImageIndex;
    for (int i = ii + 4; i <= 11; i++)
    {
        if (labelSender.AllowDrop)
        {
            labelSender.ImageIndex = i;
            Thread.Sleep(40);
        }
    }
}

and this when mouse leave

private void bgTurnOff_DoWork(object sender, DoWorkEventArgs e)
{
    Label labelSender = (Label)e.Argument;
    int ii = labelSender.ImageIndex;
    for (int i = ii; i >= 0; i--)
    {
        if (!labelSender.AllowDrop)
        {
            labelSender.ImageIndex = i;
            Thread.Sleep(80);
        }
    }
}

note: I just use AllowDrop so I do not bother to declare new variable, i have 42 button, so i think i need more efficient solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:42:28+00:00Added an answer on June 12, 2026 at 12:42 pm

    It seems that you want a glow effect, so you can use the next idea:

    • Make an OpacityPictureBox : PictureBox which supports opacity (in levels of 1-100 or double 0-1). See this for more information.
    • Add two public const int values of MaxOpacity and MinOpacity to the OpacityPictureBox class, for easy and safe range checks from the outside. The values might be 0, 100 or 0, 1, or something else, depending on your implementation of opacity.
    • Make an AnimatedPictureBox : UserControl which holds 1 PictureBox named pbNormal and 1 OpacityPictureBox named opbHover, both Dock = DockStyle.Fill, and one timer named timer. Make sure that pbNormal is below opbHover.
    • Have three public properties:
      • Normal of type Image which delegates into pbNormal.Image
      • Hover of type Image which delegates into opbHover.Image
      • AnimationInterval of type int which delgates into timer.Interval
    • In the constructor of the AnimatedPictureBox, after calling InitializeComponents, do opbHover.Opacity = 0;. You can also do this.Cursor = Cursors.Hand; if you want the cursor to change into a hand when hovering over it.
    • Have a private members: _animationDirection of type int, which will be -1 or 1.
    • Have a private method that starts an animation in a given direction:

    Code:

    private void Animate(int animationDirection)
    {
        this._animationDirection = animationDirection;
        this.timer.Start();
    }
    
    • Override OnMouseEnter and OnMouseLeave:

    Code:

     protected override void OnMouseEnter(EventArgs e)
     {
         this.Animate(1);
         base.OnMouseEnter(e);
     }
    
     protected override void OnMouseLeave(EventArgs e)
     {
         this.Animate(-1);
         base.OnMouseEnter(e);
     }
    
    • Listen to timer.Tick event and with this:

    Code:

    private void timer_Tick(object sender, EventArgs e)
    {
        var hoverOpacity = this.opbHover.Opacity + this._animationDirection;
    
        if (hoverOpacity < OpacityPictureBox.MinOpacity ||
            hoverOpacity > OpacityPictureBox.MaxOpacity)
        {
            this.timer.Stop();
            return;
        }
    
        this.opbHover.Opacity = hoverOpacity;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone help me achieve multiple zend pagination in a view using ajax. I
Can someone help by showing me how to sort a LINQ expression. I have
Can someone help me understand how to write this case statement properly its not
Can someone help me with creating functions for the following processes? I want to
Can someone help me find the error when I tried to display the list
Can someone help me, how can i define the keyCode ,which, charcode into variable.
can someone help to write a method that converts a byte array to a
Can someone help me on how to setup such a result: Want to know
Can someone help me with the correct use of the split function in perl
Can someone help my regex-challenged self with this? The match must start with *.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.