比如我打开了一个winform,最小化到托盘了.然后我又打开了一个刚才那个winform,怎么让原来最小化到托盘的那个程序显示出来上代码哦!!

解决方案 »

  1.   

    frmReprint 这个要设成全局变量            if (frmReprint != null && !frmReprint.IsDisposed)
                {
                    frmReprint.Show();
                    frmReprint.BringToFront();
                }
                else
                {
                    frmReprint = new FrmReprint();
                    frmReprint.ShowInTaskbar = false;
                    frmReprint.Show();
                }
      

  2.   


    frmReprint 是个什么东西啊?
      

  3.   


    当然是你要show出来的窗体了,。
      

  4.   


    我开始创建的是服务,后来就改成了 winform了,怎么变成你那样的啊?
      

  5.   

    使用 System.Threading.Mutex 实现进程互斥
      

  6.   


    using System;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.Reflection;
    using System.Threading;namespace TEST
    {
        static class Program
        {
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new FrmMain());
                Process instance = RunningInstance();
                if (instance == null)
                {
                    Application.Run(new FrmMain());
                }
                else
                {
                    HandleRunningInstance(instance);
                } 
            }
            #region 进程名
            public static Process RunningInstance()
            {
                Process current = Process.GetCurrentProcess();
                Process[] processes = Process.GetProcessesByName(current.ProcessName);
                foreach (Process process in processes)
                {
                    if (process.Id != current.Id)
                    {
                        if (Assembly.GetExecutingAssembly().Location.Replace("/ ", "\\ ") == current.MainModule.FileName)
                        {
                            return process;
                        }
                    }
                }
                return null;
            }
            public static void HandleRunningInstance(Process instance)
            {
                ShowWindowAsync(instance.MainWindowHandle, WS_SHOWNORMAL);
                SetForegroundWindow(instance.MainWindowHandle);
            }
            [DllImport("User32.dll ")]
            private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
            [DllImport("User32.dll ")]
            private static extern bool
                SetForegroundWindow(IntPtr hWnd);
            private const int WS_SHOWNORMAL = 1;
            #endregion
        }
    }
      

  7.   


    我也创建了一个Windows 服务,没有你这样的 属性 对话框。
    可否说一下你具体的创建过程?
      

  8.   

    http://blog.163.com/xiaozhi797@126/blog/static/62440288200951810291301/
      

  9.   

    15楼的界面,好像只能是VB.net的项目才有
      

  10.   


       private void button1_Click(object sender, EventArgs e)
            {
                Form2 frm = Form2.CreateInstance();
                if (frm.WindowState == FormWindowState.Minimized)
                {
                    frm.WindowState = FormWindowState.Normal;
                }
                else
                {
                    frm.Show();
                }
            } public partial class Form2 : Form
        {
            private static readonly object m_SyncObject = new object();        private static Form2 frm;        private Form2()
            {
                InitializeComponent();
            }        public static Form2 CreateInstance()
            {
                if (frm == null)
                {
                    lock (m_SyncObject)
                    {
                        if (frm == null)
                        {
                            frm = new Form2();
                        }
                    }
                }
                return frm;
            }    }