VB.NET中的NotifyIcon怎么用
'點(diǎn)擊狀態(tài)欄的圖標(biāo)時(shí)顯示窗體
Private Sub notifyIcon1_MouClick(ByVal nder As Object, ByVal e As MouEventArgs)
If Me.WindowState = FormWindowState.Minimized Then
Me.WindowState = FormWindowState.Normal '還原
End If
Me.Activate()
Me.notifyIcon1.Visible = Fal
Me.ShowInTaskbar = True
End Sub
'程序關(guān)閉時(shí)清除狀態(tài)欄圖標(biāo)
Private Sub 退出ToolStripMenuItem_Click(ByVal nder As Object, ByVal e As System.EventArgs)'關(guān)閉應(yīng)用程序
Me.notifyIcon1.Visible=Fal
Me.Clo()
Application.Exit()
End Sub
C# notifyIcon里的單擊事件怎么判斷是鼠標(biāo)左鍵還是右鍵點(diǎn)的
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.CenterToScreen();
}
private void Form1_MouClick(object nder, MouEventArgs e)
{
if (e.Button == MouButtons.Left && e.Clicks == 1)
{
this.label1.Text = "您單擊了鼠標(biāo)左鍵!";
}
el if (e.Button == MouButtons.Right && e.Clicks == 1)
{
this.label1.Text = "您單擊了鼠標(biāo)右鍵!";
}
}
private void Form1_MouDoubleClick(object nder, MouEventArgs e)
{
if (e.Button == MouButtons.Left && e.Clicks == 2)
{
this.label1.Text = "您雙擊了鼠標(biāo)左鍵!";
}
el if (e.Button == MouButtons.Right && e.Clicks == 2)
{
this.label1.Text = "您雙擊了鼠標(biāo)右鍵!";
}
}
}
這樣可以判斷是鼠標(biāo)左鍵還是右鍵了
c#使用notifyIcon控件時(shí)會(huì)在托盤(pán)中出現(xiàn)多個(gè)圖標(biāo)?
Form1 f1 = new Form1();
//你這里多了一個(gè)Form1了,所以會(huì)多一個(gè)notifyIcon
f1.notifyIcon1.Text = "測(cè)試測(cè)試測(cè)試";
這樣改就可以了:
public static void ceshi(Form f1)
{
((Form1)f1).notifyIcon1.Text = "測(cè)試測(cè)試測(cè)試";
}
然后調(diào)用的時(shí)候使用:
private void Form1_Load(object nder, EventArgs e)
{
Class1.ceshi(this);
}
vb.net 利用NotifyIcon實(shí)現(xiàn)最小化到系統(tǒng)托盤(pán),但是收縮到軌跡到開(kāi)始菜單
添加托盤(pán)圖標(biāo)控件,并設(shè)置好其Icon屬性,然后添加如下代碼:
Private Sub Form1_FormClosing(nder As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = True
Me.Hide()
End Sub
這樣實(shí)現(xiàn)了點(diǎn)關(guān)閉,進(jìn)入托盤(pán),如果點(diǎn)最小化進(jìn)入托盤(pán):
'窗體最小化時(shí)候隱藏窗體,
Private Sub MainForm_SizeChanged(ByVal nder As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
If Me.WindowState = FormWindowState.Minimized Then
Me.Hide()
Me.ShowInTaskbar = Fal
End If
End Sub
誰(shuí)知道vb.NET中notifyicon氣球用法
'氣球顯示5秒,可設(shè)置標(biāo)題、內(nèi)容、圖標(biāo)
NotifyIcon1.ShowBalloonTip(5000, "標(biāo)題", "顯示內(nèi)容", ToolTipIcon.Info)