程序的完整代碼如下:
Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace FalshWindows
{
public partial class Form1 : Form
{
[DllImportAttribute ("user32.dll")]
private static extern bool AnimateWindow (IntPtr hwnd, int dwTime, int dwFlags);
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;
public Form1()
{
InitializeComponent();
AnimateWindow(this.Handle, 1000, AW_SLIDE + AW_CENTER);
}
private void Form1_FormClosed (object sender, FormClosedEventArgs e)
{
AnimateWindow(this.Handle, 500, AW_SLIDE + AW_VER_POSITIVE + AW_HIDE);
}
}
}
後記: 雖為一雕蟲小技,但蘊涵著很多思想, 大 家可以眼高, 但手一定要底.
必得原理,編程是件很快樂的事.