zoukankan      html  css  js  c++  java
  • WinForm制作相对美观的登录窗体

    using System;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;
    
    namespace WinFormLoginUI
    {
        /// <summary>
        ///     WinForm制作相对美观的登录窗体
        ///     LDH @ 2021-3-22
        /// </summary>
        public partial class FrmLogin : Form
        {
            public const int WM_SYSCOMMAND = 0x0112;
            public const int SC_MOVE = 0xF010;
            public const int HTCAPTION = 0x0002;
    
    
            public FrmLogin()
            {
                InitializeComponent();
            }
    
            [DllImport("user32.dll")]
            public static extern bool ReleaseCapture();
    
            [DllImport("user32.dll")]
            public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
    
            /// <summary>
            ///     窗体的MouseDown事件
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void FrmMain_MouseDown(object sender, MouseEventArgs e)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
            }
    
            private void picExit_Click(object sender, EventArgs e)
            {
                Environment.Exit(0);
            }
    
            private void picMinimum_Click(object sender, EventArgs e)
            {
                WindowState = FormWindowState.Minimized;
            }
    
            private void FrmLogin_Load(object sender, EventArgs e)
            {
                SetWatermarks();
                MouseDown += FrmMain_MouseDown;
            }
    
            /// <summary>
            ///     Set Watermarks
            /// </summary>
            private void SetWatermarks()
            {
                txtAccount.SetWatermark("Please input your account.");
                txtPwd.SetWatermark("Please input your password.");
            }
    
            private void MyMouseMove(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    ReleaseCapture();
                    SendMessage(Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
                }
            }
    
            private void btnReset_Click(object sender, EventArgs e)
            {
                txtAccount.ResetAndFocus();
                txtPwd.Clear();
            }
        }
    }

    踏实做一个为人民服务的搬运工!
  • 相关阅读:
    固定思维的可怕(转)
    Javascript模块化编程:require.js的用法
    js中将字符串转为JSON的三种方式
    cf 55D 数位dp 好题
    fzu 2113 数位dp
    uestc 250 数位dp(水)
    hdu 3652数位dp
    数位dp 3943 二分法
    hdu 3943 经典数位dp好题
    hdu 4871 树的分治+最短路记录路径
  • 原文地址:https://www.cnblogs.com/LifeDecidesHappiness/p/14565925.html
Copyright © 2011-2022 走看看