c#应用程序如何添加弹出式广告功能
生活随笔
收集整理的這篇文章主要介紹了
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;
?{
????????????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#应用程序如何添加弹出式广告功能的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Unity加密(Sha256方式加密)
- 下一篇: 字节跳动面试题(编程题)—平衡二叉树(思