有没有有人给我一段代码.窗体最小化不在任务拦上显示.在系统托盘中显示。

解决方案 »

  1.   

    在窗体里加个notifyicon就可以了,然后窗体初始化的时候隐藏this.Hide()
      

  2.   

    _timer=new System.Timers.Timer();
    _timer.Interval=_Interval;
    _timer.Enabled=true;
    _timer.Start();
    _timer.Elapsed+=new ElapsedEventHandler(timer_Elapsed); //設定預設圖示。
    notifyIcon1 =new  System.Windows.Forms.NotifyIcon();
    notifyIcon1.Icon = mSmileIcon;
    notifyIcon1.Text = "在功能表上按一下滑鼠右鍵";
    notifyIcon1.Visible=true;
    mSmileDisplayed = true;

    //將所有 MenuItem 物件插入陣列並且同時將它們加入到內容功能表。
    mMenuItems[0] = new MenuItem("顯示自動生成代碼表單...", new EventHandler(this.ShowAutoCodeForm));
    mMenuItems[0].DefaultItem =true;
    mMenuItems[1] = new MenuItem("顯示表單...", new EventHandler(this.ShowFormSelect));
    mMenuItems[2] =new MenuItem("計算器",new EventHandler(this.ShowCalc));
    mMenuItems[3] =new MenuItem("切換影像",new EventHandler(this.ToggleImageSelect));
    mMenuItems[4] = new MenuItem("-");
    mMenuItems[5] = new MenuItem("結束", new EventHandler(this.ExitSelect));

    System.Windows.Forms.ContextMenu notifyiconMnu=new ContextMenu(mMenuItems);
    notifyIcon1.ContextMenu = notifyiconMnu;