WinForm显示关闭窗体特效封装
标签:art app 拉伸 struct new windows gpo using nfa
using System;
using System.Drawing;
using System.Windows.Forms;
namespace AnimationForm
{
///
/// WinForm常用的几种显示特效
/// LDH @ 2018-2-25
///
public partial class FrmMain : Form
{
#region Constructor
public FrmMain()
{
InitializeComponent();
}
#endregion
#region Form Events
///
/// 窗体加载事件
///
///
///
private void FrmMain_Load(object sender, EventArgs e)
{
Win32EffectHelper.ExpandEffect(this);
}
///
/// 从左到右特效
///
///
///
private void winBtnLeftToRight_Click(object sender, EventArgs e)
{
Win32EffectHelper.LeftToRightEffect(this);
}
///
/// 从右到左特效
///
///
///
private void winBtnRightToLeft_Click(object sender, EventArgs e)
{
Win32EffectHelper.RightToLeftEffect(this);
}
///
/// 从上到下特效
///
///
///
private void winBtnTopToBottom_Click(object sender, EventArgs e)
{
Win32EffectHelper.TopToBottom(this);
}
///
/// 从下到上特效
///
///
///
private void winBtnBottomToTop_Click(object sender, EventArgs e)
{
Win32EffectHelper.BottomToTop(this);
}
///
/// 渐变特效
///
///
///
private void winBtnGradualChange_Click(object sender, EventArgs e)
{
Win32EffectHelper.FadeInFadeOutEffect(this);
}
///
/// 收缩扩张特效
///
///
///
private void winBtnExpand_Click(object sender, EventArgs e)
{
Win32EffectHelper.ShrinkEffect(this);
}
///
/// 退出
///
///
///
private void exitEToolStripMenuItem_Click(object sender, EventArgs e)
{
Win32EffectHelper.Outer2MiddleDisappear(this);
}
///
/// 右下角显示窗体
///
///
///
private void winBtnShowFormInRightCorner_Click(object sender, EventArgs e)
{
Win32EffectHelper.ShowFormInRightBottomCorner(this);
}
///
/// 从上到下 伸缩后消失
///
///
///
private void winBtnTop2BottomDisappear_Click(object sender, EventArgs e)
{
Win32EffectHelper.Top2BottomDisappear(this);
}
///
/// 从下到上 伸缩后消失
///
///
///
private void winBtnBottom2TopDisappear_Click(object sender, EventArgs e)
{
Win32EffectHelper.Bottom2TopDisappear(this);
}
///
/// 从左到右 伸缩后消失
///
///
///
private void winBtnLeft2RightDisappear_Click(object sender, EventArgs e)
{
Win32EffectHelper.Left2RightDisappear(this);
}
///
/// 从右到左 伸缩后消失
///
///
///
private void winBtnRight2LeftDisappear_Click(object sender, EventArgs e)
{
Win32EffectHelper.Right2LeftDisappear(this);
}
///
/// 四周向中间 缩小后消失
///
///
///
private void winBtnOuter2MiddleDisappear_Click(object sender, EventArgs e)
{
Win32EffectHelper.Outer2MiddleDisappear(this);
}
///
/// 关闭窗体事件
///
///
///
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
Win32EffectHelper.Outer2MiddleDisappear(this);
}
#endregion
#region 控制改变窗体拉伸和移动
private const int HTLEFT = 10;
private const int HTRIGHT = 11;
private const int HTTOP = 12;
private const int HTTOPLEFT = 13;
private const int HTTOPRIGHT = 14;
private const int HTBOTTOM = 15;
private const int HTBOTTOMLEFT = 0x10;
private const int HTBOTTOMRIGHT = 17;
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x0084:
base.WndProc(ref m);
var vPoint = new Point((int) m.LParam & 0xFFFF, ((int) m.LParam >> 16) & 0xFFFF);
vPoint = PointToClient(vPoint);
if (vPoint.X 5)
{
if (vPoint.Y 5)
{
m.Result = (IntPtr) HTTOPLEFT;
}
else if (vPoint.Y >= ClientSize.Height - 5)
{
m.Result = (IntPtr) HTBOTTOMLEFT;
}
else
{
m.Result = (IntPtr) HTLEFT;
}
}
else if (vPoint.X >= ClientSize.Width - 5)
{
if (vPoint.Y 5)
{
m.Result = (IntPtr) HTTOPRIGHT;
}
else if (vPoint.Y >= ClientSize.Height - 5)
{
m.Result = (IntPtr) HTBOTTOMRIGHT;
}
else
{
m.Result = (IntPtr) HTRIGHT;
}
}
else if (vPoint.Y 5)
{
m.Result = (IntPtr) HTTOP;
}
else if (vPoint.Y >= ClientSize.Height - 5)
{
m.Result = (IntPtr) HTBOTTOM;
}
break;
case 0x0201: //鼠标左键按下的消息
m.Msg = 0x00A1; //更改消息为非客户区按下鼠标
m.LParam = IntPtr.Zero; //默认值
m.WParam = new IntPtr(2); //鼠标放在标题栏内
base.WndProc(ref m);
break;
default:
base.WndProc(ref m);
break;
}
}
#endregion
}
}
WinForm显示关闭窗体特效封装
标签:art app 拉伸 struct new windows gpo using nfa
原文地址:https://www.cnblogs.com/LifeDecidesHappiness/p/8469393.html
评论