c#アプリケーションがポップアップ広告機能を追加する方法
c#言語を使用して、検索入力法やリングス翻訳ソフトのような画面右下のポップアップ広告をどのように実現しますか?
c#codeは以下の通りです.
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#コードロードモード.