Winform登录界面美化

一、登录窗口
1、导入背景图 添加背景图片之后设置窗体的BackImageFlayOut属性为strech
在这里插入图片描述
2、添加Icon图标
3、隐藏form边框(上图)修改FormBorderStyle的属性为None
4、添加labelClosed :× 更改背景颜色和字体颜色
5、添加两个pictureBox 插入图标
在这里插入图片描述
6、添加TransTextBox类 制作透明TextBox 更改字体颜色。
7、添加Button按钮
在这里插入图片描述
设置按钮的属性:
FlatStyle = Flat;
设置FlatAppearanc里的属性
BorderSize = 0; BackColor = Transparent;
设置事件MouseEnter触发函数:
private void button1_MouseEnter(object sender, EventArgs e)
{
button1.FlatStyle = FlatStyle.Flat; //样式
//button1.ForeColor = Color.Transparent;//前景
button1.BackColor = Color.Transparent;//去背景
//button1.FlatAppearance.BorderSize = 0;//去边线
button1.FlatAppearance.MouseOverBackColor = Color.FromArgb(50, 40, 60, 82);
button1.FlatAppearance.MouseDownBackColor = Color.FromArgb(50, 40, 60, 82);
}
二、难度确认

#region --win7*Aero效果--
        [StructLayout(LayoutKind.Sequential)]
        public struct MARGINS
        {
            public int Left;
            public int Right;
            public int Top;
            public int Bottom;
        }

        [DllImport("dwmapi.dll", PreserveSig = false)]
        static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins);

        [DllImport("dwmapi.dll", PreserveSig = false)]
        static extern bool DwmIsCompositionEnabled(); //Dll 导入 DwmApi

        protected override void OnPaintBackground(PaintEventArgs e)
        {
            base.OnPaintBackground(e);
            if (DwmIsCompositionEnabled())
            {
                e.Graphics.Clear(Color.Black); //将窗体用黑色填充(Dwm 会把黑色视为透明区域)
            }
        }
        #endregion

        public transfer()
        {
            InitializeComponent();
        }

        private void transfer_Load(object sender, EventArgs e)
        {
            if (DwmIsCompositionEnabled())//如果启用Aero
            {
                MARGINS m = new MARGINS();
                m.Right = -1; //设为负数,则全窗体透明
                DwmExtendFrameIntoClientArea(this.Handle, ref m); //开启全窗体透明效果
             }
        }

效果图
在这里插入图片描述

c# winform 显示动态gif图片的简单方法
1、添加Label控件
2、准备个gif图片
3、Label控件的Image属性设成gif图
4、AutoSize=false
5、设置控件大小

c# winform 显示透明TextBox

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ******
{
    class TransTextBox:RichTextBox
    {
       
   
            [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
            static extern IntPtr LoadLibrary(string lpFileName);

            protected override CreateParams CreateParams
            {
                get
                {
                    CreateParams prams = base.CreateParams;
                    if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
                    {
                        prams.ExStyle |= 0x020;
                        prams.ClassName = "RICHEDIT50W";
                    }
                    return prams;
                }
            }
        

    }
}

发布了4 篇原创文章 · 获赞 0 · 访问量 41

猜你喜欢

转载自blog.csdn.net/qq_36655686/article/details/103989329
今日推荐