右下角彈出窗口(C#)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace winformTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        [DllImport("user32")]
        private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);

        //下面是可用的常量,根據不同的動畫效果聲明自己需要的
        private const int AW_HOR_POSITIVE = 0x0001;//自左向右顯示窗口,該標誌可以在滾動動畫和滑動動畫中使用。使用AW_CENTER標誌時忽略該標誌
        private const int AW_HOR_NEGATIVE = 0x0002;//自右向左顯示窗口,該標誌可以在滾動動畫和滑動動畫中使用。使用AW_CENTER標誌時忽略該標誌
        private const int AW_VER_POSITIVE = 0x0004;//自頂向下顯示窗口,該標誌可以在滾動動畫和滑動動畫中使用。使用AW_CENTER標誌時忽略該標誌
        private const int AW_VER_NEGATIVE = 0x0008;//自下向上顯示窗口,該標誌可以在滾動動畫和滑動動畫中使用。使用AW_CENTER標誌時忽略該標誌該標誌
        private const int AW_CENTER = 0x0010;//若使用了AW_HIDE標誌,則使窗口向內重疊;否則向外擴展
        private const int AW_HIDE = 0x10000;//隱藏窗口
        private const int AW_ACTIVE = 0x20000;//激活窗口,在使用了AW_HIDE標誌後不要使用這個標誌
        private const int AW_SLIDE = 0x40000;//使用滑動類型動畫效果,默認爲滾動動畫類型,當使用AW_CENTER標誌時,這個標誌就被忽略
        private const int AW_BLEND = 0x80000;//使用淡入淡出效果 


 



        private void Form1_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);//設置窗體在屏幕右下角顯示
            AnimateWindow(this.Handle, 1000, AW_SLIDE);

        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            AnimateWindow(this.Handle, 1000, AW_BLEND | AW_HIDE);

        }
    }
}


 

發佈了17 篇原創文章 · 獲贊 0 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章