C#中声明如下:
using System.Runtime.InteropServices;
[DllImport("user32.dll", EntryPoint = "FindWindowA")]
public static extern IntPtr FindWindowA(string lp1, string lp2);
[DllImport("user32.dll", EntryPoint = "ShowWindow")]
public static extern IntPtr ShowWindow(IntPtr hWnd, int _value);
其实Windows的任务栏就是一个特殊的窗口,所以操作窗口的方法,对任务栏一样适合!控制代码如下:
//获取任务栏
IntPtr hTray = Form1.FindWindowA("Shell_TrayWnd", String.Empty);
//显示任务栏
Form1.ShowWindow(hTray, 5);
//隐藏任务栏
Form1.ShowWindow(hTray, 0);
C# Signature:
[DllImport("user32.dll")]
static extern bool DrawAnimatedRects(IntPtr hwnd, int idAni,
[In] ref RECT lprcFrom, [In] ref RECT lprcTo);
User-Defined Types:
Notes:
Only the IDANI_CAPTION constant will result in any animation. Any other constants have not been implemented on any Windows platform!
Tips & Tricks:
Since only IDANI_CAPTION is implemented, to get the effect of IDANI_OPEN, simply swap the lprcFrom and lprcTo rectangles, but still specify the IDANI_CAPTION constant.
Sample Code:
/// <summary>
/// This constant is not implemented on any Windows platform!
/// </summary>
public const System.Int32 IDANI_OPEN = 1;
/// <summary>
/// The window caption will animate from lprcFrom to lprcTo.
/// </summary>
public const System.Int32 IDANI_CAPTION = 3;
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
struct RECT
{
public RECT(System.Drawing.Rectangle rectangle)
{
Left = rectangle.Left;
Top = rectangle.Top;
Right = rectangle.Right;
Bottom = rectangle.Bottom;
}
public RECT(System.Drawing.Point location, System.Drawing.Size size)
{
Left = location.X;
Top = location.Y;
Right = location.X + size.Width;
Bottom = location.Y + size.Height;
}
public System.Int32 Left;
public System.Int32 Top;
public System.Int32 Right;
public System.Int32 Bottom;
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern bool DrawAnimatedRects(System.IntPtr hwnd, int idAni,
[System.Runtime.InteropServices.In] ref RECT lprcFrom,
[Sy