程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> c#軟件窗體的淡入淡出

c#軟件窗體的淡入淡出

編輯:C#入門知識

private void Form1_Load(object sender, System.EventArgs e)
for(double d=0.01; d< 1; d+=0.02)
{
System.Threading.Thread.Sleep(1);
Application.DoEvents();
this.Opacity=d;
this.Refresh();
}
 
2.www.2cto.com
private void timer1_Tick(object sender, System.EventArgs e)
{
this.Opacity = WinShow ;
WinShow += 0.1 ;
if(WinShow >=1 )
{
timer1.Dispose ();
}
}
3.
用循環或計時器,
 
frmForm myForm=new frmForm()
frmForm.Opacity=0;
frmForm.show();
for(int i=0;i<100;i++)
{
Application.DoEvents()
frmForm.Opacity=i/100;
}
 
4.
 
#region ******** 窗體淡入效果函數********
private double WinShow = 0;//用於窗口淡入效果的變量
private void FormShow(System.Windows.Forms.Form Curfrm)
{
Curfrm.Opacity = WinShow ;
WinShow += 0.01;
if(WinShow == 1)
{
Curfrm.timerShow.Stop ();
}
}
 
#endregion
#region ******** 窗體淡入效果函數調用示例********
//實現窗口的淡入效果
private void timerShow_Tick(object sender, System.EventArgs e)
{
//timerShow,這是一個timer控件名稱;把timerShow.interval=100就可以了。
FormShow(this);
}
#endregion
 
5.
 
using System.Runtime.InteropServices;
 
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
);
}
 
 
/*淡入窗體*/
 
private void Form_Load(object sender, EventArgs e)
{
Win32.AnimateWindow(this.Handle, 2000, Win32.AW_BLEND);
}
 
/*淡出窗體*/
 
 
private void Form_FormClosing(object sender, FormClosingEventArgs e)
{
Win32.AnimateWindow(this.Handle, 2000, Win32.AW_SLIDE | Win32.AW_HIDE | Win32.AW_BLEND);
}

摘自 http://www.xssxss.com/fuck/798.xss

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved