Esempio n. 1
0
        internal void TransitionDownTo(ActiveXHelper.ActiveXState state)
        {
            if (!this.GetAxHostState(ActiveXHelper.inTransition))
            {
                this.SetAxHostState(ActiveXHelper.inTransition, true);

                try
                {
                    ActiveXHelper.ActiveXState oldState;

                    while (state < this.ActiveXState)
                    {
                        oldState = this.ActiveXState;

                        switch (this.ActiveXState)
                        {
                        case ActiveXHelper.ActiveXState.Open:
                            Debug.Fail("how did we ever get into the open state?");
                            this.ActiveXState = ActiveXHelper.ActiveXState.UIActive;
                            break;

                        case ActiveXHelper.ActiveXState.UIActive:
                            TransitionFromUIActiveToInPlaceActive();
                            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Failed transition");
                            this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
                            break;

                        case ActiveXHelper.ActiveXState.InPlaceActive:
                            TransitionFromInPlaceActiveToRunning();
                            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Running, "Failed transition");
                            this.ActiveXState = ActiveXHelper.ActiveXState.Running;
                            break;

                        case ActiveXHelper.ActiveXState.Running:
                            TransitionFromRunningToLoaded();
                            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Failed transition");
                            this.ActiveXState = ActiveXHelper.ActiveXState.Loaded;
                            break;

                        case ActiveXHelper.ActiveXState.Loaded:
                            TransitionFromLoadedToPassive();
                            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Passive, "Failed transition");
                            this.ActiveXState = ActiveXHelper.ActiveXState.Passive;
                            break;

                        default:
                            Debug.Fail("bad state");
                            this.ActiveXState = this.ActiveXState - 1;      // To exit the loop
                            break;
                        }

                        OnActiveXStateChange((int)oldState, (int)this.ActiveXState);
                    }
                }
                finally
                {
                    this.SetAxHostState(ActiveXHelper.inTransition, false);
                }
            }
        }
Esempio n. 2
0
        private void TransitionFromLoadedToPassive()
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Wrong start state to transition from");
            if (this.ActiveXState == ActiveXHelper.ActiveXState.Loaded)
            {
                //
                // Need to make sure that we don't handle any PropertyChanged
                // notifications at this point.
                //this.NoComponentChangeEvents++;
                try
                {
                    //
                    // Release the _axInstance
                    if (_axInstance != null)
                    {
                        //
                        // Lets first get the cached interface pointers of _axInstance released.
                        this.DetachInterfacesInternal();

                        Marshal.FinalReleaseComObject(_axInstance);
                        _axInstance = null;
                    }
                }
                finally
                {
                    //Consider: this.NoComponentChangeEvents--;
                }

                //
                // We are now Passive!
                this.ActiveXState = ActiveXHelper.ActiveXState.Passive;
            }
        }
Esempio n. 3
0
        private void TransitionFromRunningToInPlaceActive()
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Running, "Wrong start state to transition from");
            if (this.ActiveXState == ActiveXHelper.ActiveXState.Running)
            {
                try
                {
                    DoVerb(NativeMethods.OLEIVERB_INPLACEACTIVATE);
                }
                catch (Exception e)
                {
                    if (CriticalExceptions.IsCriticalException(e))
                    {
                        throw;
                    }
                    else
                    {
                        throw new TargetInvocationException(SR.Get(SRID.AXNohWnd, GetType().Name), e);
                    }
                }

                //
                // We are now InPlaceActive!
                this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
            }
        }
Esempio n. 4
0
 private void TransitionFromInPlaceActiveToRunning()
 {
     if (this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive)
     {
         this._axOleInPlaceObject.InPlaceDeactivate();
         this.ActiveXState = ActiveXHelper.ActiveXState.Running;
     }
 }
Esempio n. 5
0
 private void TransitionFromInPlaceActiveToUIActive()
 {
     if (this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive)
     {
         this.DoVerb(-4);
         this.ActiveXState = ActiveXHelper.ActiveXState.UIActive;
     }
 }
Esempio n. 6
0
 private void TransitionFromUIActiveToInPlaceActive()
 {
     if (this.ActiveXState == ActiveXHelper.ActiveXState.UIActive)
     {
         int num = this._axOleInPlaceObject.UIDeactivate();
         this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
     }
 }
Esempio n. 7
0
 private void TransitionFromPassiveToLoaded()
 {
     if (this.ActiveXState == ActiveXHelper.ActiveXState.Passive)
     {
         this._axInstance  = this.CreateActiveXObject(this._clsid.Value);
         this.ActiveXState = ActiveXHelper.ActiveXState.Loaded;
         this.AttachInterfacesInternal();
     }
 }
Esempio n. 8
0
 private void TransitionFromRunningToLoaded()
 {
     if (this.ActiveXState == ActiveXHelper.ActiveXState.Running)
     {
         this.StopEvents();
         this._axOleObject.SetClientSite(null);
         this.ActiveXState = ActiveXHelper.ActiveXState.Loaded;
     }
 }
Esempio n. 9
0
        private void TransitionFromInPlaceActiveToUIActive()
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Wrong start state to transition from");
            if (this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive)
            {
                DoVerb(NativeMethods.OLEIVERB_UIACTIVATE);

                //
                // We are now UIActive!
                this.ActiveXState = ActiveXHelper.ActiveXState.UIActive;
            }
        }
Esempio n. 10
0
        // Token: 0x0600617D RID: 24957 RVA: 0x001B5940 File Offset: 0x001B3B40
        internal void TransitionUpTo(ActiveXHelper.ActiveXState state)
        {
            if (!this.GetAxHostState(ActiveXHelper.inTransition))
            {
                this.SetAxHostState(ActiveXHelper.inTransition, true);
                try
                {
                    while (state > this.ActiveXState)
                    {
                        ActiveXHelper.ActiveXState activeXState = this.ActiveXState;
                        switch (this.ActiveXState)
                        {
                        case ActiveXHelper.ActiveXState.Passive:
                            this.TransitionFromPassiveToLoaded();
                            this.ActiveXState = ActiveXHelper.ActiveXState.Loaded;
                            break;

                        case ActiveXHelper.ActiveXState.Loaded:
                            this.TransitionFromLoadedToRunning();
                            this.ActiveXState = ActiveXHelper.ActiveXState.Running;
                            break;

                        case ActiveXHelper.ActiveXState.Running:
                            this.TransitionFromRunningToInPlaceActive();
                            this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
                            break;

                        case (ActiveXHelper.ActiveXState) 3:
                            goto IL_87;

                        case ActiveXHelper.ActiveXState.InPlaceActive:
                            this.TransitionFromInPlaceActiveToUIActive();
                            this.ActiveXState = ActiveXHelper.ActiveXState.UIActive;
                            break;

                        default:
                            goto IL_87;
                        }
IL_95:
                        this.OnActiveXStateChange((int)activeXState, (int)this.ActiveXState);
                        continue;
IL_87:
                        this.ActiveXState++;
                        goto IL_95;
                    }
                }
                finally
                {
                    this.SetAxHostState(ActiveXHelper.inTransition, false);
                }
            }
        }
Esempio n. 11
0
 private void TransitionFromLoadedToPassive()
 {
     if (this.ActiveXState == ActiveXHelper.ActiveXState.Loaded)
     {
         if (this._axInstance != null)
         {
             this.DetachInterfacesInternal();
             Marshal.FinalReleaseComObject(this._axInstance);
             this._axInstance = null;
         }
         this.ActiveXState = ActiveXHelper.ActiveXState.Passive;
     }
 }
Esempio n. 12
0
        private void TransitionFromUIActiveToInPlaceActive()
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.UIActive, "Wrong start state to transition from");
            if (this.ActiveXState == ActiveXHelper.ActiveXState.UIActive)
            {
                int hr = _axOleInPlaceObject.UIDeactivate();
                Debug.Assert(NativeMethods.Succeeded(hr), "Failed in IOleInPlaceObject.UiDeactivate");

                //
                // We are now InPlaceActive!
                this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
            }
        }
Esempio n. 13
0
 private void TransitionFromLoadedToRunning()
 {
     if (this.ActiveXState == ActiveXHelper.ActiveXState.Loaded)
     {
         int num        = 0;
         int miscStatus = this._axOleObject.GetMiscStatus(1, out num);
         if (NativeMethods.Succeeded(miscStatus) && (num & 131072) != 0)
         {
             this._axOleObject.SetClientSite(this.ActiveXSite);
         }
         this.StartEvents();
         this.ActiveXState = ActiveXHelper.ActiveXState.Running;
     }
 }
Esempio n. 14
0
        private void TransitionFromInPlaceActiveToRunning()
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Wrong start state to transition from");
            if (this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive)
            {
                //
                // InPlaceDeactivate.
                _axOleInPlaceObject.InPlaceDeactivate();

                //
                // We are now Running!
                this.ActiveXState = ActiveXHelper.ActiveXState.Running;
            }
        }
Esempio n. 15
0
        private void TransitionFromRunningToLoaded()
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Running, "Wrong start state to transition from");
            if (this.ActiveXState == ActiveXHelper.ActiveXState.Running)
            {
                StopEvents();

                //
                // Inform the ActiveX control that it's been un-sited.
                _axOleObject.SetClientSite(null);

                //
                // We are now Loaded!
                this.ActiveXState = ActiveXHelper.ActiveXState.Loaded;
            }
        }
 protected override void OnHandleCreated(EventArgs e)
 {
     if (Application.OleRequired() != ApartmentState.STA)
     {
         throw new ThreadStateException(ResourcesHelper.GetString(ResourcesHelper.ThreadMustBeSTA));
     }
     base.OnHandleCreated(e);
     if ((this.activeXReloadingState != ActiveXHelper.ActiveXState.Passive) && (this.activeXReloadingState != this.activeXState))
     {
         if (this.activeXState < this.activeXReloadingState)
         {
             this.ChangeActiveXStateUpTo(this.activeXReloadingState);
         }
         else
         {
             this.ChangeActiveXStateDownTo(this.activeXReloadingState);
         }
         this.activeXReloadingState = ActiveXHelper.ActiveXState.Passive;
     }
 }
Esempio n. 17
0
 private void TransitionFromRunningToInPlaceActive()
 {
     if (this.ActiveXState == ActiveXHelper.ActiveXState.Running)
     {
         try
         {
             this.DoVerb(-5);
         }
         catch (Exception ex)
         {
             if (CriticalExceptions.IsCriticalException(ex))
             {
                 throw;
             }
             throw new TargetInvocationException(SR.Get("AXNohWnd", new object[]
             {
                 base.GetType().Name
             }), ex);
         }
         this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
     }
 }
Esempio n. 18
0
        private void TransitionFromPassiveToLoaded()
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Passive, "Wrong start state to transition from");
            if (this.ActiveXState == ActiveXHelper.ActiveXState.Passive)
            {
                //
                // First, create the ActiveX control
                Debug.Assert(_axInstance == null, "_axInstance must be null");

                _axInstance = CreateActiveXObject(_clsid.Value);
                Debug.Assert(_axInstance != null, "w/o an exception being thrown we must have an object...");

                //
                // We are now Loaded!
                this.ActiveXState = ActiveXHelper.ActiveXState.Loaded;

                //
                // Lets give them a chance to cast the ActiveX object
                // to the appropriate interfaces.
                this.AttachInterfacesInternal();
            }
        }
Esempio n. 19
0
        private void TransitionFromLoadedToRunning()
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Wrong start state to transition from");
            if (this.ActiveXState == ActiveXHelper.ActiveXState.Loaded)
            {
                //
                // See if the ActiveX control returns OLEMISC_SETCLIENTSITEFIRST
                int bits = 0;
                int hr   = _axOleObject.GetMiscStatus(NativeMethods.DVASPECT_CONTENT, out bits);
                if (NativeMethods.Succeeded(hr) && ((bits & NativeMethods.OLEMISC_SETCLIENTSITEFIRST) != 0))
                {
                    //
                    // Simply setting the site to the ActiveX control should activate it.
                    // And this will take us to the Running state.
                    _axOleObject.SetClientSite(this.ActiveXSite);
                }

                StartEvents();

                //
                // We are now Running!
                this.ActiveXState = ActiveXHelper.ActiveXState.Running;
            }
        }
Esempio n. 20
0
        private void TransitionFromLoadedToRunning() 
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Wrong start state to transition from"); 
            if (this.ActiveXState == ActiveXHelper.ActiveXState.Loaded)
            {
                //
                // See if the ActiveX control returns OLEMISC_SETCLIENTSITEFIRST 
                int bits = 0;
                int hr = _axOleObject.GetMiscStatus(NativeMethods.DVASPECT_CONTENT, out bits); 
                if (NativeMethods.Succeeded(hr) && ((bits & NativeMethods.OLEMISC_SETCLIENTSITEFIRST) != 0)) 
                {
                    // 
                    // Simply setting the site to the ActiveX control should activate it.
                    // And this will take us to the Running state.
                    _axOleObject.SetClientSite(this.ActiveXSite);
                } 

                StartEvents(); 
 
                //
                // We are now Running! 
                this.ActiveXState = ActiveXHelper.ActiveXState.Running;
            }
        }
        private void ChangeActiveXStateUpTo(ActiveXHelper.ActiveXState state)
        {
            if (!this.GetActiveXHostState(ActiveXHelper.InTransition))
            {
                this.SetActiveXHostState(ActiveXHelper.InTransition, true);
                try
                {
                    while (state > this.activeXState)
                    {
                        switch (this.activeXState)
                        {
                        case ActiveXHelper.ActiveXState.Passive:
                            this.activeXInstance = UnsafeNativeMethods.CoCreateInstance <TActiveXClass, TActiveXInterface>(null, NativeMethods.tagCLSCTX.CLSCTX_INPROC_SERVER, NativeMethods.ActiveX.IID_IUnknown);
                            this.activeXState    = ActiveXHelper.ActiveXState.Loaded;
                            this.AttachInterfacesInternal();
                            continue;

                        case ActiveXHelper.ActiveXState.Loaded:
                            try
                            {
                                if ((this.activeXOleObject.GetMiscStatus(NativeMethods.tagDVASPECT.DVASPECT_CONTENT) & NativeMethods.tagOLEMISC.OLEMISC_SETCLIENTSITEFIRST) != 0)
                                {
                                    this.activeXOleObject.SetClientSite(this.ActiveXSite);
                                }
                            }
                            catch { }
                            if (!base.DesignMode)
                            {
                                this.StartEvents();
                            }
                            this.activeXState = ActiveXHelper.ActiveXState.Running;
                            continue;

                        case ActiveXHelper.ActiveXState.Running:
                            try
                            {
                                this.DoVerb(NativeMethods.OLEIVERB.OLEIVERB_INPLACEACTIVATE);
                            }
                            catch (Exception ex)
                            {
                                throw new TargetInvocationException(ResourcesHelper.GetString(ResourcesHelper.ActiveXNoWindowHandle, new object[] { base.GetType().Name }), ex);
                            }
                            ControlShim.CreateControl(this, true);
                            this.activeXState = ActiveXHelper.ActiveXState.InPlaceActive;
                            continue;

                        case ActiveXHelper.ActiveXState.InPlaceActive:
                            try
                            {
                                this.DoVerb(NativeMethods.OLEIVERB.OLEIVERB_UIACTIVATE);
                            }
                            catch (Exception ex)
                            {
                                throw new TargetInvocationException(ResourcesHelper.GetString(ResourcesHelper.ActiveXNoWindowHandle, new object[] { base.GetType().Name }), ex);
                            }
                            this.activeXState = ActiveXHelper.ActiveXState.UIActive;
                            continue;
                        }
                        //this.activeXState += ActiveXHelper.ActiveXState.Loaded;
                        this.activeXState = (ActiveXHelper.ActiveXState)((int)(this.activeXState) + (int)(ActiveXHelper.ActiveXState.Loaded));
                    }
                }
                finally
                {
                    this.SetActiveXHostState(ActiveXHelper.InTransition, false);
                }
            }
        }
Esempio n. 22
0
        // Token: 0x0600617E RID: 24958 RVA: 0x001B5A1C File Offset: 0x001B3C1C
        internal void TransitionDownTo(ActiveXHelper.ActiveXState state)
        {
            if (!this.GetAxHostState(ActiveXHelper.inTransition))
            {
                this.SetAxHostState(ActiveXHelper.inTransition, true);
                try
                {
                    while (state < this.ActiveXState)
                    {
                        ActiveXHelper.ActiveXState activeXState  = this.ActiveXState;
                        ActiveXHelper.ActiveXState activeXState2 = this.ActiveXState;
                        switch (activeXState2)
                        {
                        case ActiveXHelper.ActiveXState.Loaded:
                            this.TransitionFromLoadedToPassive();
                            this.ActiveXState = ActiveXHelper.ActiveXState.Passive;
                            break;

                        case ActiveXHelper.ActiveXState.Running:
                            this.TransitionFromRunningToLoaded();
                            this.ActiveXState = ActiveXHelper.ActiveXState.Loaded;
                            break;

                        case (ActiveXHelper.ActiveXState) 3:
                            goto IL_95;

                        case ActiveXHelper.ActiveXState.InPlaceActive:
                            this.TransitionFromInPlaceActiveToRunning();
                            this.ActiveXState = ActiveXHelper.ActiveXState.Running;
                            break;

                        default:
                            if (activeXState2 != ActiveXHelper.ActiveXState.UIActive)
                            {
                                if (activeXState2 != ActiveXHelper.ActiveXState.Open)
                                {
                                    goto IL_95;
                                }
                                this.ActiveXState = ActiveXHelper.ActiveXState.UIActive;
                            }
                            else
                            {
                                this.TransitionFromUIActiveToInPlaceActive();
                                this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
                            }
                            break;
                        }
IL_A3:
                        this.OnActiveXStateChange((int)activeXState, (int)this.ActiveXState);
                        continue;
IL_95:
                        this.ActiveXState--;
                        goto IL_A3;
                    }
                }
                finally
                {
                    this.SetAxHostState(ActiveXHelper.inTransition, false);
                }
            }
        }
Esempio n. 23
0
        internal void TransitionDownTo(ActiveXHelper.ActiveXState state)
        {
            if (!this.GetAxHostState(ActiveXHelper.inTransition)) 
            {
                this.SetAxHostState(ActiveXHelper.inTransition, true); 
 
                try
                { 
                    ActiveXHelper.ActiveXState oldState;

                    while (state < this.ActiveXState)
                    { 
                        oldState = this.ActiveXState;
 
                        switch (this.ActiveXState) 
                        {
                            case ActiveXHelper.ActiveXState.Open: 
                                Debug.Fail("how did we ever get into the open state?");
                                this.ActiveXState = ActiveXHelper.ActiveXState.UIActive;
                                break;
                            case ActiveXHelper.ActiveXState.UIActive: 
                                TransitionFromUIActiveToInPlaceActive();
                                Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Failed transition"); 
                                this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive; 
                                break;
                            case ActiveXHelper.ActiveXState.InPlaceActive: 
                                TransitionFromInPlaceActiveToRunning();
                                Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Running, "Failed transition");
                                this.ActiveXState = ActiveXHelper.ActiveXState.Running;
                                break; 
                            case ActiveXHelper.ActiveXState.Running:
                                TransitionFromRunningToLoaded(); 
                                Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Failed transition"); 
                                this.ActiveXState = ActiveXHelper.ActiveXState.Loaded;
                                break; 
                            case ActiveXHelper.ActiveXState.Loaded:
                                TransitionFromLoadedToPassive();
                                Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Passive, "Failed transition");
                                this.ActiveXState = ActiveXHelper.ActiveXState.Passive; 
                                break;
                            default: 
                                Debug.Fail("bad state"); 
                                this.ActiveXState = this.ActiveXState - 1;  // To exit the loop
                                break; 
                        }

                        OnActiveXStateChange((int)oldState, (int)this.ActiveXState);
                    } 
                }
                finally 
                { 
                    this.SetAxHostState(ActiveXHelper.inTransition, false);
                } 
            }
        }
Esempio n. 24
0
        private void TransitionFromPassiveToLoaded()
        { 
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Passive, "Wrong start state to transition from");
            if (this.ActiveXState == ActiveXHelper.ActiveXState.Passive)
            {
                // 
                // First, create the ActiveX control
                Debug.Assert(_axInstance == null, "_axInstance must be null"); 
 
                _axInstance = CreateActiveXObject(_clsid.Value);
                Debug.Assert(_axInstance != null, "w/o an exception being thrown we must have an object..."); 

                //
                // We are now Loaded!
                this.ActiveXState = ActiveXHelper.ActiveXState.Loaded; 

                // 
                // Lets give them a chance to cast the ActiveX object 
                // to the appropriate interfaces.
                this.AttachInterfacesInternal(); 
            }
        }
Esempio n. 25
0
        private void TransitionFromInPlaceActiveToUIActive()
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Wrong start state to transition from"); 
            if (this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive)
            { 
                DoVerb(NativeMethods.OLEIVERB_UIACTIVATE); 

                // 
                // We are now UIActive!
                this.ActiveXState = ActiveXHelper.ActiveXState.UIActive;
            }
        } 
        private void ChangeActiveXStateDownTo(ActiveXHelper.ActiveXState state)
        {
            if (!this.GetActiveXHostState(ActiveXHelper.InTransition))
            {
                this.SetActiveXHostState(ActiveXHelper.InTransition, true);
                try
                {
                    while (state < this.activeXState)
                    {
                        switch (this.activeXState)
                        {
                        case ActiveXHelper.ActiveXState.Loaded:
                            this.numberOfComponentChangeEvents++;
                            try
                            {
                                if (this.activeXInstance != null)
                                {
                                    this.DetachInterfacesInternal();
                                    Marshal.FinalReleaseComObject(this.activeXInstance);
                                    this.activeXInstance = null;
                                }
                            }
                            finally
                            {
                                this.numberOfComponentChangeEvents--;
                            }
                            this.activeXState = ActiveXHelper.ActiveXState.Passive;
                            continue;

                        case ActiveXHelper.ActiveXState.Running:
                            this.StopEvents();
                            ActiveXContainer activeXContainer = this.GetParentContainer();
                            if (activeXContainer != null)
                            {
                                activeXContainer.RemoveControl(this);
                            }
                            this.activeXOleObject.SetClientSite(null);
                            this.activeXState = ActiveXHelper.ActiveXState.Loaded;
                            continue;

                        case (ActiveXHelper.ActiveXState.Running | ActiveXHelper.ActiveXState.Loaded):
                            break;

                        case ActiveXHelper.ActiveXState.InPlaceActive:
                            ContainerControl containingControl = this.ContainingControl;
                            if ((containingControl != null) && (containingControl.ActiveControl == this))
                            {
                                ContainerControlShim.SetActiveControlInternal(containingControl, null);
                            }
                            this.activeXOleInPlaceObject.InPlaceDeactivate();
                            this.activeXState = ActiveXHelper.ActiveXState.Running;
                            continue;

                        case ActiveXHelper.ActiveXState.UIActive:
                            this.activeXOleInPlaceObject.UIDeactivate();
                            this.activeXState = ActiveXHelper.ActiveXState.InPlaceActive;
                            continue;
                        }
                        this.activeXState -= ActiveXHelper.ActiveXState.Loaded;
                    }
                }
                finally
                {
                    this.SetActiveXHostState(ActiveXHelper.InTransition, false);
                }
            }
        }
Esempio n. 27
0
        private void TransitionFromRunningToLoaded()
        { 
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Running, "Wrong start state to transition from");
            if (this.ActiveXState == ActiveXHelper.ActiveXState.Running) 
            { 
                StopEvents();
 
                //
                // Inform the ActiveX control that it's been un-sited.
                _axOleObject.SetClientSite(null);
 
                //
                // We are now Loaded! 
                this.ActiveXState = ActiveXHelper.ActiveXState.Loaded; 
            }
        } 
Esempio n. 28
0
        private void TransitionFromRunningToInPlaceActive() 
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Running, "Wrong start state to transition from");
            if (this.ActiveXState == ActiveXHelper.ActiveXState.Running)
            { 
                try
                { 
                    DoVerb(NativeMethods.OLEIVERB_INPLACEACTIVATE); 
                }
                catch (Exception e) 
                {
                    if(CriticalExceptions.IsCriticalException(e))
                    {
                        throw; 
                    }
                    else 
                    { 
                        throw new TargetInvocationException(SR.Get(SRID.AXNohWnd, GetType().Name), e);
                    } 
                }

                //
                // We are now InPlaceActive! 
                this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
            } 
        } 
Esempio n. 29
0
        private void TransitionFromInPlaceActiveToRunning() 
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive, "Wrong start state to transition from"); 
            if (this.ActiveXState == ActiveXHelper.ActiveXState.InPlaceActive)
            {
                //
                // InPlaceDeactivate. 
                _axOleInPlaceObject.InPlaceDeactivate();
 
                // 
                // We are now Running!
                this.ActiveXState = ActiveXHelper.ActiveXState.Running; 
            }
        }
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case NativeMethods.WM_LBUTTONDOWN:
            case NativeMethods.WM_RBUTTONDOWN:
            case NativeMethods.WM_MBUTTONDOWN:
            case NativeMethods.WM_MOUSEACTIVATE:
                if (!base.DesignMode)
                {
                    this.Focus();
                }
                this.DefWndProc(ref m);
                return;

            case NativeMethods.WM_LBUTTONUP:
            case NativeMethods.WM_LBUTTONDBLCLK:
            case NativeMethods.WM_RBUTTONUP:
            case NativeMethods.WM_RBUTTONDBLCLK:
            case NativeMethods.WM_MBUTTONUP:
            case NativeMethods.WM_MBUTTONDBLCLK:
            case NativeMethods.x2055:
            case NativeMethods.WM_CONTEXTMENU:
            case NativeMethods.WM_ERASEBKGND:
            case NativeMethods.WM_SYSCOLORCHANGE:
            case NativeMethods.WM_SETCURSOR:
            case NativeMethods.WM_DRAWITEM:
                this.DefWndProc(ref m);
                return;

            case NativeMethods.WM_COMMAND:
                if (!ControlShim.ReflectMessageInternal(m.LParam, ref m))
                {
                    this.DefWndProc(ref m);
                }
                return;

            case NativeMethods.WM_HELP:
                base.WndProc(ref m);
                this.DefWndProc(ref m);
                return;

            case NativeMethods.WM_DESTROY:
                break;

            case NativeMethods.WM_KILLFOCUS:
                this.hwndFocus = m.WParam;
                try
                {
                    base.WndProc(ref m);
                    return;
                }
                finally
                {
                    this.hwndFocus = IntPtr.Zero;
                }

            default:
                if (m.Msg == ActiveXHelper.REGMSG_MSG)
                {
                    m.Result = (IntPtr)0x7b;
                }
                else
                {
                    base.WndProc(ref m);
                }
                return;
            }

            if ((this.activeXState >= ActiveXHelper.ActiveXState.InPlaceActive))
            {
                IntPtr window = this.activeXOleInPlaceObject.GetWindow();
                if (window != IntPtr.Zero)
                {
                    ApplicationShim.ParkHandle(new HandleRef(this.activeXOleInPlaceObject, window));
                }
            }
            if (base.RecreatingHandle)
            {
                this.activeXReloadingState = this.activeXState;
            }
            this.ChangeActiveXStateDownTo(ActiveXHelper.ActiveXState.Running);
            if (this.activeXWindow != null)
            {
                this.activeXWindow.ReleaseHandle();
            }
            this.OnHandleDestroyed(EventArgs.Empty);
        }
Esempio n. 31
0
        private void TransitionFromLoadedToPassive()
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.Loaded, "Wrong start state to transition from"); 
            if (this.ActiveXState == ActiveXHelper.ActiveXState.Loaded)
            { 
                // 
                // Need to make sure that we don't handle any PropertyChanged
                // notifications at this point. 
                //this.NoComponentChangeEvents++;
                try
                {
                    // 
                    // Release the _axInstance
                    if (_axInstance != null) 
                    { 
                        //
                        // Lets first get the cached interface pointers of _axInstance released. 
                        this.DetachInterfacesInternal();

                        Marshal.FinalReleaseComObject(_axInstance);
                        _axInstance = null; 
                    }
                } 
                finally 
                {
                    // 
                }

                //
                // We are now Passive! 
                this.ActiveXState = ActiveXHelper.ActiveXState.Passive;
            } 
        } 
Esempio n. 32
0
        private void TransitionFromUIActiveToInPlaceActive() 
        {
            Debug.Assert(this.ActiveXState == ActiveXHelper.ActiveXState.UIActive, "Wrong start state to transition from"); 
            if (this.ActiveXState == ActiveXHelper.ActiveXState.UIActive) 
            {
                int hr = _axOleInPlaceObject.UIDeactivate(); 
                Debug.Assert(NativeMethods.Succeeded(hr), "Failed in IOleInPlaceObject.UiDeactivate");

                //
                // We are now InPlaceActive! 
                this.ActiveXState = ActiveXHelper.ActiveXState.InPlaceActive;
            } 
        }