winform中两个程序间的问题?? winform程序1,程序2:程序2有个主窗体A程序1怎么获得程序1的主窗体A ??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 从进程下手吧。程序2运行了就有个进程。程序2.ext 搞错了。是程序2winform程序1,程序2:程序2有个主窗体A 程序1怎么获得程序2的主窗体A ??? 两个窗体通信还是两个exe通信,如果两个exe,那么就要从进程通信入手了。三思我的博客 程序员日记 http://www.ideaext.com 欢迎交流 在程序1通过反射程序2的DLL文件,创建窗体A。 private void CreateForm(string strName){this.Cursor = Cursors.WaitCursor;string path=AssemblyName;string name=strName; Form fm=(Form)Assembly.Load(path).CreateInstance(name);fm.MdiParent=this.ParentForm;fm.Show();fm.Dock=DockStyle.Fill;this.Cursor = Cursors.Default;} [DllImport("User32.dll", EntryPoint = "FindWindow")]private static extern int FindWindow(string lpClassName, string lpWindowName);private void button1_Click(object sender, EventArgs e){ int WINDOW_HANDLER = FindWindow(null, @"主窗体A"); if (WINDOW_HANDLER == 0) { //不存在 ...... } else { //存在 ...... }} int SC_MAXIMIZE = 0xf030; int WM_SYSCOMMAND = 0x0112; [DllImport("User32.dll", EntryPoint = "FindWindow")] private static extern int FindWindow(string lpClassName, string lpWindowName); [DllImport("User32.dll", EntryPoint = "SendMessage")] private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); private void button1_Click(object sender, EventArgs e) { int WINDOW_HANDLER = FindWindow(null, @"应用程序1"); if (WINDOW_HANDLER == 0) { } else { SendMessage((System.IntPtr)WINDOW_HANDLER, WM_SYSCOMMAND, SC_MAXIMIZE, 0); } } int WINDOW_HANDLER = FindWindow(null, @"这是什么?是程序2的名字?"); 在程序1里写 this.SendToBack(); 帮满看看,下面的程序那有问题. webBrowser打开Excel 屏蔽信息框出错 return calss vs2005怎么操作excel? 请教如果是很不规则的窗体边框该怎么用GraphicsPath类画出! MySQLDriverCS 访问mysql text型 字段? 程序部署到其他电脑运行出错了 winform C# 对话框 关于ping该为snmp WPF任意位置显示任意图片 xtrareports 报表怎么保存为doc 有没有人做过word或者pdf的续打
{
this.Cursor = Cursors.WaitCursor;string path=AssemblyName;
string name=strName; Form fm=(Form)Assembly.Load(path).CreateInstance(name);
fm.MdiParent=this.ParentForm;
fm.Show();
fm.Dock=DockStyle.Fill;
this.Cursor = Cursors.Default;
}
[DllImport("User32.dll", EntryPoint = "FindWindow")]
private static extern int FindWindow(string lpClassName, string lpWindowName);private void button1_Click(object sender, EventArgs e)
{
int WINDOW_HANDLER = FindWindow(null, @"主窗体A");
if (WINDOW_HANDLER == 0)
{
//不存在
......
}
else
{
//存在
......
}
}
int SC_MAXIMIZE = 0xf030;
int WM_SYSCOMMAND = 0x0112; [DllImport("User32.dll", EntryPoint = "FindWindow")]
private static extern int FindWindow(string lpClassName, string lpWindowName); [DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); private void button1_Click(object sender, EventArgs e)
{
int WINDOW_HANDLER = FindWindow(null, @"应用程序1");
if (WINDOW_HANDLER == 0)
{ }
else
{
SendMessage((System.IntPtr)WINDOW_HANDLER, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
}
}