本人想实现如下效果:我有个应用程序,启动应用程序后进入主界面,如果我把主界面最小化,然后再去启动该应用程序(该应用程序只能启动一次)。如何控制让我最小化的主界面再最大化显示出来?(c#语言实现),有经验的同行请赐教!详细点的,小弟不胜感激!

解决方案 »

  1.   

     private void Form1_Load(object sender, EventArgs e)
            {
                this.WindowState = FormWindowState.Minimized;
            }       
      

  2.   

    最大化是  this.WindowState = FormWindowState.Normal;
      

  3.   

    首先佩服一下 yinhunfeixue 同志的回答,精辟啊! 但是您看明白楼主的意思没有?
      

  4.   

    http://www.codeproject.com/csharp/cssingprocess.asp
      

  5.   

    现在是可以了,但是有些感觉不好:
    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;
    using System.IO;
    using System.Threading;namespace WindowsApplication8
    {
    static class Program
    {
    /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main()
    {
    if (File.Exists(Application.StartupPath + "/mutex.tmp"))
    {
    File.Delete(Application.StartupPath + "/mutex.tmp");
    Thread.Sleep(1000);
    if (File.Exists(Application.StartupPath + "/mutex.tmp"))
    return; } Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
    }
    }
    }using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.IO;
    using System.Windows.Forms;namespace WindowsApplication8
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    } private void Form1_Load(object sender, EventArgs e)
    {
    this.timer1.Start();
    } private void timer1_Tick(object sender, EventArgs e)
    {
    if (!File.Exists(Application.StartupPath + "/mutex.tmp"))
    {
    FileStream fs= File.Create(Application.StartupPath + "/mutex.tmp");
    fs.Close(); this.WindowState = FormWindowState.Normal;
    } }
    }
    }
    虽然办法有些苯,但总归实现了.其它很多方法只能是先但进行运行,窗口没法自动出来,现在这个办法是我能想到的最简的地了.
      

  6.   

    我又重新看了一次.
    首先,加一个控件--notifyicon  最小化后会在任务栏显示这个图标.
    然后在notifyicon的单击事件中,加入下面的代码
    this.WindowState = FormWindowState.Normal
    当然,也可以用右键菜单实现.
      

  7.   

    lovefootball 给的代码也很好,刚才测试了.他这个使用Mutex实现的。比我那个好:)
      

  8.   

    yinhunfeixue 哥们 需求还是搞错了~~~~~~~~~~