1.右下角弹出气泡窗口

  1. 用到NotifyIcon控件的ShowBalloonTip方法,该方法用于在任务栏中持续显示具有指定标题、文本和图标的气球提示指定的时间。其语法格式如下:
  1. Void NotifyIcon.ShowBalloonTip(int timeout,string tipTitle,string tipText,ToolTipIcon tipIcon);

参数说明如下。

timeout:表示气球提示显示的时间长度。
tipTitle:表示要在气球提示上显示的标题。
tipText:表示要在气球提示上显示的文本。
tipIcon:表示气球提示的图标。

用法

添加NotifyIcon控件,将需要显示的地方加入下面代码

  1. this.notifyIcon1.Visible = true;//设置NotifyIcon控件的可见性为真
  2. //显示气泡提示
  3. this.notifyIcon1.ShowBalloonTip(1000,"当前时间:",DateTime.Now.ToLocalTime().ToString(),ToolTipIcon.Info);

2.右下角弹出窗体

动画显示窗体的API函数AnimateWindow

  1. [DllImportAttribute("user32.dll")]
  2. private static int AW_HIDE = 0x00010000;//该变量表示动画隐藏窗体
  3. private static int AW_SLIDE = 0x00040000;//该变量表示出现滑行效果的窗体
  4. private static int AW_VER_NEGATIVE = 0x00000008;//该变量表示从下向上开屏
  5. private static int AW_VER_POSITIVE = 0x00000004;//该变量表示从上向下开屏
  6. private const int AW_ACTIVE = 0x20000;//激活窗口
  7. private const int AW_BLEND = 0x80000;//应用淡入淡出结果

显示右下角窗口

  1. public void ShowForm()
  2. {
  3. int x = Screen.PrimaryScreen.WorkingArea.Right - this.Width;
  4. int y = Screen.PrimaryScreen.WorkingArea.Bottom - this.Height;
  5. this.Location = new Point(x, y);//设置窗体在屏幕右下角显示
  6. AnimateWindow(this.Handle, 1000, AW_SLIDE | AW_ACTIVE | AW_VER_NEGATIVE);
  7. }
  8. //以淡入淡出效果关闭窗口
  9. public void CloseForm()
  10. {
  11. AnimateWindow(this.Handle, 1000, AW_BLEND | AW_HIDE);
  12. }