using System.Runtime.InteropServices; public partial class Form2 : Form { public Form2() { InitializeComponent(); } [DllImport("user32")] private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags); private static int AW_HIDE = 0x00010000;//This variable indicates that the animation hides the form private static int AW_SLIDE = 0x00040000;//This variable represents the form with sliding effect private static int AW_VER_NEGATIVE = 0x00000008;//This variable indicates that the screen is opened from bottom to top private static int AW_VER_POSITIVE = 0x00000004;//This variable indicates that the screen is opened from top to bottom private const int AW_ACTIVE = 0x20000;//Activate the window private const int AW_BLEND = 0x80000;//Apply fading result private void Form2_Load(object sender, EventArgs e) { int x = Screen.PrimaryScreen.WorkingArea.Right - this.Width; int y = Screen.PrimaryScreen.WorkingArea.Bottom - this.Height; this.Location = new Point(x, y);//Set the form to be displayed in the lower right corner of the screen AnimateWindow(this.Handle, 1000, AW_SLIDE | AW_ACTIVE | AW_VER_NEGATIVE); } //Close the popup private void simpleButton2_Click(object sender, EventArgs e) { AnimateWindow(this.Handle, 1000, AW_BLEND | AW_HIDE); } }The code is as shown above, the personal feeling of closing the pop-up window is not closing the pop-up window, but a kind of hiding, because the form collection is obtained through FormCollection formCollection = Application.OpenForms;, the form always exists, so if you want to achieve secondary pop-up window, you can use the close method of the window;
WinForm implements a pop-up window in the lower right corner
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=324882775&siteId=291194637
Recommended
Ranking