hiding the C # application to the system tray is quiet straight forward. With a few line of codes in C # and you can accomplish this. First you'll need to create the context menu for the system tray, and then after this need to create the Notify Icon. The next step is just enable the system icon. Here is the sample code below.
1 using System;
2 using System.Collections.Generic;
3 using System. ComponentModel;
4 using system.data;
5 using system.drawing;
6 using system.linq;
7 using system.text;
8 using System. Windows. Forms;
9
Ten namespace adsensedisabler
each {
public partial class Form1 : Form
{
+ private NotifyIcon Systrayicon;
- private ContextMenu systraymenu;
-
[STAThread]
static void Main ()
{
Application. EnableVisualStyles ();
Application. Setcompatibletextrenderingdefault (false);
Application. Run (new Form1());
(+}
-
public Form1 ()
+ {
InitializeComponent ();
-
//Create a context menu for th systray.
-
systraymenu = new ContextMenu();
sysTrayMenu.MenuItems.Add ("Enable Adsense", onenabled);
sysTrayMenu.MenuItems.Add ("Disable adsensedisabler", ondisabled);
sysTrayMenu.MenuItems.Add ("Show Panel", onshowed);
sysTrayMenu.MenuItems.Add ("Exit", OnExit);
$
PNS //Create and intialise the Tray notify icon.
example uses the standard icon but can is replaced
/ /with your own custom icon.
Systrayicon = new NotifyIcon();
systrayicon.text = "Adsense disabler";
Systrayicon.icon = new Icon(systemicons. Shield, 40, 40);
+
//Add menu to tray icon and show it.
systrayicon.contextmenu = Systraymenu;
systrayicon.visible = true;
*}
-
protected override void OnLoad (EventArgs e)
{
The Visible = true; //Hide Form window.
ShowInTaskbar = false; //Remove from taskbar.
-
base. OnLoad (e);
+}
About
OnExit private void (object sender, EventArgs e)
(
Application. Exit ();
*
A
onenabled private void (object sender, EventArgs e)
$ {
-
+}
the
ondisabled private void (object sender, EventArgs e)
(
the
+}
in
onshowed private void (object sender, EventArgs e)
A. {
About
--}
the
+ +}
+}