亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C#實現(xiàn)系統(tǒng)桌面右下角彈框

 更新時間:2023年01月05日 11:10:21   作者:芝麻粒兒  
這篇文章主要為大家詳細介紹了C#如何實現(xiàn)系統(tǒng)桌面右下角彈框,文中的示例代碼講解詳細,對我們學習C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下

實踐過程

效果

代碼

 public partial class GroundForm : Form
    {
        public GroundForm()
        {
            InitializeComponent();
        }

        private void display_Click(object sender, EventArgs e)
        {
            DropDownForm.Instance().ShowForm(); //顯示窗體
        }

        private void close_Click(object sender, EventArgs e)
        {
            DropDownForm.Instance().CloseForm(); //隱藏窗體
            //關閉窗體
            this.Close();
        }
    }
   public partial class DropDownForm : System.Windows.Forms.Form
    {
        #region 聲明的變量

        private System.Drawing.Rectangle Rect; //定義一個存儲矩形框的數組
        private FormState InfoStyle = FormState.Hide; //定義變量為隱藏
        static private DropDownForm dropDownForm = new DropDownForm(); //實例化當前窗體
        private static int AW_HIDE = 0x00010000;
        private static int AW_SLIDE = 0x00040000;
        private static int AW_VER_NEGATIVE = 0x00000008;

        #endregion

        #region 該窗體的構造方法

        public DropDownForm()
        {
            InitializeComponent();
            //初始化工作區(qū)大小
            System.Drawing.Rectangle rect = System.Windows.Forms.Screen.GetWorkingArea(this);
            this.Rect = new System.Drawing.Rectangle(rect.Right - this.Width - 1, rect.Bottom - this.Height - 1,
                this.Width, this.Height);
        }

        #endregion

        #region 調用API函數顯示窗體

        [DllImportAttribute("user32.dll")]
        private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);

        #endregion

        #region 鼠標控制圖片的變化

        private void pictureBox1_MouseEnter(object sender, EventArgs e)
        {
            for (int i = 0; i < imageList1.Images.Count; i++)
            {
                if (i == 1)
                    pictureBox1.Image = imageList1.Images[i];
            }
        }

        private void pictureBox1_MouseLeave(object sender, EventArgs e)
        {
            for (int i = 0; i < imageList1.Images.Count; i++)
            {
                if (i == 0)
                    pictureBox1.Image = imageList1.Images[i];
            }
        }

        #endregion

        #region 定義標識窗體移動狀態(tài)的枚舉值

        protected enum FormState
        {
            //隱藏窗體
            Hide = 0,

            //顯示窗體
            Display = 1,

            //顯示窗體中
            Displaying = 2,

            //隱藏窗體中
            Hiding = 3
        }

        #endregion

        #region 用屬性標識當前狀態(tài)

        protected FormState FormNowState
        {
            get { return this.InfoStyle; }
            set { this.InfoStyle = value; }
        }

        #endregion

        #region 顯示窗體

        public void ShowForm()
        {
            switch (this.FormNowState)
            {
                case FormState.Hide:
                    if (this.Height <= this.Rect.Height - 192) //當窗體沒有完全顯示時
                        this.SetBounds(Rect.X, this.Top - 192, Rect.Width, this.Height + 192); //使窗體不斷上移
                    else
                    {
                        this.SetBounds(Rect.X, Rect.Y, Rect.Width, Rect.Height); //設置當前窗體的邊界
                        this.FormNowState = FormState.Display; //設置當前窗體的操作狀態(tài)為顯示
                    }

                    AnimateWindow(this.Handle, 800, AW_SLIDE + AW_VER_NEGATIVE); //動態(tài)顯示本窗體
                    break;
            }
        }

        #endregion

        #region 關閉窗體

        public void CloseForm()
        {
            switch (this.FormNowState)
            {
                case FormState.Display: //顯示當前窗體
                    if (this.Top <= this.Rect.Bottom - 192) //如果窗體沒有完全隱藏
                    {
                        this.SetBounds(Rect.X, this.Top + 192, Rect.Width, this.Height - 192); //使窗體不斷下移
                    }
                    else
                    {
                        this.Close(); //隱藏當前窗體
                        this.FormNowState = FormState.Hide; //設置窗體的操作狀態(tài)為隱藏
                    }

                    break;
            }
        }

        #endregion

        #region 返回當前窗體的實例化對象

        static public DropDownForm Instance()
        {
            return dropDownForm;
        }

        #endregion

        #region 在窗體的關閉事件中進行動態(tài)關閉

        private void DropDownForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            AnimateWindow(this.Handle, 800, AW_SLIDE + AW_VER_NEGATIVE + AW_HIDE);
            this.Close();
        }

        #endregion
    }

以上就是C#實現(xiàn)系統(tǒng)桌面右下角彈框的詳細內容,更多關于C#桌面彈框的資料請關注腳本之家其它相關文章!

相關文章

  • C# 多線程處理List數據的示例代碼

    C# 多線程處理List數據的示例代碼

    這篇文章主要介紹了C# 多線程處理List數據的示例代碼,幫助大家更好的理解和使用c#編程語言,感興趣的朋友可以了解下
    2020-12-12
  • C#控制鍵盤按鍵的常用方法

    C#控制鍵盤按鍵的常用方法

    這篇文章主要介紹了C#控制鍵盤按鍵的常用方法,涉及C#針對鍵盤大寫、滾動、數字的開啟與鎖定等功能,非常簡單實用,需要的朋友可以參考下
    2015-05-05
  • WPF實現(xiàn)html中的table控件的示例代碼

    WPF實現(xiàn)html中的table控件的示例代碼

    相信很多做WPF開發(fā)的小伙伴都遇到過表格類的需求,雖然現(xiàn)有的Grid控件也能實現(xiàn),但是使用起來的體驗感并不好,所以本文我們就來用WPF自己實現(xiàn)一個html中的table控件吧
    2024-03-03
  • C# Oracle數據庫操作類實例詳解

    C# Oracle數據庫操作類實例詳解

    這篇文章主要介紹了C# Oracle數據庫操作類實例,進行數據庫操作時很有實用價值,需要的朋友可以參考下
    2014-07-07
  • C#調用FFmpeg操作音視頻的實現(xiàn)示例

    C#調用FFmpeg操作音視頻的實現(xiàn)示例

    本文主要介紹了C#調用FFmpeg操作音視頻的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • C#中后臺post請求常用的兩種方式總結

    C#中后臺post請求常用的兩種方式總結

    這篇文章主要介紹了C#中后臺post請求常用的兩種方式總結,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-06-06
  • 手把手教你如何基于C#制作一個網址檢測工具

    手把手教你如何基于C#制作一個網址檢測工具

    這篇文章主要給大家介紹了關于如何基于C#制作一個網址檢測工具的相關資料,文中通過圖文以及實例代碼介紹的非常詳細,對大家學習或者使用C#具有一定的參考學習價值,需要的朋友可以參考下
    2023-02-02
  • C#遍歷刪除字符串中重復字符

    C#遍歷刪除字符串中重復字符

    這篇文章主要介紹了C#遍歷刪除字符串中重復字符的方法,涉及C#遍歷字符串的相關技巧,非常具有實用價值,需要的朋友可以參考下
    2015-04-04
  • gridview的buttonfield獲取該行的索引值(實例講解)

    gridview的buttonfield獲取該行的索引值(實例講解)

    本篇文章主要介紹了gridview的buttonfield獲取該行的索引值(實例講解)需要的朋友可以過來參考下,希望對大家有所幫助
    2014-01-01
  • C#使用SqlDataAdapter對象獲取數據的方法

    C#使用SqlDataAdapter對象獲取數據的方法

    這篇文章主要介紹了C#使用SqlDataAdapter對象獲取數據的方法,結合實例形式較為詳細的分析了SqlDataAdapter對象獲取數據具體步驟與相關使用技巧,需要的朋友可以參考下
    2016-02-02

最新評論