C # Flashing of icons in the taskbar

Source: Internet
Author: User

Guidance:
I believe you have seen the flash effect on the taskbar during QQ message prompts. I found some related information on the Internet and found that using C # To achieve this effect is not very difficult, I only used a notifyicon (I guess it is called the taskbar tray control because I don't know what it is ). because I have not studied it in depth, I can only briefly introduce the basic usage to achieve the flickering effect. (In winform)
1. First, drag a yyicon control and a timing control into the blank form.
Private system. Windows. Forms. policyicon policyicon1;
Private system. Windows. Forms. Timer timer1;
2. secondly, we prepare two ICO images to display on the taskbar. One of them is a transparent ICO image, which is called 1. ICO and 2.ico; create two icon objects to store two ICO images respectively;
Private icon ico1 = new icon ("1.ico ");
Private icon ico2 = new icon ("2.ico"); // transparent icon
3. initialize policyicon in form_load:
Private void form1_load (Object sender, system. eventargs E)
{
This. policyicon1.icon = ico1; // setProgram Icon displayed on the taskbar at the moment of Running
This. timer1.enable = true; // set the scheduled control to enabled. The default value is false;
}
4. Set a global variable I to control the image index, create a scheduled event, and double-click the scheduled control to edit it.
Int I = 0;
Private void timerjavastick (Object sender, system. eventargs E)
{
// If I = 0, make the taskbar icon transparent and exit
If (I <1)
{
This. policyicon1.icon = ico2;
I ++;
Return;
}
// If I! = 0, the taskbar icon is changed to ico1, And I is set to 0;
Else
This. policyicon1.icon = ico1;
I = 0;
}
So far, we have completed the effect of flashing images; isn't it easy? If you want to implement a more powerful taskbar tray icon, you can add the menu function, because the menu control is involved, so we will not describe it here, and wait for the next write to improve this flashing effect ..

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.