The development of desktop programs, often consider the status bar to implement the tray shortcut operation, the implementation of the tray program in the API era, or relatively complex, first in MSDN can see its function details,
The complex settings are then made based on the parameters they require.
In the. NET ERA, MS encapsulates these cumbersome details, and developers can easily implement the control and operation of the tray program. Now take a simple example to illustrate:
1. Adding NotifyIcon controls and ContextMenuStrip controls
2. Set its properties icon and CONTEXTMENUSTRP Properties, the Icon property simply selects a tray icon, contextmenustrip the shortcut menu for associating the first step.
3. Add the SizeChanged event program for the form to minimize the form of the Si cho tray:
if (this. WindowState = = formwindowstate.minimized) {this . Hide (); Can or may not, depending on whether the main form is hidden this.notifyIcon.Visible = true; }
4. Add the NotifyIcon Click Event, open the shortcut menu item, or other more complex action options, depending on your needs.
private void Form1_sizechanged (object sender, EventArgs e) {if (this. WindowState = = formwindowstate.minimized) {this. Hide (); this.notifyIcon1.Visible = true; } } private void Notifyicon1_click (object sender, EventArgs e) {this.contextMenuStrip1.Show (mouseposition.x, MOUSEPOSITION.Y); }
The above is the C # Tray program content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!