just write a program, encounter a small problem, is when click on the Minimize button, how to minimize the program to the system tray. In fact, such examples in a lot of software can be seen, but just started looking for properties and there is no system tray-related, an event was found, and there was no event on the minimized button click. Depressed, so the internet search a bit, only then found that there is a control called NotifyIcon (Khan one, and then BS himself, how did not find before). the smallest event can also be implemented in a different way (with SizeChanged event). The following is the implementation when the minimized button is clicked, the program is indented to the system tray and the system tray icon is double-clicked to restore the program. 1, build a WinForm project, other operations skipped. 2, pull a NotifyIcon control, set the property visable to False, in the Text property on a random fill in some files. 3, the implementation of the form of the SizeChanged event, the code is as follows:
if (this. WindowState = = formwindowstate.minimized)//To determine whether or not to minimize
{
This. ShowInTaskbar = false; Do not appear in the system tray
notifyicon.visible = true; Tray icon Visible
}
4, the implementation of the NotifyIcon control DoubleClick event, the code is as follows:
if (this. WindowState = = formwindowstate.minimized)
{
This. ShowInTaskbar = true; Display in system taskbar
This . WindowState = Formwindowstate.normal; Restore Form
notifyicon.visible = false; Tray icon Hide
}
ok! That's it, run and try it. It's very simple, but the implementation method may be different from other languages, write out hope that friends who need not go too many detours.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.