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 { } } }
public DiagnosticModule(DmData data) { m_dmdata = data; Client = m_dmdata.Client; ChildForm = data.Form; m_tempff = data.Form; Text = data.Name; //m_button.Text = data.Name; m_icon = data.Icon; m_imgbox.Image = data.Icon; this.Size = new System.Drawing.Size(280, 150); this.BorderStyle = BorderStyle.FixedSingle; this.Name = data.Name; m_tooltip.IsBalloon = true; m_tooltip.UseFading = true; m_tooltip.SetToolTip(this, data.Description); m_tooltip.SetToolTip(m_button, data.Description); m_tooltip.SetToolTip(m_imgbox, data.Description); m_imgbox.Size = new Size(274, 118); m_imgbox.Location = new Point(3, 3); m_imgbox.BorderStyle = BorderStyle.Fixed3D; m_imgbox.SizeMode = PictureBoxSizeMode.StretchImage; m_imgbox.DoubleClick += Button_Click; m_button.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | AnchorStyles.Bottom))); m_imgbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Top))); m_button.Size = new Size(274, 26); m_button.Location = new Point(3, 121); m_button.Click += Button_Click; m_button.Font = new System.Drawing.Font("BankGothic Md BT", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Controls.Add(m_imgbox); this.Controls.Add(m_button); Invalidate(); }