Floating windows similar to flashget and thunder

Source: Internet
Author: User
Part 1:

Download tools such as flashget and Thunder are often seen. When the download tool is minimized, a floating window will appear in the upper right corner of the screen. You can drag it to any position and right-click it to perform some operations, when you move the mouse up, there will also be a prompt below, so how do these use C?

First, the floating window is a topmost form (create a form and set the topmost attribute );
2. Drag the mouse and drag it to add a mousemove event to the topmost form to determine the mouse position and move the topmost form by changing the location;
Third, right-click the topmost form and add contextmenustrip in. NET 2.0;
Fourth, you can add a tooltip component to the form following the mouse prompt. The tooltip has three main delay attributes: initialdelay (how long will the tooltip string appear), reshowdelay (when moving to another control, the number of milliseconds required for the following tool prompt string appears), autopopdelay (indicating how long the string is displayed), you can set these attributes on the form. However, this component made by Ms seems a bit problematic. If the form is moved, the tooltip will no longer be prompted, and if autopopdelay = 5000; then the prompt box will automatically disappear after five seconds, you will not be prompted again in the future, but it will be normal if you manually move the mouse <5 seconds; to avoid this situation, you can add two events to the topmost form: frmtopmost_mouseenter and frmtopmost_mouseleave: Private void frmtopmost_mouseenter (Object sender, system. eventargs E)
{
This. tooltip1.active = true;
This. tooltip1.autopopdelay = 5000;
This. tooltip1.initialdelay = 500;
This. tooltip1.reshowdelay = 100;
This. tooltip1.showalways = true;
}

Private void frmtopmost_mouseleave (Object sender, system. eventargs E)
{
This. tooltip1.active = false;
}

This is normal.

Part 2 code

Drag the form
Private void frmtopmost_mousemove (Object sender, system. Windows. Forms. mouseeventargs E)
{
If (blnmousedown)
{
// Get the current postion of the mouse in the screen.
Ptmousenewpos = control. mouseposition;

// Set window postion.
Ptformnewpos. x = ptmousenewpos. X-ptmousecur1_pos. x + ptformpos. X;
Ptformnewpos. Y = ptmousenewpos. Y-ptmousecur1_pos. Y + ptformpos. Y;

// Save window postion.
Location = ptformnewpos;
Ptformpos = ptformnewpos;

// Save Mouse pontion.
Ptmousecurrentpos = ptmousenewpos;
}
}

Part 3

Source download

EXE files: http://files.cnblogs.com/Roger52027/TopMost.rar
Solution files: http://files.cnblogs.com/Roger52027/TopMostSolution.rar

Note: This article is based on an article by yuweng's eldest brother. Address: http://blog.csdn.net/Knight94

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.