• 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();
            }
        }
    }

    踏实做一个为人民服务的搬运工!
  • 相关阅读:
    HTML5智能表单
    HTML表单
    CSS文档统筹
    二分查找/折半查找(C++实现)
    实验6:Problem H: 字符串类(II)
    实验6:Problem G: 字符串类(I)
    实验6:Problem F: 时间和日期类(IV)
    实验6:Problem E: 时间和日期类(III)
    实验6:Problem D: 时间和日期类(II)
    实验6:Problem C: 时间和日期类(I)
  • 原文地址:https://www.cnblogs.com/LifeDecidesHappiness/p/14565925.html
Copyright © 2020-2023  润新知