タスクトレイにバルーンを表示する

タスクトレイにバルーンを表示する

NotifyIconコントロールを利用して
タスクトレイにバルーンを表示することができます。

・バルーンのアイコン
・バルーンのタイトル
・バルーンのメッセージ
を設定した後、ShowBalloonTip関数でバルーンを表示します。

Formに配置されたButtonをクリックするとバルーンを表示します。

balloon

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // リソースのアイコンを設定する場合
            notifyIcon1.Icon = Properties.Resources.Icon1;

            // .icoファイルを指定する場合
            //Icon icon = new Icon(@"c:\test.ico");
            //notifyIcon1.Icon = icon

            // タスクトレイアイコンにマウスホバーした際に表示されるテキスト
            notifyIcon1.Text = "テストアプリです";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // バルーン内のアイコン
            notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;

            // バルーンのタイトル
            notifyIcon1.BalloonTipTitle = "タイトル名";

            // バルーンのメッセージ
            notifyIcon1.BalloonTipText = "テスト";

            // バルーンを表示(引数は表示間隔ミリ秒指定:ここでは5秒)
            notifyIcon1.ShowBalloonTip(5000);
        }
    }
}

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)