protected void Button_Click(object sender, EventArgs e) { if (ChildForm == null) { ChildForm = new SiemensForm(Client); ChildForm.StartPosition = FormStartPosition.CenterScreen; ChildForm.Show(); } else { try { if (ChildForm.IsDisposed) { // get type information var type = ChildForm.GetType(); // get all constructors var ctors = type.GetConstructors(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.CreateInstance); //invoke second ctor that passes the handle, or call first one with no arguments and pass HANDLE after <Cast> var obj = ctors[1].Invoke(new object[] { Client }); ChildForm = (SiemensForm)obj; //ChildForm = m_tempff; //ChildForm.HANDLE = HANDLE; ChildForm.StartPosition = FormStartPosition.CenterScreen; ChildForm.Show(); } else { ChildForm.Client = Client; ChildForm.StartPosition = FormStartPosition.CenterScreen; ChildForm.Show(); } } catch { } } //bubble the event up to the parent if (this.ViewClick != null) { this.ViewClick(this, e); } }
public void OpenChildForm() { if (ChildForm != null) { try { if (ChildForm.IsDisposed) { // get type information var type = ChildForm.GetType(); // get all constructors var ctors = type.GetConstructors(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.CreateInstance); //invoke second ctor that passes the handle, or call first one with no arguments and pass HANDLE after <Cast> object obj = null; if (ctors.Length > 1) { obj = ctors[1].Invoke(new object[] { Client }); } else { obj = ctors[0].Invoke((new object[] { })); } ChildForm = (SiemensForm)obj; //ChildForm = m_tempff; //ChildForm.HANDLE = HANDLE; ChildForm.StartPosition = FormStartPosition.CenterScreen; ChildForm.Show(); } else { ChildForm.Client = Client; ChildForm.StartPosition = FormStartPosition.CenterScreen; ChildForm.Show(); } } catch { } } }