using System; using System.Runtime.InteropServices; namespace SnapForms { public class Win32 { public const int WM_MOVING = 0x0216; public const int SnapMargin = 10; [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); [DllImport("user32.dll", EntryPoint = "SetWindowPos")] public static extern bool SetWindowPos( int hWnd, // window handle int hWndInsertAfter, // placement-order handle int X, // horizontal position int Y, // vertical position int cx, // width int cy, // height uint uFlags); // window positioning flags public const int HWND_TOP = 0; public const int HWND_BOTTOM = 0x1; public const uint SWP_NOSIZE = 0x1; public const uint SWP_NOMOVE = 0x2; public const uint SWP_SHOWWINDOW = 0x40; public const int SW_HIDE = 0; public const int SW_SHOWNORMAL = 1; public const int SW_NORMAL = 1; public const int SW_SHOWMINIMIZED = 2; public const int SW_SHOWMAXIMIZED = 3; public const int SW_MAXIMIZE = 3; public const int SW_SHOWNOACTIVATE = 4; public const int SW_SHOW = 5; public const int SW_MINIMIZE = 6; public const int SW_SHOWMINNOACTIVE = 7; public const int SW_SHOWNA = 8; public const int SW_RESTORE = 9; public const int SW_SHOWDEFAULT = 10; public const int SW_FORCEMINIMIZE = 11; public const int SW_MAX = 12; /// /// Animates the window from left to right. This flag can be used with roll or slide animation. /// public const int AW_HOR_POSITIVE = 0X1; /// /// Animates the window from right to left. This flag can be used with roll or slide animation. /// public const int AW_HOR_NEGATIVE = 0X2; /// /// Animates the window from top to bottom. This flag can be used with roll or slide animation. /// public const int AW_VER_POSITIVE = 0X4; /// /// Animates the window from bottom to top. This flag can be used with roll or slide animation. /// public const int AW_VER_NEGATIVE = 0X8; /// /// Makes the window appear to collapse inward if AW_HIDE is used or expand outward if the AW_HIDE is not used. /// public const int AW_CENTER = 0X10; /// /// Hides the window. By default, the window is shown. /// public const int AW_HIDE = 0X10000; /// /// Activates the window. /// public const int AW_ACTIVATE = 0X20000; /// /// Uses slide animation. By default, roll animation is used. /// public const int AW_SLIDE = 0X40000; /// /// Uses a fade effect. This flag can be used only if hwnd is a top-level window. /// public const int AW_BLEND = 0X80000; /// /// Animates a window. /// [DllImport("user32.dll", CharSet=CharSet.Auto)] public static extern int AnimateWindow(IntPtr hwand , int dwTime , int dwFlags) ; } }