private void renameToolStripMenuItem_Click(object sender, System.EventArgs e) { using (GetTextForm frm = new GetTextForm(TabText)) { frm.Text = "Edit Tab Name"; if (frm.ShowDialog(this) == DialogResult.OK) { TabText = frm.Data; } } }
private void menuObjectBindMoniker_Click(object sender, EventArgs e) { using (GetTextForm frm = new GetTextForm(_last_moniker)) { frm.Text = "Specify Moniker"; if (frm.ShowDialog(this) == DialogResult.OK) { try { _last_moniker = frm.Data; object comObj = Marshal.BindToMoniker(_last_moniker); if (comObj != null) { OpenObjectInformation(comObj, _last_moniker); } } catch (Exception ex) { MessageBox.Show(this, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void menuViewCreateInstanceFromCLSID_Click(object sender, EventArgs e) { GetTextForm frm = new GetTextForm(""); if (frm.ShowDialog() == DialogResult.OK) { try { Guid g = new Guid(frm.Data); Dictionary<string, string> props = new Dictionary<string,string>(); object comObj = null; string strObjName = ""; COMInterfaceEntry[] ints = null; if (m_comRegistry.Clsids.ContainsKey(g)) { COMCLSIDEntry ent = m_comRegistry.Clsids[g]; strObjName = ent.Name; props.Add("CLSID", ent.Clsid.ToString("B")); props.Add("Name", ent.Name); props.Add("Server", ent.Server); comObj = ent.CreateInstanceAsObject(); ints = m_comRegistry.GetSupportedInterfaces(ent, false); } else { Guid unk = COMInterfaceEntry.IID_IUnknown; IntPtr pObj; if (COMUtilities.CoCreateInstance(ref g, IntPtr.Zero, COMUtilities.CLSCTX.CLSCTX_SERVER, ref unk, out pObj) == 0) { ints = m_comRegistry.GetInterfacesForIUnknown(pObj); comObj = Marshal.GetObjectForIUnknown(pObj); strObjName = g.ToString("B"); props.Add("CLSID", g.ToString("B")); Marshal.Release(pObj); } } if (comObj != null) { /* Need to implement a type library reader */ Type dispType = COMUtilities.GetDispatchTypeInfo(comObj); ObjectInformation view = new ObjectInformation(strObjName, comObj, props, ints); view.ShowHint = DockState.Document; view.Show(m_dockPanel); } } catch(Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }