How to simulate QQ pallets through. net every day

Source: Internet
Author: User

Some applicationsProgramIt runs for a long time, but does not want it to occupy the taskbar. You also want to call up the results frequently. At this time, you can use a torch program.

. Net Implementation of the pallet program is not complex, the basic principle is like this:

1. Drag a policyicon control to the application form. In fact, the pallets are called notification areas in Microsoft's standard format, so the control name is policyicon.

2. assign an icon class instance to the icon attribute of policyicon, that is, set the icon.

3. assign a contextmenu class instance to the contextmenu attribute of yyicon. when instantiating the contextmenu, You can input a parameter of the menuitem [] type in the contextmenu function, each menuitem has a text attribute and a click event. You can right-click the tray icon.

4. subscribe to the click event of yyicon and set the visible of form to true in the event response function.

5. subscribe to the form closing event. In the event response function, set the formclosingeventargs. Cancel attribute to true and set the visible of form to false. When the vertex is closed, the form is hidden.

ImplementationCodeAs follows:

Private   Bool Isexit;

Public Frmmain ()
{
Initializecomponent ();

If (File. exists ( " Monitor. ICO " ))
{
Yyicon. icon =   New Icon ( " Monitor. ICO " );

Menuitem [] traymenu =   New Menuitem [ 3 ];

Menuitem startitem =   New Menuitem ();
Startitem. Text =   " Start " ;
Startitem. Click + =   New Eventhandler (startitem_click );

Menuitem stopitem =   New Menuitem ();
Stopitem. Text =   " Stop " ;
Stopitem. Click + =   New Eventhandler (stopitem_click );

Menuitem exititem =   New Menuitem ();
Exititem. Text =   " Exit " ;
Exititem. Click + =   New Eventhandler (exititem_click );

Traymenu [ 0 ] = Startitem;
Traymenu [ 1 ] = Stopitem;
Traymenu [ 2 ] = Exititem;

Notifyicon. contextmenu =   New Contextmenu (traymenu );

Policyicon. Click + =   New Eventhandler (policyicon_click );
}

Isexit =   False ;
}

Void Notifyicon_click ( Object Sender, eventargs E)
{
This. Visible= True;
}

Void Startitem_click ( Object Sender, eventargs E)
{
}

Void Stopitem_click ( Object Sender, eventargs E)
{
}

Void Exititem_click ( Object Sender, eventargs E)
{
Isexit= True;
Close ();
}

Private   Void Frmmain_formclosing ( Object Sender, formclosingeventargs E)
{
If ( ! Isexit)
{
E. Cancel= True;
This. Visible= False;
}
}
}
}

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.