开发者

working with system tray

i create a setup file for my window based project. it is working fine. my requirement is when i minimize the window it should come in syst开发者_Go百科em tray not in task bar. help me thank u


  1. To get started, open an existing C# Windows form (or create a new one).
  2. Open the Visual Studio Toolbox.
  3. Drag a NotifyIcon control onto the form. The control will named notifyIcon1 by default and placed below the form because it has no visual representation on the form itself.
  4. Set the NotifyIcon control's Text property to the name you want to appear when the user pauses the mouse over the application's icon. For example, this value could be "KillerApp 1.0".
  5. Set the control's Icon property to the icon that you want to appear in the System Tray.

      Tip: If you have a BMP file that you want to convert to an icon file, I highly recommend the QTam Bitmap to Icon 3.5 application.
    
  6. Add an event handler for the form's Resize event that will hide the application when it's minimized. That way, it won't appear on the task bar.

    private void Form1_Resize(object sender, System.EventArgs e) { if (FormWindowState.Minimized == WindowState) Hide(); }

  7. Add an event handler for the NotifyIcon.DoubleClick event and code it as follows so that the application will be restored when the icon is double-clicked.

    private void notifyIcon1_DoubleClick(object sender, System.EventArgs e) { Show(); WindowState = FormWindowState.Normal; }


This depends on which language you have written your program in. You would need to create a class or use a built in function to minimize it to the system tray. More information would be helpful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜