English 中文(简体)
关闭申请后如何在通知区域运行应用程序
原标题:How to run application in notification area after closing the application
  • 时间:2012-05-26 11:09:57
  •  标签:
  • c#
  • .net

我创建了一个演示应用程序, 并且想运行总是像 抗病毒,微麦氏数据卡软件, 或任何其他通知软件。

My Main objective is: When I close an application then my application may close, but it should run and display in notification area icon like gtalk, skypee, etc. and when it will click then the application window will open and display it in task bar.

请用代码和实例描述它。

问题回答

I hope that you aware of notify icon and context menu strip in WinForms. Add ContextMenustrip choose Edit items and add show and Exit menu item tool strips. Add corresponding click events.

using System;
using System.Windows.Forms;

namespace test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            //Form Closing Event
            e.Cancel = true;
            Hide();
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            //Exit in notify icon Context menu tool strip
           Environment.Exit(-1);
        }

        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            //Show in notify icon context menu tool strip
            Show();
        }
    }
}




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签