// IOleDocumentSite Implementation public int ActivateMe(IOleDocumentView pViewToActivate) { if (pViewToActivate == null) { return(HRESULT.E_INVALIDARG); } RECT rect = new RECT(); ComSupport.GetClientRect(container.Handle, rect); view = pViewToActivate; int iResult = view.SetInPlaceSite((IOleInPlaceSite)this); iResult = view.UIActivate(1); iResult = view.SetRect(rect); int iShow = 1; iResult = view.Show(iShow); //1 is a boolean for True return(HRESULT.S_OK); }
// IOleDocumentSite Implementation public int ActivateMe(IOleDocumentView pViewToActivate) { Debug.Assert(pViewToActivate != null, "The view to activate was null"); if (pViewToActivate == null) { return(HRESULT.E_INVALIDARG); } RECT rect = new RECT(); win32.GetClientRect(container.Handle, rect); view = pViewToActivate; int iResult = view.SetInPlaceSite((IOleInPlaceSite)this); iResult = view.UIActivate(1); iResult = view.SetRect(rect); int iShow = 1; iResult = view.Show(iShow); //1 is a boolean for True return(HRESULT.S_OK); }
public void CloseDocument() { try { container.releaseWndProc(); container.Resize -= new EventHandler(this.Container_Resize); if (m_document == null) { return; } try { //this may raise an exception, however it does work and must //be called if (view != null) { view.Show(-1); view.UIActivate(-1); view.SetInPlaceSite(null); view.CloseView(0); } } catch (Exception e) { Debug.WriteLine("CloseView raised exception: " + e.Message); } try { //this could raise an exception too, but it must be called m_document.Close((int)tagOLECLOSE.OLECLOSE_NOSAVE); } catch (Exception e) { Debug.WriteLine("Close document raised exception: " + e.Message); } m_document.SetClientSite(null); win32.OleLockRunning(m_document, false, false); if (this.iAdviseCookie != 0) { m_document.Unadvise(this.iAdviseCookie); } if (this.iEventsCookie != 0) { m_document.Unadvise(this.iEventsCookie); } if (this.iPropertyNotifyCookie != 0) { m_document.Unadvise(this.iPropertyNotifyCookie); } if (container.changeCookie != 0) { ((IMarkupContainer2)m_document).UnRegisterForDirtyRange(container.changeCookie); container.changeCookie = 0; } //release COM objects int RefCount = 0; if (m_document != null) { do { RefCount = Marshal.ReleaseComObject(m_document); } while (RefCount > 0); } if (view != null) { do { RefCount = Marshal.ReleaseComObject(view); } while (RefCount > 0); } if (activeObject != null) { do { RefCount = Marshal.ReleaseComObject(activeObject); } while (RefCount > 0); } m_document = null; view = null; activeObject = null; container.mHtmlDoc = null; container.mDocHTML = null; } catch (Exception e) { Debug.WriteLine("CloseDocument raised exception: " + e.Message); } }
/// <summary> /// Asks a document site to activate the document making the call as a /// document object rather than an in-place-active object and, optionally, /// specifies which view of the object document to activate. This is based /// on the CFramerDocument::ActivateMe method from the FramerEx sample /// (referenced above in the class comment). The only difference is that /// we don't call IOleDocumentView.SetRect after the call to UIActivate /// since we don't allow additional of toolbars, etc. to the container. /// </summary> /// <param name="pViewToActivate"> Pointer to the document view to be used /// in activating the document object. Can be NULL according to the /// specification, however MSHTML should always pass a valid view when /// requesting activation.</param> void IOleDocumentSite.ActivateMe(IOleDocumentView pViewToActivate) { // log access to method LOG("IOleDocumentSite", "ActivateMe"); // MSHTML should always pass us a view if (pViewToActivate == null) { Debug.Fail("MSHMTL should always pass us a view!"); ComHelper.Return(HRESULT.E_FAILED); } // Get a reference to the document's view oleDocumentView = pViewToActivate; // Associate our site with the document view pViewToActivate.SetInPlaceSite((IOleInPlaceSite)(this)); // Get the command target for the view oleCommandTarget = (IOleCommandTargetWithExecParams)oleDocumentView; // hookup extra-feature accessor to the command target standardCommandSet = new MshtmlCoreCommandSet(oleCommandTarget); // UI Activate the document view oleDocumentView.UIActivate(true); // Show the view! oleDocumentView.Show(true); }
// IOleDocumentSite Implementation public int ActivateMe(IOleDocumentView pViewToActivate) { Debug.Assert(pViewToActivate != null, "The view to activate was null"); if (pViewToActivate == null) return HRESULT.E_INVALIDARG; RECT rect = new RECT(); win32.GetClientRect(container.Handle, rect); view = pViewToActivate; int iResult = view.SetInPlaceSite((IOleInPlaceSite)this); iResult = view.UIActivate(1); iResult = view.SetRect(rect); int iShow = 1; iResult = view.Show(iShow); //1 is a boolean for True return HRESULT.S_OK; }