bool UnsafeNativeMethods.IMsoComponentManager.FUpdateComponentRegistration(IntPtr dwComponentID, NativeMethods.MSOCRINFOSTRUCT info) { if (_original == null) { return(false); } // We assume that all winforms domains use the same registration. return(_original.FUpdateComponentRegistration(_componentId, info)); }
bool UnsafeNativeMethods.IMsoComponentManager.FGetActiveComponent(int dwgac, UnsafeNativeMethods.IMsoComponent[] ppic, NativeMethods.MSOCRINFOSTRUCT info, int dwReserved) { if (_original == null) { return(false); } if (_original.FGetActiveComponent(dwgac, ppic, info, dwReserved)) { // We got a component. See if it's our proxy, and if it is, // return what we think is currently active. We need only // check for "this", because we only have one of these // doo jabbers per process. if (ppic[0] == this) { if (dwgac == NativeMethods.MSOCM.msogacActive) { ppic[0] = _activeComponent; } else if (dwgac == NativeMethods.MSOCM.msogacTracking) { ppic[0] = _trackingComponent; } else if (dwgac == NativeMethods.MSOCM.msogacTrackingOrActive) { if (_trackingComponent != null) { ppic[0] = _trackingComponent; } } } return(ppic[0] != null); } else { return(false); } }
bool UnsafeNativeMethods.IMsoComponentManager.FRegisterComponent(UnsafeNativeMethods.IMsoComponent component, NativeMethods.MSOCRINFOSTRUCT pcrinfo, out IntPtr dwComponentID) { if (component == null) { throw new ArgumentNullException(nameof(component)); } dwComponentID = (IntPtr)0; if (_refCount == 0) { // Our first time hooking up to the real component manager if (!_original.FRegisterComponent(this, pcrinfo, out _componentId)) { return(false); } } _refCount++; if (_components == null) { _components = new Dictionary <int, UnsafeNativeMethods.IMsoComponent>(); } _nextComponentId++; if (_nextComponentId == int.MaxValue) { _nextComponentId = 1; } bool outofMemory = false; //just in case we wrap, lets search for a free ID while (_components.ContainsKey(_nextComponentId)) { _nextComponentId++; if (_nextComponentId == int.MaxValue) { if (outofMemory) { throw new InvalidOperationException(SR.ComponentManagerProxyOutOfMemory); } outofMemory = true; _nextComponentId = 1; } } _components.Add(_nextComponentId, component); dwComponentID = (IntPtr)_nextComponentId; return(true); }