问题一:就像QQ那样点最小化就缩小到右下角的系统栏里了。

解决方案 »

  1.   

    打开 VS.net的工具箱,然后选择NotifyIcon,拖到 Form上,在属性中Icon中设置图象
    添加一个ContextMenu,输入 需要的选择项
    在NotifyIcon中的ContextMenu属性中 可以设置刚添加的ContextMenu 
    点托盘上的图标 就可以显示选择项
      

  2.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Net;
    using System.IO;namespace SendSMS
    {
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.NotifyIcon notifyIcon1;
    private System.Windows.Forms.ContextMenu contextMenu1;
    private System.Windows.Forms.MenuItem menuItem1;
    private System.Windows.Forms.MenuItem menuItem2;
    private System.Windows.Forms.MenuItem menuItem3;
    private System.Windows.Forms.Timer timer1;
    private System.ComponentModel.IContainer components;
    startSend sSend = new startSend(); public Form1()
    {
    InitializeComponent();
    } #region
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    }
    #endregion #region Windows Form 設計工具產生的程式碼
    /// <summary>
    /// 此為設計工具支援所必須的方法 - 請勿使用程式碼編輯器修改
    /// 這個方法的內容。
    /// </summary>
    private void InitializeComponent()
    {
    this.components = new System.ComponentModel.Container();
    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
    this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
    this.contextMenu1 = new System.Windows.Forms.ContextMenu();
    this.menuItem1 = new System.Windows.Forms.MenuItem();
    this.menuItem2 = new System.Windows.Forms.MenuItem();
    this.menuItem3 = new System.Windows.Forms.MenuItem();
    this.timer1 = new System.Windows.Forms.Timer(this.components);
    // 
    // notifyIcon1
    // 
    this.notifyIcon1.ContextMenu = this.contextMenu1;
    this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
    this.notifyIcon1.Text = "簡訊勤務兵";
    this.notifyIcon1.Visible = true;
    this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
    // 
    // contextMenu1
    // 
    this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
     this.menuItem1,
     this.menuItem2,
     this.menuItem3});
    // 
    // menuItem1
    // 
    this.menuItem1.Index = 0;
    this.menuItem1.Text = "打開簡訊勤務兵(&O)";
    this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
    // 
    // menuItem2
    // 
    this.menuItem2.Index = 1;
    this.menuItem2.Text = "-";
    // 
    // menuItem3
    // 
    this.menuItem3.Index = 2;
    this.menuItem3.Text = "退出  (&X)";
    this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
    // 
    // timer1
    // 
    this.timer1.Interval = 60000;
    this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
    this.ClientSize = new System.Drawing.Size(292, 273);
    this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
    this.MaximizeBox = false;
    this.Name = "Form1";
    this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
    this.Text = "簡訊勤務兵";
    this.Load += new System.EventHandler(this.Form1_Load); }
    #endregion #region 程序主入口
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    }
    #endregion #region 重寫WndProc屏蔽掉關閉按鈕
    protected override void WndProc(ref Message m)
    {
    const int WM_SYSCOMMAND = 0x0112;
    const int SC_CLOSE = 0xF060;
    if (m.Msg == WM_SYSCOMMAND && (int) m.WParam == SC_CLOSE)
    {
    // User clicked close button
    //this.WindowState = FormWindowState.Minimized;
    this.Visible = false;
    return;
    }
    base.WndProc (ref m);
    }
    #endregion #region 退出簡訊勤務兵
    private void menuItem3_Click(object sender, System.EventArgs e)
    {
    DialogResult result;
    result = MessageBox.Show(this,"你確定要退出簡訊勤務兵麼?","簡訊勤務兵...",MessageBoxButtons.OKCancel,MessageBoxIcon.Asterisk); //"簡訊勤務兵..."
    if(result == DialogResult.OK)
    {
    this.Dispose();
    this.Close();
    }
    }
    #endregion #region 顯示簡訊勤務兵
    private void menuItem1_Click(object sender, System.EventArgs e)
    {
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
    this.ClientSize = new System.Drawing.Size(292, 273);
    this.Visible = true;
    //this.WindowState = FormWindowState.Normal;
    }
    #endregion #region 雙擊托盤圖標
    private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)
    {
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
    this.ClientSize = new System.Drawing.Size(292, 273);
    this.Visible = true;
    }
    #endregion #region Form1_load
    private void Form1_Load(object sender, System.EventArgs e)
    {// this.timer1.Interval = 60000;
    // this.timer1.Start();
    this.Visible = true; sSend.ifHaveSend();
    }
    #endregion #region 定時事件
    public int h = 0;
    private void timer1_Tick(object sender, System.EventArgs e)
    {
    sSend.ifHaveSend();
    }
    #endregion
    }
    }
      

  3.   

    思路:
    使用NotifyIcon
    在窗体的最小化消息(在event里找不到)将窗体.hide()
    添加NotifyIcon的单击事件 这个时候将显示窗体.show()具体代码已经有很多了 搜一下
      

  4.   

    hunter_32的方法似乎有点.....
      

  5.   

    添加notifyIcon,这样在系统托盘显示一个图标(图标可以自己设置),然后可以添加一个ContextMenuStrip,在其中可以添加最大化和最小化菜单,然后在这些菜单的Click事件中添加如下代码:
    //在最大化菜单事件中
    this.WindowState = FormWindowState.Normal;//(FormWindowState.Maximized)//在最小化菜单事件中
    this.WindowState = FormWindowState.Minimized;仅供参考,呵呵~~~
      

  6.   

    http://blog.csdn.net/CnBabyCrazy/archive/2005/11/30/540561.aspx