日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

c#应用程序如何添加弹出式广告功能

發布時間:2024/1/1 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c#应用程序如何添加弹出式广告功能 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

???? 使用c#語言,如何實現像搜狗輸入法以及靈格斯翻譯軟件的屏幕右下角彈出式廣告呢?

?? c#code如下:

??

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>????///?枚舉,描述消息窗口加載的形式????///?</summary>????public?enum?LoadMode????{????????///?<summary>????????///?警告????????///?</summary>????????Warning,????????///?<summary>????????///?錯誤????????///?</summary>????????Error,????????///?<summary>????????///?提示????????///?</summary>????????Prompt????}????///?<summary>

????///?消息提示窗口

///?<summary>

????///?消息提示窗口????///?</summary>????public?partial?class?FormMessageBox?:?Form????{????????///?<summary>????????///?構造方法????????///?</summary>????????public?FormMessageBox()????????{????????????InitializeComponent();????????}????????#region?***********************字?段***********************????????///?<summary>????????///?窗體加載模式????????///?</summary>????????private?static?LoadMode?FormMode?=?LoadMode.Prompt;????????///?<summary>????????///?顯示的消息正文????????///?</summary>????????private?static?string?ShowMessage?=?null;????????///?<summary>????????///?關閉窗口的定時器????????///?</summary>

????????private?Timer?Timer_Close?=?new?Timer();

? ?[DllImportAttribute("user32.dll")]

????????private?static?extern?bool?AnimateWindow(IntPtr?hwnd,?int?dwTime,?int?dwFlags);???//?該函數可以實現窗體的動畫效果????????public?const?Int32?AW_HOR_POSITIVE?=?0x00000001;???//?自左向右顯示窗口。該標志可以在滾動動畫和滑動動畫中使用。當使用AW_CENTER標志時,該標志將被忽略?????????public?const?Int32?AW_HOR_NEGATIVE?=?0x00000002;???//?自右向左顯示窗口。當使用了?AW_CENTER?標志時該標志被忽略????????public?const?Int32?AW_VER_POSITIVE?=?0x00000004;???//?自頂向下顯示窗口。該標志可以在滾動動畫和滑動動畫中使用。當使用AW_CENTER標志時,該標志將被忽略????????public?const?Int32?AW_VER_NEGATIVE?=?0x00000008;???//?自下向上顯示窗口。該標志可以在滾動動畫和滑動動畫中使用。當使用AW_CENTER標志時,該標志將被忽略????????public?const?Int32?AW_CENTER?=?0x00000010;?????????//?若使用了AW_HIDE標志,則使窗口向內重疊;若未使用AW_HIDE標志,則使窗口向外擴展????????public?const?Int32?AW_HIDE?=?0x00010000;???????????//?隱藏窗口,缺省則顯示窗口????????public?const?Int32?AW_ACTIVATE?=?0x00020000;???????//?激活窗口。在使用了AW_HIDE標志后不要使用這個標志????????public?const?Int32?AW_SLIDE?=?0x00040000;??????????//?使用滑動類型。缺省則為滾動動畫類型。當使用AW_CENTER標志時,這個標志就被忽略????????public?const?Int32?AW_BLEND?=?0x00080000;??????????//?使用淡入效果。只有當hWnd為頂層窗口的時候才可以使用此標志????????#endregion*************************************************????????#region?***********************方?法***********************????????///?<summary>????????///?構造方法????????///?</summary>????????///?<param?name="loadMode">加載模式</param>????????///?<param?name="message">消息正文</param>????????public?static?void?Show(LoadMode?loadMode,?string?message)????????{????????????FormMode?=?loadMode;????????????ShowMessage?=?message;????????????FormMessageBox?box?=?new?FormMessageBox();????????????box.Show();????????}

?#endregion*************************************************

????????#region?***********************事?件***********************????????///?<summary>????????///?窗體加載事件????????///?</summary>????????///?<param?name="sender"></param>????????///?<param?name="e"></param>????????private?void?FormMessageBox_Load(object?sender,?EventArgs?e)????????{????????????this.lblTitle.Text?=?"提示";????????????if?(FormMode?==?LoadMode.Error)????????????{????????????????this.lblTitle.Text?=?"錯誤";????????????????this.plShow.BackgroundImage?=?global::dataSource.Properties.Resources.error;????//?更換背景????????????}????????????else?if?(FormMode?==?LoadMode.Warning)????????????{????????????????this.lblTitle.Text?=?"警告";????????????????this.plShow.BackgroundImage?=?global::dataSource.Properties.Resources.warning;??//?更換背景????????????}????????????else????????????{????????????????this.plShow.BackgroundImage?=?global::dataSource.Properties.Resources.Prompt;???//?更換背景????????????}????????????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);//開始窗體動畫????????????this.ShowInTaskbar?=?false;????????????Timer_Close.Interval?=?4000;????????????Timer_Close.Tick?+=?new?EventHandler(Timer_Close_Tick);????????????Timer_Close.Start();????????}????????///?<summary>????????///?關閉窗口的定時器響應事件????????///?</summary>????????///?<param?name="sender"></param>????????///?<param?name="e"></param>????????private?void?Timer_Close_Tick(object?sender,?EventArgs?e)????????{????????????Timer_Close.Stop();????????????this.Close();????????}????????///?<summary>????????///?窗口已經關閉????????///?</summary>????????///?<param?name="sender"></param>????????///?<param?name="e"></param>

?{

????????????AnimateWindow(this.Handle,?500,?AW_SLIDE?+?AW_VER_POSITIVE?+?AW_HIDE);????????????Timer_Close.Stop();????????????Timer_Close.Dispose();????????}????????///?<summary>????????///?鼠標移動在消息框上????????///?</summary>????????///?<param?name="sender"></param>????????///?<param?name="e"></param>????????private?void?plShow_MouseMove(object?sender,?MouseEventArgs?e)????????{????????????this.Timer_Close.Stop();????????}????????///?<summary>????????///?鼠標移動離開消息框上????????///?</summary>????????///?<param?name="sender"></param>????????///?<param?name="e"></param>????????private?void?plShow_MouseLeave(object?sender,?EventArgs?e)????????{????????????this.Timer_Close.Start();????????}????????#endregion*************************************************

?? c#代碼加載模式。




??

轉載于:https://blog.51cto.com/7330234/1560276

總結

以上是生活随笔為你收集整理的c#应用程序如何添加弹出式广告功能的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。