C # Highlight the taskbar (the task is stopped after 3 seconds of flashing and remains highlighted)

Source: Internet
Author: User
Zookeeper

Today, I use C # as a communication software similar to QQ. Sometimes I don't notice the message, so I want to flash the taskbar after receiving the message, and finally highlight the orange color, it's like sending messages via QQ. After searching and querying the API repeatedly, you need to use this function to find that the taskbar is flashing and staying:
Public static extern bool flash1_wex (ref flashwinfo pwfi );
The key code for implementation is as follows:

[Dllimport ("user32.dll")]
Public static extern bool flash1_wex (ref flashwinfo pwfi );

Public Enum falshtype: uint
{
Flashw_stop = 0, // stop flashing
Falshw_caption = 1, // only flashes the title
Flashw_tray = 2, // only flashes the taskbar
Flashw_all = 3, // The title and taskbar flash simultaneously
Flashw_param1 = 4,
Flashw_param2 = 12,
Flashw_timer = flashw_tray | flashw_param1, // flashes the taskbar unconditionally until the stop flag is sent. Highlight the task after it is stopped.
Flashw_timernofg = flashw_tray | flashw_param2 // flash the taskbar when it is not activated until the stop sending sign or the form is activated. Highlight it after it is stopped.
}

Public static bool flashtaskbar (intptr hwnd, falshtype type)
{
Flashwinfo finfo = new flashwinfo ();
Finfo. cbsize = convert. touint32 (marshal. sizeof (finfo ));
Finfo. hwnd = hwnd; // handle of the window to flash. The window can be opened or minimized.
Finfo. dwflags = (uint) type; // flashing type
Finfo. ucount = uint32.maxvalue; // Number of blinking windows
Finfo. dwtimeout = 0; // The frequency of window blinking, in milliseconds. If this value is 0, it is the flashing frequency of the default icon.
Return flashmediawex (ref finfo );
}


The following call: if the task is not activated, the taskbar will flash until the sending Stop sign or the form is activated. After the task is highlighted and activated, it will be normal. This is the same as QQ, the activation window is a stop highlight event:
Flashtaskbar (this. Handle, falshtype. flashw_timernofg );

However, QQ does not flash when processing the activation status in the session window, so that sometimes the messages sent by the other party are not noticed. Therefore, whether the form is activated or not, the taskbar will flash when there is a new message until the text is entered by the user. This can be called as follows:

Flashtaskbar (this. Handle, falshtype. flashw_timer );

Add a timer to trigger the event for only 3 s, and when the user inputs the event, add the following call to the event processing function:

The following call: stop flashing. If the window is not activated after the stop, the window is highlighted.

Flashtaskbar (this. Handle, falshtype. flashw_stop );



C # Highlight the taskbar (the task is stopped after 3 seconds of flashing and remains highlighted)

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.