Extracted WinForm Control development 5, WinForm development: FlashGetFormDemos, similar to the flash get floating window

Source: Internet
Author: User
The main form has two processes: 1. When the main form is minimized, the floating window displays the code: Code Void MainFormSizeChanged (object sender, EventArgs e)
{
If (this. WindowState = FormWindowState. Minimized)
{
TopMostForm. Show ();
This. ShowInTaskbar = false;
}
Else if (this. WindowState! = Previusestate)
{
Previusestate = this. WindowState;
}
}

 

2. Restore the Main Window

/// <Summary>
/// Restore the Main Window
/// </Summary>
Public void RestoreWindowState ()
{
This. WindowState = previusestate;
This. ShowInTaskbar = true;
}

 

Floating window processing:

1. Set the window status to None to remove the border of the form.

This. FormBorderStyle = System. Windows. Forms. FormBorderStyle. None;

2. In the Load event, the highlight is to set the window transparency.

Code:

/// <Summary>
/// Transparent settings
/// </Summary>
Private void SetClarity (double prameter)
{
This. Opacity = prameter;
}

 

3. Hover window events:

Code:

 

Code Void TopMostFormMouseDown (object sender, MouseEventArgs e)
{
If (e. Button = MouseButtons. Left)
{
BlnMouseDown = true;

// Save the current, mouse, and window
PtMouseCurrrnetPos = Control. MousePosition;
PtFormPos = Location;
}
}

Void TopMostFormMouseUp (object sender, MouseEventArgs e)
{
If (e. Button = MouseButtons. Left)
{
BlnMouseDown = false;
}
}

Void TopMostFormMouseMove (object sender, MouseEventArgs e)
{
If (blnMouseDown)
{
// Obtain the current mouse position
PtMouseNewPos = Control. MousePosition;

// Set the window position
PtFormNewPos. X = ptMouseNewPos. X-ptMouseCurrrnetPos. X + ptFormPos. X;
PtFormNewPos. Y = ptMouseNewPos. Y-ptMouseCurrrnetPos. Y + ptFormPos. Y;

// Set the window position
Location = ptFormNewPos;
PtFormPos = ptFormNewPos;

// Save the mouse position
PtMouseCurrrnetPos = ptMouseNewPos;
}
}

 

4. Convert the functions of the main window:

Code:

Void TopMostFormDoubleClick (object sender, EventArgs e)
{
SwitchToMainForm ();
}

Void SwitchToMainForm ()
{
This. mainForm. RestoreWindowState ();
This. Hide ();
}

 

/Files/csharponworking/FlashFormDemos.zip

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.