1.右下角彈出氣泡窗口
用到NotifyIcon控件的ShowBalloonTip方法,該方法用于在任務欄中持續(xù)顯示具有指定標題、文本和圖標的氣球提示指定的時間。其語法格式如下:
Void NotifyIcon.ShowBalloonTip(int timeout,string tipTitle,string tipText,ToolTipIcon tipIcon);
參數(shù)說明如下。
timeout:表示氣球提示顯示的時間長度。
tipTitle:表示要在氣球提示上顯示的標題。
tipText:表示要在氣球提示上顯示的文本。
tipIcon:表示氣球提示的圖標。
用法
添加NotifyIcon控件,將需要顯示的地方加入下面代碼
this.notifyIcon1.Visible = true; //設置NotifyIcon控件的可見性為真
//顯示氣泡提示
this.notifyIcon1.ShowBalloonTip(1000,"當前時間:",DateTime.Now.ToLocalTime().ToString(),ToolTipIcon.Info);
2.右下角彈出窗體
動畫顯示窗體的API函數(shù)AnimateWindow
[DllImportAttribute("user32.dll")]
private static int AW_SLIDE = 0x00040000; //該變量表示出現(xiàn)滑行效果的窗體
private static int AW_VER_NEGATIVE = 0x00000008; //該變量表示從下向上開屏
private static int AW_VER_POSITIVE = 0x00000004; //該變量表示從上向下開屏
private const int AW_ACTIVE = 0x20000;//激活窗口
private const int AW_BLEND = 0x80000;//應用淡入淡出結果
public void ShowForm()
{
int x = Screen.PrimaryScreen.WorkingArea.Right - this.Width;
int y = Screen.PrimaryScreen.WorkingArea.Bottom - this.Height;
this.Location = new Point(x, y);//設置窗體在屏幕右下角顯示
AnimateWindow(this.Handle, 1000, AW_SLIDE | AW_ACTIVE | AW_VER_NEGATIVE);
}
//以淡入淡出效果關閉窗口
public void CloseForm()
{
AnimateWindow(this.Handle, 1000, AW_BLEND | AW_HIDE);
}