zoukankan      html  css  js  c++  java
  • c#窗体移动与窗体阴影效果

      
    //步骤
    //1.导入代码
    //2.事件中添加form_1mousedown函数
    //3.在load函数中定义AnimateWindow语句,注意有两个引用。
    //4.DllImport若有错误,按shift+alt+F10添加第一个解决
     [System.Runtime.InteropServices.DllImport("user32.dll")]//api加载声明
            protected static extern bool AnimateWindow(IntPtr hWnd, int dwTime, int dwFlags);//定义AnimateWindow
            public const Int32 AW_BLEND = 0x00080000;
            public const Int32 AW_CENTER = 0x00000010;
            public const Int32 AW_ACTIVATE = 0x00020000;
            public const Int32 AW_HIDE = 0x00010000;
            public const Int32 AW_SLIDE = 0x00040000;
     public Form1()
            {
                InitializeComponent();
                SetClassLong(this.Handle, GCL_STYLE, GetClassLong(this.Handle, GCL_STYLE) | CS_DropSHADOW);//API函数加载 

        ,实现窗体边框阴影效果
                this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |     

    ControlStyles.OptimizedDoubleBuffer, true);
            }
     #region 窗体拖动代码
            //
            public const int WM_NCLBUTTONDOWN = 0xA1;
            public const int HTCAPTION = 0x2;

            [DllImportAttribute("user32.dll")]
            public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

            [DllImportAttribute("user32.dll")]
            public static extern bool ReleaseCapture();
            private void Form1_MouseDown(object sender, MouseEventArgs e)//在窗体事件中手动添加,注意引用,无引用则无法完成
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
            }
            #endregion
            #region 窗体边框阴影效果
            const int CS_DropSHADOW = 0x20000;
            const int GCL_STYLE = (-26);
            //声明win32 api
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            public static extern int SetClassLong(IntPtr hwnd, int nIndex, int deNewLong);
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            public static extern int GetClassLong(IntPtr hwnd, int nIndex);   #endregion
        

    private void Form1_Load(object sender, EventArgs e)
                {
                    AnimateWindow(this.Handle, 500, AW_BLEND | AW_CENTER | AW_ACTIVATE);

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

  • 相关阅读:
    HDU 4489 The King’s Ups and Downs (DP+数学计数)
    HDU 2084 数塔 (水DP)
    CodeForces 706C Hard problem (水DP)
    CodeForces 706B Interesting drink (二分查找)
    CodeForces 706A Beru-taxi (数学计算,水题)
    HDU 4438 Hunters (数学,概率计算)
    机器学习-基础知识
    如何学习-学习理论(A-1)-KOLB学习周期理论
    如何学习-辅助工具
    如何学习-入门之后
  • 原文地址:https://www.cnblogs.com/licongzhuo/p/5091157.html
Copyright © 2011-2022 走看看