日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > C# >内容正文

C#

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

發(fā)布時(shí)間:2024/1/1 C# 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c#应用程序如何添加弹出式广告功能 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

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

?? 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>????????///?錯(cuò)誤????????///?</summary>????????Error,????????///?<summary>????????///?提示????????///?</summary>????????Prompt????}????///?<summary>

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

///?<summary>

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

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

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

????????private?static?extern?bool?AnimateWindow(IntPtr?hwnd,?int?dwTime,?int?dwFlags);???//?該函數(shù)可以實(shí)現(xiàn)窗體的動(dòng)畫(huà)效果????????public?const?Int32?AW_HOR_POSITIVE?=?0x00000001;???//?自左向右顯示窗口。該標(biāo)志可以在滾動(dòng)動(dòng)畫(huà)和滑動(dòng)動(dòng)畫(huà)中使用。當(dāng)使用AW_CENTER標(biāo)志時(shí),該標(biāo)志將被忽略?????????public?const?Int32?AW_HOR_NEGATIVE?=?0x00000002;???//?自右向左顯示窗口。當(dāng)使用了?AW_CENTER?標(biāo)志時(shí)該標(biāo)志被忽略????????public?const?Int32?AW_VER_POSITIVE?=?0x00000004;???//?自頂向下顯示窗口。該標(biāo)志可以在滾動(dòng)動(dòng)畫(huà)和滑動(dòng)動(dòng)畫(huà)中使用。當(dāng)使用AW_CENTER標(biāo)志時(shí),該標(biāo)志將被忽略????????public?const?Int32?AW_VER_NEGATIVE?=?0x00000008;???//?自下向上顯示窗口。該標(biāo)志可以在滾動(dòng)動(dòng)畫(huà)和滑動(dòng)動(dòng)畫(huà)中使用。當(dāng)使用AW_CENTER標(biāo)志時(shí),該標(biāo)志將被忽略????????public?const?Int32?AW_CENTER?=?0x00000010;?????????//?若使用了AW_HIDE標(biāo)志,則使窗口向內(nèi)重疊;若未使用AW_HIDE標(biāo)志,則使窗口向外擴(kuò)展????????public?const?Int32?AW_HIDE?=?0x00010000;???????????//?隱藏窗口,缺省則顯示窗口????????public?const?Int32?AW_ACTIVATE?=?0x00020000;???????//?激活窗口。在使用了AW_HIDE標(biāo)志后不要使用這個(gè)標(biāo)志????????public?const?Int32?AW_SLIDE?=?0x00040000;??????????//?使用滑動(dòng)類(lèi)型。缺省則為滾動(dòng)動(dòng)畫(huà)類(lèi)型。當(dāng)使用AW_CENTER標(biāo)志時(shí),這個(gè)標(biāo)志就被忽略????????public?const?Int32?AW_BLEND?=?0x00080000;??????????//?使用淡入效果。只有當(dāng)hWnd為頂層窗口的時(shí)候才可以使用此標(biāo)志????????#endregion*************************************************????????#region?***********************方?法***********************????????///?<summary>????????///?構(gòu)造方法????????///?</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?=?"錯(cuò)誤";????????????????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);//開(kāi)始窗體動(dòng)畫(huà)????????????this.ShowInTaskbar?=?false;????????????Timer_Close.Interval?=?4000;????????????Timer_Close.Tick?+=?new?EventHandler(Timer_Close_Tick);????????????Timer_Close.Start();????????}????????///?<summary>????????///?關(guān)閉窗口的定時(shí)器響應(yīng)事件????????///?</summary>????????///?<param?name="sender"></param>????????///?<param?name="e"></param>????????private?void?Timer_Close_Tick(object?sender,?EventArgs?e)????????{????????????Timer_Close.Stop();????????????this.Close();????????}????????///?<summary>????????///?窗口已經(jīng)關(guān)閉????????///?</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>????????///?鼠標(biāo)移動(dòng)在消息框上????????///?</summary>????????///?<param?name="sender"></param>????????///?<param?name="e"></param>????????private?void?plShow_MouseMove(object?sender,?MouseEventArgs?e)????????{????????????this.Timer_Close.Stop();????????}????????///?<summary>????????///?鼠標(biāo)移動(dòng)離開(kāi)消息框上????????///?</summary>????????///?<param?name="sender"></param>????????///?<param?name="e"></param>????????private?void?plShow_MouseLeave(object?sender,?EventArgs?e)????????{????????????this.Timer_Close.Start();????????}????????#endregion*************************************************

?? c#代碼加載模式。




??

轉(zhuǎn)載于:https://blog.51cto.com/7330234/1560276

總結(jié)

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

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。