private XlCommandBarControl ReturnHelper(MsoControlType type, object comRef) { switch (type) { case MsoControlType.msoControlButton: XlCommandBarButton newButton = new XlCommandBarButton(this, comRef); ListChildReferences.Add(newButton); return(newButton); case MsoControlType.msoControlPopup: XlCommandBarPopup newPopup = new XlCommandBarPopup(this, comRef); ListChildReferences.Add(newPopup); return(newPopup); case MsoControlType.msoControlComboBox: XlCommandBarComboBox newBox = new XlCommandBarComboBox(this, comRef); ListChildReferences.Add(newBox); return(newBox); default: XlCommandBarControl newClass = new XlCommandBarControl(this, comRef); ListChildReferences.Add(newClass); return(newClass); } }
public void SetupEventBinding(XlCommandBarButton button) { if (true == XlLateBindingApiSettings.EventsEnabled) { _button = button; IConnectionPointContainer connectionPointContainer = (IConnectionPointContainer)button.COMReference; Guid guid = new Guid("{000C0351-0000-0000-C000-000000000046}"); connectionPointContainer.FindConnectionPoint(ref guid, out _connectionPoint); _connectionPoint.Advise(this, out _connectionCookie); } }
internal void RaiseClickEvent(object Ctrl, ref bool CancelDefault) { if (null == Click) { Marshal.ReleaseComObject(Ctrl); return; } XlCommandBarButton btn = new XlCommandBarButton(this, Ctrl); ListChildReferences.Add(btn); Click(btn, ref CancelDefault); }