4
Reply

how can i run this code in a thread

Bahar Jalali

Bahar Jalali

Nov 10 2009 4:28 AM
5k
hi
i have a code that is given effect on forms...

some part of this code is for closing form
but this sample code don't close form in an effect

because it don't run in a thread and i don't know how run that in a thread

please help me

my code is that:

 private void btnClose_Click(object sender, System.EventArgs e)
{
flags -= WinAPI.AW_ACTIVATE;
flags += WinAPI.AW_HIDE;
WinAPI.AnimateWindow(this.Handle,animationTime,flags);
this.Dispose();
}


and ApiClass is here :

 using System;
using System.Runtime.InteropServices;

namespace formAnimation
{
/// <summary>
/// Win32 implementation to show / hide a window with animation.
/// </summary>

public class WinAPI
{
/// <summary>
/// Animates the window from left to right. This flag can be used with roll or slide animation.
/// </summary>
public const int AW_HOR_POSITIVE = 0X1;
/// <summary>
/// Animates the window from right to left. This flag can be used with roll or slide animation.
/// </summary>
public const int AW_HOR_NEGATIVE = 0X2;
/// <summary>
/// Animates the window from top to bottom. This flag can be used with roll or slide animation.
/// </summary>
public const int AW_VER_POSITIVE = 0X4;
/// <summary>
/// Animates the window from bottom to top. This flag can be used with roll or slide animation.
/// </summary>
public const int AW_VER_NEGATIVE = 0X8;
/// <summary>
/// Makes the window appear to collapse inward if AW_HIDE is used or expand outward if the AW_HIDE is not used.
/// </summary>
public const int AW_CENTER = 0X10;
/// <summary>
/// Hides the window. By default, the window is shown.
/// </summary>
public const int AW_HIDE = 0X10000;
/// <summary>
/// Activates the window.
/// </summary>
public const int AW_ACTIVATE = 0X20000;
/// <summary>
/// Uses slide animation. By default, roll animation is used.
/// </summary>
public const int AW_SLIDE = 0X40000;
/// <summary>
/// Uses a fade effect. This flag can be used only if hwnd is a top-level window.
/// </summary>
public const int AW_BLEND = 0X80000;

/// <summary>
/// Animates a window.
/// </summary>
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int AnimateWindow (IntPtr hwand , int dwTime , int dwFlags) ;
}
}


thanks

Answers (4)