[英]How do i add a click event on an icon in the taskbar?
My Form1 is shown in the taskbar on the bottom. 我的Form1显示在底部的任务栏中。 I want that when i click on the icon it will do something.
我希望当我点击图标时它会做一些事情。 Not maximize the form but do something else.
不是最大化形式,而是做其他事情。
I have a form1 click event: 我有一个form1点击事件:
private void Form1_Click_1(object sender, EventArgs e)
{
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(30000);
}
But this will work only when i click on the form when the form is maximized. 但这只有在表单最大化时单击表单时才有效。 I want it to work only when i click on the icon in the taskbar.
我希望它只在我点击任务栏中的图标时才能工作。 Not tray icon on the right bottom corner but on the taskbar on the bottom.
右下角不是托盘图标,而是底部的任务栏上。
EDIT** 编辑**
I didn't find any click event for the icon of the form when it's in the taskbar what i did so far is using the form1 resi8ze event and did: 我在任务栏中找不到表单图标的任何点击事件我到目前为止所做的是使用form1 resi8ze事件并且做了:
private void Form1_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Normal)
{
this.WindowState = FormWindowState.Minimized;
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(30000);
}
}
I also did in the Form1 Load event: 我也在Form1 Load事件中做过:
this.WindowState = FormWindowState.Minimized;
So the result now is that when i'm running the program the form icon is in the taskbar all the time the form never maximize resize or open . 因此现在的结果是,当我运行程序时,表单图标始终位于任务栏中,表单永远不会最大化调整大小或打开。 when i click on the icon in the taskbar the balloon tip is working good.
当我点击任务栏中的图标时,气球提示工作正常。
The problems now is: 现在的问题是:
I think you need to get familiar with WindowsAPICodePack and Taskbar API . 我认为您需要熟悉WindowsAPICodePack和Taskbar API 。 I have never done exactly what you need, but those are pretty powerful APIs and might come handy.
我从来没有完成你所需要的,但这些是非常强大的API,可能会派上用场。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.