欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時間:2023年01月05日 11:10:21   作者:芝麻粒兒  
這篇文章主要為大家詳細(xì)介紹了C#如何實現(xiàn)系統(tǒng)桌面右下角彈框,文中的示例代碼講解詳細(xì),對我們學(xué)習(xí)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(); //隱藏窗體
            //關(guān)閉窗體
            this.Close();
        }
    }
   public partial class DropDownForm : System.Windows.Forms.Form
    {
        #region 聲明的變量

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

        #endregion

        #region 該窗體的構(gòu)造方法

        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 調(diào)用API函數(shù)顯示窗體

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

        #endregion

        #region 鼠標(biāo)控制圖片的變化

        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 定義標(biāo)識窗體移動狀態(tài)的枚舉值

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

            //顯示窗體
            Display = 1,

            //顯示窗體中
            Displaying = 2,

            //隱藏窗體中
            Hiding = 3
        }

        #endregion

        #region 用屬性標(biāo)識當(dāng)前狀態(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) //當(dāng)窗體沒有完全顯示時
                        this.SetBounds(Rect.X, this.Top - 192, Rect.Width, this.Height + 192); //使窗體不斷上移
                    else
                    {
                        this.SetBounds(Rect.X, Rect.Y, Rect.Width, Rect.Height); //設(shè)置當(dāng)前窗體的邊界
                        this.FormNowState = FormState.Display; //設(shè)置當(dāng)前窗體的操作狀態(tài)為顯示
                    }

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

        #endregion

        #region 關(guān)閉窗體

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

                    break;
            }
        }

        #endregion

        #region 返回當(dāng)前窗體的實例化對象

        static public DropDownForm Instance()
        {
            return dropDownForm;
        }

        #endregion

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

        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)桌面右下角彈框的詳細(xì)內(nèi)容,更多關(guān)于C#桌面彈框的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • C# 多線程處理List數(shù)據(jù)的示例代碼

    C# 多線程處理List數(shù)據(jù)的示例代碼

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

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

    這篇文章主要介紹了C#控制鍵盤按鍵的常用方法,涉及C#針對鍵盤大寫、滾動、數(shù)字的開啟與鎖定等功能,非常簡單實用,需要的朋友可以參考下
    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數(shù)據(jù)庫操作類實例詳解

    C# Oracle數(shù)據(jù)庫操作類實例詳解

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

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

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

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

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

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

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

    C#遍歷刪除字符串中重復(fù)字符

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

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

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

    C#使用SqlDataAdapter對象獲取數(shù)據(jù)的方法

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

最新評論