怎样用c#制作程序的启动画面? 用flash做好 嵌入就可以了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 using System.Runtime.InteropServices; private void Form1_Load(object sender, System.EventArgs e) { Win32.AnimateWindow(this.Handle,2000,Win32.AW_BLEND); } public class Win32 { 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; [DllImport("user32.dll", CharSet=CharSet.Auto)] public static extern bool AnimateWindow( IntPtr hwnd, // handle to window int dwTime, // duration of animation int dwFlags // animation type ); } 注意1、使用前要 using System.Runtime.InteropServices; 2、Form的WinState屬性必須為Normal,不能為最大化,否則看不到效果3、AnimateWindow方法的第二個參數即為特效持續時間,單位為毫秒4、Win32類中的各種常量都可以試一試,分別代表不同的窗體特效,如百葉窗等 停留2"可以用timer控件 在这段时间内改变窗口的Opacity(透明度) 来做深入浅出 looner(looner) :大哥能不能解释一下?多谢!! 加一个timer来控件窗体的Opacity属性值的大小就可以做到啊. 大家理解错了,是这样:有两个winForm:A,B我想启动A,但是我希望在启动A之前先让B出现,B停留2",然后淡出,随后A才显示给使用者。怎样实现?? 完整的代碼(完全替換你的Form裡面的代碼後可直接運行)using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using System.Runtime.InteropServices; namespace activeForm{ /// <summary> /// Form1 的摘要描述。 /// </summary> public class Form1 : System.Windows.Forms.Form { /// <summary> /// 設計工具所需的變數。 /// </summary> private System.ComponentModel.Container components = null; public Form1() { // // Windows Form 設計工具支援的必要項 // InitializeComponent(); // // TODO: 在 InitializeComponent 呼叫之後加入任何建構函式程式碼 // } /// <summary> /// 清除任何使用中的資源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form 設計工具產生的程式碼 /// <summary> /// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改 /// 這個方法的內容。 /// </summary> private void InitializeComponent() { // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 15); this.ClientSize = new System.Drawing.Size(292, 273); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); } #endregion /// <summary> /// 應用程式的主進入點。 /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } private void Form1_Load(object sender, System.EventArgs e) { Win32.AnimateWindow(this.Handle,2000,Win32.AW_BLEND); } } public class Win32 { 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; [DllImport("user32.dll", CharSet=CharSet.Auto)] public static extern bool AnimateWindow( IntPtr hwnd, // handle to window int dwTime, // duration of animation int dwFlags // animation type ); }} 回lzhlcj (山水) 聲明 using System.Runtime.InteropServices; 是為了使你程序可以調用API函數AnimateWindow 就是一個用DllImport指明你要調的API所處於哪個文件至於具體AnimateWindow每個參數代表什麼意思,你在編譯環境下打個逗號它自己就有說明了 在要做启动画面的窗口里面丢两个timer窗口启动事件写上 timer1.start(); timer1的Tick事件写上if(this.Opacity<1) { this.Opacity+=0.01; } else { timer1.Stop(); timer2.Start(); }timer2的Tick事件写上if(this.Opacity >0) { this.Opacity-=0.01; } else { timer2.Stop(); this.Dispose(); } 主窗體的代碼:using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;namespace activeForm{ /// <summary> /// Form1 的摘要描述。 /// </summary> public class frmMain : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; /// <summary> /// 設計工具所需的變數。 /// </summary> private System.ComponentModel.Container components = null; public frmMain() { // // Windows Form 設計工具支援的必要項 // InitializeComponent(); // // TODO: 在 InitializeComponent 呼叫之後加入任何建構函式程式碼 // } /// <summary> /// 清除任何使用中的資源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form 設計工具產生的程式碼 /// <summary> /// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改 /// 這個方法的內容。 /// </summary> private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 // this.label1.Font = new System.Drawing.Font("新細明體", 36F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((System.Byte)(136))); this.label1.ForeColor = System.Drawing.Color.Red; this.label1.Location = new System.Drawing.Point(8, 88); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(224, 96); this.label1.TabIndex = 0; this.label1.Text = "主窗體"; // // frmMain // this.AutoScaleBaseSize = new System.Drawing.Size(5, 15); this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.Add(this.label1); this.Name = "frmMain"; this.Text = "主窗體"; this.Load += new System.EventHandler(this.frmMain_Load); this.ResumeLayout(false); } #endregion /// <summary> /// 應用程式的主進入點。 /// </summary> [STAThread] static void Main() { Application.Run(new frmMain()); } private void frmMain_Load(object sender, System.EventArgs e) { frmMask objFrmMask = new frmMask(); objFrmMask.ShowDialog(); } }} Mask窗體的代碼:using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Runtime.InteropServices; namespace activeForm{ /// <summary> /// Form2 的摘要描述。 /// </summary> public class frmMask : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; /// <summary> /// 設計工具所需的變數。 /// </summary> private System.ComponentModel.Container components = null; public frmMask() { // // Windows Form 設計工具支援的必要項 // InitializeComponent(); // // TODO: 在 InitializeComponent 呼叫之後加入任何建構函式程式碼 // } /// <summary> /// 清除任何使用中的資源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form 設計工具產生的程式碼 /// <summary> /// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改 /// 這個方法的內容。 /// </summary> private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 // this.label1.Font = new System.Drawing.Font("新細明體", 36F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((System.Byte)(136))); this.label1.ForeColor = System.Drawing.Color.Blue; this.label1.Location = new System.Drawing.Point(34, 88); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(224, 96); this.label1.TabIndex = 1; this.label1.Text = "Mask窗體"; // // frmMask // this.AutoScaleBaseSize = new System.Drawing.Size(5, 15); this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.Add(this.label1); this.Name = "frmMask"; this.Text = "Mask窗體"; this.Load += new System.EventHandler(this.Form2_Load); this.ResumeLayout(false); } #endregion private void Form2_Load(object sender, System.EventArgs e) { Win32.AnimateWindow(this.Handle,2000,Win32.AW_BLEND); this.Dispose(); } } public class Win32 { 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; [DllImport("user32.dll", CharSet=CharSet.Auto)] public static extern bool AnimateWindow( IntPtr hwnd, // handle to window int dwTime, // duration of animation int dwFlags // animation type ); }} 如何关联两个滚动条? 新手提个问题 关于一个ADO.NET Entity Framework 连接的问题 c#生成XML文件中的声明<xml version="1.0" encoding="UTF-8">没有显示出来 求问关于DateTime如何生成特定时间 WPF Style Converter 我用windows服务读取消息队列中的消息,没效果! 如何将URL后面的参数截下来啊? 网络新手问C#里socket客户端如何接收服务器端不定时发送的数据,采用TCP连接。有什么事件?或委托呢? 数据更新时出现同步错误,如何解决呢? 急救!关于字符串转换问题 怎样添加个button?
private void Form1_Load(object sender, System.EventArgs e)
{
Win32.AnimateWindow(this.Handle,2000,Win32.AW_BLEND);
}
public class Win32
{
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;
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern bool AnimateWindow(
IntPtr hwnd, // handle to window
int dwTime, // duration of animation
int dwFlags // animation type
);
}
1、使用前要 using System.Runtime.InteropServices;
2、Form的WinState屬性必須為Normal,不能為最大化,否則看不到效果
3、AnimateWindow方法的第二個參數即為特效持續時間,單位為毫秒
4、Win32類中的各種常量都可以試一試,分別代表不同的窗體特效,如百葉窗等
在这段时间内改变窗口的Opacity(透明度) 来做深入浅出
大哥能不能解释一下?
多谢!!
有两个winForm:A,B
我想启动A,但是我希望在启动A之前先让B出现,B停留2",然后淡出,随后A才显示给使用者。
怎样实现??
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace activeForm
{
/// <summary>
/// Form1 的摘要描述。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// 設計工具所需的變數。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows Form 設計工具支援的必要項
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 呼叫之後加入任何建構函式程式碼
//
} /// <summary>
/// 清除任何使用中的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form 設計工具產生的程式碼
/// <summary>
/// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load); }
#endregion /// <summary>
/// 應用程式的主進入點。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void Form1_Load(object sender, System.EventArgs e)
{
Win32.AnimateWindow(this.Handle,2000,Win32.AW_BLEND);
}
}
public class Win32
{
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;
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern bool AnimateWindow(
IntPtr hwnd, // handle to window
int dwTime, // duration of animation
int dwFlags // animation type
);
}
}
聲明 using System.Runtime.InteropServices; 是為了使你程序可以調用API函數
AnimateWindow 就是一個用DllImport指明你要調的API所處於哪個文件至於具體AnimateWindow每個參數代表什麼意思,你在編譯環境下打個逗號它自己就有說明了
窗口启动事件写上
timer1.start(); timer1的Tick事件写上if(this.Opacity<1)
{
this.Opacity+=0.01;
}
else
{
timer1.Stop();
timer2.Start();
}
timer2的Tick事件写上if(this.Opacity >0)
{
this.Opacity-=0.01; }
else
{
timer2.Stop(); this.Dispose();
}
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace activeForm
{
/// <summary>
/// Form1 的摘要描述。
/// </summary>
public class frmMain : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
/// <summary>
/// 設計工具所需的變數。
/// </summary>
private System.ComponentModel.Container components = null; public frmMain()
{
//
// Windows Form 設計工具支援的必要項
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 呼叫之後加入任何建構函式程式碼
//
} /// <summary>
/// 清除任何使用中的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form 設計工具產生的程式碼
/// <summary>
/// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Font = new System.Drawing.Font("新細明體", 36F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((System.Byte)(136)));
this.label1.ForeColor = System.Drawing.Color.Red;
this.label1.Location = new System.Drawing.Point(8, 88);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(224, 96);
this.label1.TabIndex = 0;
this.label1.Text = "主窗體";
//
// frmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.label1);
this.Name = "frmMain";
this.Text = "主窗體";
this.Load += new System.EventHandler(this.frmMain_Load);
this.ResumeLayout(false); }
#endregion /// <summary>
/// 應用程式的主進入點。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new frmMain());
} private void frmMain_Load(object sender, System.EventArgs e)
{
frmMask objFrmMask = new frmMask();
objFrmMask.ShowDialog();
}
}}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace activeForm
{
/// <summary>
/// Form2 的摘要描述。
/// </summary>
public class frmMask : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
/// <summary>
/// 設計工具所需的變數。
/// </summary>
private System.ComponentModel.Container components = null; public frmMask()
{
//
// Windows Form 設計工具支援的必要項
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 呼叫之後加入任何建構函式程式碼
//
} /// <summary>
/// 清除任何使用中的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form 設計工具產生的程式碼
/// <summary>
/// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Font = new System.Drawing.Font("新細明體", 36F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((System.Byte)(136)));
this.label1.ForeColor = System.Drawing.Color.Blue;
this.label1.Location = new System.Drawing.Point(34, 88);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(224, 96);
this.label1.TabIndex = 1;
this.label1.Text = "Mask窗體";
//
// frmMask
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.label1);
this.Name = "frmMask";
this.Text = "Mask窗體";
this.Load += new System.EventHandler(this.Form2_Load);
this.ResumeLayout(false); }
#endregion private void Form2_Load(object sender, System.EventArgs e)
{
Win32.AnimateWindow(this.Handle,2000,Win32.AW_BLEND);
this.Dispose();
}
}
public class Win32
{
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;
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern bool AnimateWindow(
IntPtr hwnd, // handle to window
int dwTime, // duration of animation
int dwFlags // animation type
);
}
}