http://wenku.baidu.com/view/c1ad1227482fb4daa58d4bfe.html /// <summary> /// enumeration that describes the form of message window loading /// </summary> public enum loadmode { /// <summary> /// Warnings /// </summary> Warning, /// <summary> /// Errors /// </summary> Error, /// <summary> /// Tips /// </summary> prompt } /// < summary> /// Message Prompt window /// </summary> public partial class formmessagebox : form { /// <summary> /// Construction Methods /// </summary> public formmessagebox () { initializecomponent (); } #region ****** Word Segment *********************** /// < summary> /// Form Load Mode /// </ Summary> private static loadmode formmode = LoadMode.Prompt; /// <summary> /// the message body displayed /// </summary> private static string showmessage = null; /// <summary> /// Close the window timer /// </summary> private timer timer_close = new timer (); [dllimportattribute ("User32.dll" )] private static extern bool animatewindow (IntPtr hwnd, int dwtime, int dwflags); // The function can animate the form public const int32 aw_hor_positive = 0x00000001; / / Displays the window from left to right. This flag can be used in scrolling animations and slide animations. When the Aw_center flag is used, the flag is ignored public const int32 AW_HOR_NEGATIVE = 0x00000002; // Displays the window from right to left. When the AW_CENTER flag is used, the flag is ignored public const int32 AW_VER_POSITIVE = 0x00000004; // Displays the window from top to bottom. This flag can be used in scrolling animations and slide animations. When the Aw_center flag is used, the flag is ignored public const int32 aw_ ver_negative = 0x00000008; // Displays the window from the bottom up. This flag can be used in scrolling animations and slide animations. When the Aw_center flag is used, the flag is ignored public const int32 aw_center = 0x00000010; // If the Aw_hide flag is used, the window will overlap inward, and if the AW_HIDE flag is not used, the window is extended outward public const Int32 AW_HIDE = 0x00010000; // Hide window, default display window public const Int32 AW_ACTIVATE = 0x00020000; // Activate window. Do not use this flag after using the AW_HIDE flag public const int32 aw_ slide = 0x00040000; // use sliding type. The default is the scrolling animation type. This flag is ignored when using the Aw_center flag public const int32 aw_ blend = 0x00080000; // uses the fade effect.This flag can only be used when the HWND is the top-level window #endregion ***************************** #region *********************** Fang Law *********************** /// <summary> /// Construction Method /// </summary> /// <param name= "LoadMode" > Load mode </param> /// <param name= "message" > Message Body </param> public static void show ( Loadmode loadmode, string message) { FormMode = loadMode; showmessage = message; formmessagebox box = new formmessagebox (); box. Show (); } # endregion************************************************* # region *********************** Pieces *********************** /// <summary> /// Form Load Events /// </summary> / <param name= "Sender" ></param> /// <param name= "E" ></param> &nBsp;private void formmessagebox_load (object sender, eventargs e) { this.lbltitle.text = "hint"; if (Formmode == loadmode.error) { this.lbltitle.text = "Error"; this.plshow.backgroundimage = global::d ataSource.Properties.Resources.error; // change background } else if (formmode == loadmode.warning) { this.lblTitle.Text = "Warning"; this.plshow.backgroundimage = global::d atasource.properties.resources.warning; // Change Background } else { this.plshow.backgroundimage = global::d atasource.properties.resources.prompt; // Change Background } this.lblmessage.text = showmessage; int width = system.windows.forms.screen.primaryscreen.bounds.width; int height = system.windows.forms.screen.primaryscreen.bounds.height; int top = height - 35 - this. Height; int left = width - this. Width - 5; this. Top = top; this. Left = left; this. Topmost = true; animatewIndow (this. handle, 500, aw_slide + aw_ver_negative);//Start Form animation this. Showintaskbar = false; timer_ Close.interval = 4000; timer_ Close.tick += new eventhandler (Timer_close_tick); timer_close.start (); } /// <summary> /// Close the window's Timer response event /// </summary> /// <param name= "Sender" ></param> /// <param name= "E" ></param>&nbSp; private void timer_close_tick (object sender, Eventargs e) { timer_close.stop (); this. Close (); } /// <summary> /// window is closed /// </summary> /// < Param name= "Sender" ></param> /// <param name= "E" ></param> private void Formmessagebox_formclosed (object sender, formclosedeventargs e) { animatewindow (this. Handle, 500, aw_slide + aw_ver_positive + aw_hide); timer_close.stop (); timer_close.dispose (); } /// <summary> /// mouse moves on the message box /// </summary> /// <param name= "Sender" ></param> /// <param name= "E" ></param> private void plshow_mousemove (Object sender, mouseeventargs e) &nbSp; { this. Timer_close.stop (); } /// <summary> /// move the mouse away from the message box /// </summary> / <param name= "Sender" ></param> /// <param name= "E" ></param> private Void plshow_mouseleave (object sender, eventargs e) { this. Timer_close.start (); }
C # implements pop-up window in the lower right corner