窗体动态效果实现 本人是新手,现在做KTV项目,需要从第一个窗体跳到第二个窗体时,有动态效果,谢谢各位大哥大姐帮忙解决一下,小弟在这里感谢了!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 怎么ktv的项目老火了。http://topic.csdn.net/u/20120303/12/e6bf630d-5b6f-47f2-947b-d9ec1e244c7e.html?77755下面几个链接下个项目自己去玩玩 动态效果? lz,想要什么样的动态效果? 不妨加一个进度条,但。这样一来的话,那就不符合现实生活的 KTV 系统了。 先找个地方声明如下的Win32 API://-- 窗体动画 --// /* 1. AW_SLIDE : 使用滑动类型, 默认为该类型. 当使用 AW_CENTER 效果时, 此效果被忽略 2. AW_ACTIVE: 激活窗口, 在使用了 AW_HIDE 效果时不可使用此效果 3. AW_BLEND: 使用淡入效果 4. AW_HIDE: 隐藏窗口 5. AW_CENTER: 与 AW_HIDE 效果配合使用则效果为窗口几内重叠, 单独使用窗口向外扩展. 6. AW_HOR_POSITIVE : 自左向右显示窗口 7. AW_HOR_NEGATIVE: 自右向左显示窗口 8. AW_VER_POSITVE: 自顶向下显示窗口 9. AW_VER_NEGATIVE : 自下向上显示窗口 */ public const Int32 AW_HOR_POSITIVE = 0x00000001; // 从左向右显示 public const Int32 AW_HOR_NEGATIVE = 0x00000002; // 从右向左显示 public const Int32 AW_VER_POSITIVE = 0x00000004; // 从上到下显示 public const Int32 AW_VER_NEGATIVE = 0x00000008; // 从下到上显示 public const Int32 AW_CENTER = 0x00000010; // 从中间向四周 public const Int32 AW_HIDE = 0x00010000; // 隐藏显示 public const Int32 AW_ACTIVATE = 0x00020000; // 普通显示 public const Int32 AW_SLIDE = 0x00040000; // 滑动显示 public const Int32 AW_BLEND = 0x00080000; // 透明渐变显示 private const int DURATION_OF_TIME = 600; // 效果持续时间 [DllImport("user32.dll", EntryPoint = "AnimateWindow", ExactSpelling = true, SetLastError = true)] public static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags); /// <summary> /// 随机动画打开窗体 /// </summary> /// <param name="hwnd">窗体句柄</param> public static void RandomAnimateOpenWindow(IntPtr hwnd) { int animateType = 10; Random rand = new Random(); int dwFlags = (int)rand.Next(animateType); switch (dwFlags) { case 0: // 普通显示 // AnimateWindow(hwnd, DURATION_OF_TIME, AW_ACTIVATE); // 透明渐变显示 AnimateWindow(hwnd, DURATION_OF_TIME, AW_BLEND); break; case 1: // 从左向右显示 AnimateWindow(hwnd, DURATION_OF_TIME, AW_HOR_POSITIVE); break; case 2: // 从右向左显示 AnimateWindow(hwnd, DURATION_OF_TIME, AW_HOR_NEGATIVE); break; case 3: // 从上到下显示 AnimateWindow(hwnd, DURATION_OF_TIME, AW_VER_POSITIVE); break; case 4: // 从下到上显示 AnimateWindow(hwnd, DURATION_OF_TIME, AW_VER_NEGATIVE); break; case 5: // 透明渐变显示 AnimateWindow(hwnd, DURATION_OF_TIME, AW_BLEND); break; case 6: // 从中间向四周 AnimateWindow(hwnd, DURATION_OF_TIME, AW_CENTER); break; case 7: // 左上角伸展 AnimateWindow(hwnd, DURATION_OF_TIME, AW_SLIDE | AW_HOR_POSITIVE | AW_VER_POSITIVE); break; case 8: // 左下角伸展 AnimateWindow(hwnd, DURATION_OF_TIME, AW_SLIDE | AW_HOR_POSITIVE | AW_VER_NEGATIVE); break; case 9: // 右上角伸展 AnimateWindow(hwnd, DURATION_OF_TIME, AW_SLIDE | AW_HOR_NEGATIVE | AW_VER_POSITIVE); break; case 10:// 右下角伸展 AnimateWindow(hwnd, DURATION_OF_TIME, AW_SLIDE | AW_HOR_NEGATIVE | AW_VER_NEGATIVE); break; } } /// <summary> /// 淡入动画打开窗体 /// </summary> /// <param name="hwnd">窗体句柄</param> public static void AnimateOpenWindow(IntPtr hwnd) { AnimateWindow(hwnd, DURATION_OF_TIME, AW_BLEND | AW_ACTIVATE); } /// <summary> /// 淡出动画关闭窗体 /// </summary> /// <param name="hwnd">窗体句柄</param> public static void AnimateCloseWindow(IntPtr hwnd) { AnimateWindow(hwnd, DURATION_OF_TIME, AW_BLEND | AW_HIDE); }然后再做个窗体基类,并调用上述的动画窗体的API:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using CodingMouse.MMP.ClassLibrary.Classes;namespace CodingMouse.MMP.ControlLibrary.Forms{ public partial class BaseForm : Form { public BaseForm() { InitializeComponent(); } /// <summary> /// 窗体加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BaseForm_Load(object sender, EventArgs e) { // 淡入动画打开窗体 Win32.AnimateOpenWindow(this.Handle); } /// <summary> /// 窗体关闭事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BaseForm_FormClosing(object sender, FormClosingEventArgs e) { // 淡出动画关闭窗体 Win32.AnimateCloseWindow(this.Handle); } }}这样你继承这个窗体基类的所有窗体实例都就有动画效果了,具体采用哪种效果你换下API调用方法即可:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.IO;using System.Windows.Forms;using System.Configuration;using System.Diagnostics;using CodingMouse.MMP.UI.Common;using CodingMouse.MMP.ClassLibrary.Classes;namespace CodingMouse.MMP.UI.Forms{ /// <summary> /// 用户登录界面 /// </summary> public partial class frmLogin : CodingMouse.MMP.ControlLibrary.Forms.BaseForm { }}调用 Win32 API 实现窗体动态效果在各类语言中方法都是通用的,以前我在VFP中也这样使用,现在在C#还是一个样。 byte类型转换求助,java byte转c# byte。大神们帮忙看看 C# 用SqlDataAdapter的Update更新数据库问题 二维数组可不可以使用foreach实现遍历? 求助 c# 文件操作 访问被拒绝 在sqlhelper中调用配置文件出现问题 求教:读txt文件会乱码? 急急急,初学者,这到底怎么回事 ActiveX 控件 已拔出如何解决 关于ASP.NET(C#)导出为EXCEL的错误 (HTML可以 但是一变为ASPX都不行了??大哥们进来看看可以吗?) 关于vs.net c++函数可以返回const引用,c#有类似的么? RSA签名中怎么样自己设置p q参数?
1. AW_SLIDE : 使用滑动类型, 默认为该类型. 当使用 AW_CENTER 效果时, 此效果被忽略
2. AW_ACTIVE: 激活窗口, 在使用了 AW_HIDE 效果时不可使用此效果
3. AW_BLEND: 使用淡入效果
4. AW_HIDE: 隐藏窗口
5. AW_CENTER: 与 AW_HIDE 效果配合使用则效果为窗口几内重叠, 单独使用窗口向外扩展.
6. AW_HOR_POSITIVE : 自左向右显示窗口
7. AW_HOR_NEGATIVE: 自右向左显示窗口
8. AW_VER_POSITVE: 自顶向下显示窗口
9. AW_VER_NEGATIVE : 自下向上显示窗口
*/
public const Int32 AW_HOR_POSITIVE = 0x00000001; // 从左向右显示
public const Int32 AW_HOR_NEGATIVE = 0x00000002; // 从右向左显示
public const Int32 AW_VER_POSITIVE = 0x00000004; // 从上到下显示
public const Int32 AW_VER_NEGATIVE = 0x00000008; // 从下到上显示
public const Int32 AW_CENTER = 0x00000010; // 从中间向四周
public const Int32 AW_HIDE = 0x00010000; // 隐藏显示
public const Int32 AW_ACTIVATE = 0x00020000; // 普通显示
public const Int32 AW_SLIDE = 0x00040000; // 滑动显示
public const Int32 AW_BLEND = 0x00080000; // 透明渐变显示 private const int DURATION_OF_TIME = 600; // 效果持续时间 [DllImport("user32.dll", EntryPoint = "AnimateWindow", ExactSpelling = true, SetLastError = true)]
public static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
/// <summary>
/// 随机动画打开窗体
/// </summary>
/// <param name="hwnd">窗体句柄</param>
public static void RandomAnimateOpenWindow(IntPtr hwnd)
{
int animateType = 10;
Random rand = new Random();
int dwFlags = (int)rand.Next(animateType);
switch (dwFlags)
{
case 0: // 普通显示
// AnimateWindow(hwnd, DURATION_OF_TIME, AW_ACTIVATE);
// 透明渐变显示
AnimateWindow(hwnd, DURATION_OF_TIME, AW_BLEND);
break;
case 1: // 从左向右显示
AnimateWindow(hwnd, DURATION_OF_TIME, AW_HOR_POSITIVE);
break;
case 2: // 从右向左显示
AnimateWindow(hwnd, DURATION_OF_TIME, AW_HOR_NEGATIVE);
break;
case 3: // 从上到下显示
AnimateWindow(hwnd, DURATION_OF_TIME, AW_VER_POSITIVE);
break;
case 4: // 从下到上显示
AnimateWindow(hwnd, DURATION_OF_TIME, AW_VER_NEGATIVE);
break;
case 5: // 透明渐变显示
AnimateWindow(hwnd, DURATION_OF_TIME, AW_BLEND);
break;
case 6: // 从中间向四周
AnimateWindow(hwnd, DURATION_OF_TIME, AW_CENTER);
break;
case 7: // 左上角伸展
AnimateWindow(hwnd, DURATION_OF_TIME, AW_SLIDE | AW_HOR_POSITIVE | AW_VER_POSITIVE);
break;
case 8: // 左下角伸展
AnimateWindow(hwnd, DURATION_OF_TIME, AW_SLIDE | AW_HOR_POSITIVE | AW_VER_NEGATIVE);
break;
case 9: // 右上角伸展
AnimateWindow(hwnd, DURATION_OF_TIME, AW_SLIDE | AW_HOR_NEGATIVE | AW_VER_POSITIVE);
break;
case 10:// 右下角伸展
AnimateWindow(hwnd, DURATION_OF_TIME, AW_SLIDE | AW_HOR_NEGATIVE | AW_VER_NEGATIVE);
break;
}
} /// <summary>
/// 淡入动画打开窗体
/// </summary>
/// <param name="hwnd">窗体句柄</param>
public static void AnimateOpenWindow(IntPtr hwnd)
{
AnimateWindow(hwnd, DURATION_OF_TIME, AW_BLEND | AW_ACTIVATE);
} /// <summary>
/// 淡出动画关闭窗体
/// </summary>
/// <param name="hwnd">窗体句柄</param>
public static void AnimateCloseWindow(IntPtr hwnd)
{
AnimateWindow(hwnd, DURATION_OF_TIME, AW_BLEND | AW_HIDE);
}
然后再做个窗体基类,并调用上述的动画窗体的API:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CodingMouse.MMP.ClassLibrary.Classes;namespace CodingMouse.MMP.ControlLibrary.Forms
{
public partial class BaseForm : Form
{
public BaseForm()
{
InitializeComponent();
} /// <summary>
/// 窗体加载事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BaseForm_Load(object sender, EventArgs e)
{
// 淡入动画打开窗体
Win32.AnimateOpenWindow(this.Handle);
} /// <summary>
/// 窗体关闭事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BaseForm_FormClosing(object sender, FormClosingEventArgs e)
{
// 淡出动画关闭窗体
Win32.AnimateCloseWindow(this.Handle);
}
}
}这样你继承这个窗体基类的所有窗体实例都就有动画效果了,具体采用哪种效果你换下API调用方法即可:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Configuration;
using System.Diagnostics;
using CodingMouse.MMP.UI.Common;
using CodingMouse.MMP.ClassLibrary.Classes;namespace CodingMouse.MMP.UI.Forms
{
/// <summary>
/// 用户登录界面
/// </summary>
public partial class frmLogin : CodingMouse.MMP.ControlLibrary.Forms.BaseForm
{
}
}
调用 Win32 API 实现窗体动态效果在各类语言中方法都是通用的,以前我在VFP中也这样使用,现在在C#还是一个样。