C # There are a lot of software written. How can I add pop-up advertisements such as sogou Input Method software and the lower right corner of the screen of the linger translation software.
C # The Code is as follows:
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. LINQ;
Using system. text;
Using system. Windows. forms;
Using system. runtime. interopservices;
Namespace datasource
{
/// <Summary> /// enumeration, description of the message window loading format /// </Summary> Public Enum loadmode {// <summary> /// warning /// </Summary> warning, /// <summary> /// error /// </Summary> error, /// <summary> /// prompt /// </Summary> prompt} // <summary> // message Prompt window
///
Public partial class formmessagebox: FORM {// <summary> /// constructor /// </Summary> Public formmessagebox () {initializecomponent ();} # region ************* * ******** // <summary> // form Loading Mode /// </Summary> Private Static loadmode formmode = loadmode. prompt; // <summary> // message body displayed // </Summary> Private Static string showmessage = NULL; /// <summary> /// the timer for closing the window /// </Summary> private timer timer_close = new timer ();
///
/// Constructor // </Summary> Public formmessagebox (){
[Dllimportattribute ("user32.dll")]
Private Static extern bool animatewindow (intptr hwnd, int dwtime, int dwflags); // This function can achieve the form animation effect public const int32 aw_hor_positive = 0x00000001; // display the window from left to right. This flag can be used in rolling and sliding animations. When the aw_center flag is used, the public const int32 aw_hor_negative = 0x00000002 is ignored; // The window is displayed from the right to the left. When the aw_center flag is used, public const int32 aw_ver_positive = 0x00000004 is ignored. // The window is displayed from top to bottom. This flag can be used in rolling and sliding animations. When the aw_center flag is used, the public const int32 aw_ver_negative = 0x00000008 is ignored; // The window is displayed from bottom to top. This flag can be used in rolling and sliding animations. When the aw_center flag is used, the public const int32 aw_center = 0x00000010 is ignored. // If the aw_hide flag is used, the window overlaps inwards. If the aw_hide flag is not used, expand the window to public const int32 aw_hide = 0x00010000; // hide the window. The window public const int32 aw_activate = 0x00020000 is displayed by default. // activate the window. Do not use this flag public const int32 aw_slide = 0x00040000 after the aw_hide flag is used; // use the slide type. The default value is the scroll animation type. When the aw_center flag is used, this flag is ignored. Public const int32 aw_blend = 0x00080000; // use the fade-in effect. This flag can be used only when hwnd is a top-level window # endregion ************************* * ********************** # region ************** ********************************** // <summary> /// constructor /// </Summary> /// <Param name = "loadmode"> loading mode </param> /// <Param name = "message"> message Body </param> Public static void show (loadmode, string message) initializecomponent ();} # region ************* * ******** // <summary> // form Loading Mode /// </Summary> Private Static loadmode formmode = loadmode. prompt; // <summary> // message body displayed // </Summary> Private Static string showmessage = NULL; /// <summary> /// the timer for closing the window /// </Summary> private timer timer_close = new timer ();
Formmode = loadmode;
Showmessage = message; formmessagebox box = new formmessagebox (); box. show ();} # endregion ************************************** * ********* # region **************************** event ** * ******************* // <summary> // form loading event // </Summary> /// <Param name = "sender"> </param> /// <Param name = "E"> </param> private void formmessagebox_load (Object sender, eventargs e) {This. lbltitle. TEXT = "prompt"; if (formmode = loadmode. error) {This. lbltitle. TEXT = "error"; this. plshow. backgroundimage = Global: datasource. properties. resources. error; // Change Background} else if (formmode = loadmode. warning) {This. lbltitle. TEXT = "warning"; this. plshow. backgroundimage = Global: datasource. properties. resources. warning; // Change Background} else
{
This. plshow. backgroundimage = Global: datasource. properties. resources. prompt; // change the 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 the form animation this. showintaskbar = false; timer_close.interval = 4000; timer_close.tick + = new eventhandler (timer_close_tick); timer_close.start ();} /// <summary> /// the timer that closes the window responds to the event // </Summary> /// <Param name = "sender"> </param> /// <Param name = "E"> </param> private void timer_close_tick (Object sender, eventargs e) {timer_close.stop (); this. close ();
///
/// The 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> /// move the cursor over the message box /// </Summary> /// <Param name = "sender"> </param> /// <Param name = "E"> </param> private void plshow_mousemove (Object sender, mouseeventargs e) {This. timer_close.stop ();} /// <summary> /// move the cursor 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 ();}
Endregion
*
The Code is fully available
C # how to add pop-up ads to desktop applications