如题,form用来显示图片,在program.cs文件中,已经做了唯一实例的处理,但不知道如何传参然后让form重新显示新的图片:
static class Program
    {
        public static System.Threading.Mutex MutexRun;
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(string[] cmd)
        {  
            bool noRun = false;
            MutexRun = new Mutex(true, "HumControl", out noRun);            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
          
            Form1 frm1 = new Form1();
          
            if (noRun)
            {
                if (cmd.Length > 0)
                {
                    frm1.strFile = cmd[0];
                }
                MutexRun.ReleaseMutex();               
                Application.Run(frm1);             
            }
            else
            {
                
                if (cmd.Length > 0)
                {
                    frm1.strFile = cmd[0];
                }
            //todo 如何写,改变正在运行的frm1的picbox图片变成给定的路径的图片
                MessageBox.Show("已有实例正在运行!");
            }
        } 
    }
以下是form1.cs文件:   public string strFile = @"F:\g.jpg";
        private void Form1_Load(object sender, EventArgs e)
        {           
            this.Location = new Point(0, 0);
            //this.Size = new System.Drawing.Size(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
            mvPicBox.BackColor = Color.Black;
            this.mvPicBox.Image = Image.FromFile(strFile);
        }
求高手指点,谢谢

解决方案 »

  1.   

    设置好frm1.strFile = cmd[0];后
    frm1.OnLoad();//引发FormLoad事件。
      

  2.   

    用 WindowsFormsApplicationBase 类
    如果不清楚可以新建一个VB的WinForm项目参考
      

  3.   

    form里面没有这个方法啊,需要引用命名空间么?
      

  4.   

    關掉已經打開,再重新run起來不行嗎
      

  5.   

    那样的话就会出现闪烁了,我需要的是给正在运行的winform传递参数,然后让它重新Load一次
      

  6.   

    这个类是VB里面的啊,在C#里面有类似的吗?
      

  7.   


    在Form1中定义一个方法:
    public void PerformOnLoad()
    {
            this.OnLoad();
    }
    设置好frm1.strFile = cmd[0];后
    frm1.PerformOnLoad();//引发Form1 OnLoad事件。
      

  8.   

    直接添加Microsoft.VisualBasic.dll的引用就可以,在程序集的使用上VB和C#没有区别