当前位置: 首页>>代码示例>>C#>>正文


C# IWebBrowser2类代码示例

本文整理汇总了C#中IWebBrowser2的典型用法代码示例。如果您正苦于以下问题:C# IWebBrowser2类的具体用法?C# IWebBrowser2怎么用?C# IWebBrowser2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IWebBrowser2类属于命名空间,在下文中一共展示了IWebBrowser2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteForBrowser

 /// <summary>
 /// Writes a url file representing the current navigation state of a browser
 /// </summary>
 /// <param name="browser">The IWebBrowser2 for which to write the url file</param>
 /// <param name="filePath">The path to the url file</param>
 public void WriteForBrowser( IWebBrowser2 browser, string filePath )
 {
     IObjectWithSite site = internetShortcut as IObjectWithSite ;
     site.SetSite( browser ) ;
     IPersistFile file = internetShortcut as IPersistFile ;
     file.Save( filePath, false ) ;
 }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:12,代码来源:InternetShortCut.cs

示例2: SetSite

 public void SetSite(object site) {
     explorer = site as IWebBrowser2;
     if(explorer == null || Process.GetCurrentProcess().ProcessName == "iexplore") {
         Marshal.ThrowExceptionForHR(E_FAIL);
     }
     else {
         ActivateIt();
     }
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:9,代码来源:AutoLoader.cs

示例3: Process

        public void Process(IWebBrowser2 webBrowser2)
        {
            var htmlDocument2 = (IHTMLDocument2)webBrowser2.Document;
            var containingFrameElement = GetContainingFrameElement();
            Elements.Add(new IEDocument(htmlDocument2, containingFrameElement));

            _index++;
        }
开发者ID:koshdim,项目名称:KoWatIn,代码行数:8,代码来源:AllFramesProcessor.cs

示例4: Process

 public void Process(IWebBrowser2 webBrowser2)
 {
     if (counter == index)
     {
         iWebBrowser2 = webBrowser2;
     }
     counter++;
 }
开发者ID:kevinswarner,项目名称:Hover_OLD,代码行数:8,代码来源:FrameByIndexProcessor.cs

示例5: Process

        public void Process(IWebBrowser2 webBrowser2)
        {
            // Get the frame element from the parent document
            var uniqueId = RetrieveUniqueIdOfFrameElement();

            var frameElement = RetrieveSameFrameFromHtmlDocument(uniqueId);
            var nativeFrameElement = new IEElement(frameElement);
            Elements.Add(new IEDocument((IHTMLDocument2) webBrowser2.Document, nativeFrameElement));

            index++;
        }
开发者ID:fschwiet,项目名称:WatiN-2.0.20.1089-net-2.0,代码行数:11,代码来源:AllFramesProcessor.cs

示例6: Process

		public void Process(IWebBrowser2 webBrowser2)
		{
			// Get the frame element from the parent document
			IHTMLElement frameElement = (IHTMLElement) frameElements.item(index, null);
			string frameElementUniqueId = ((DispHTMLBaseElement) frameElement).uniqueID;

			Frame frame = new Frame(_domContainer, (IHTMLDocument2)webBrowser2.Document, (IHTMLDocument3) htmlDocument, frameElementUniqueId);
			
			elements.Add(frame);

			index++;
		}
开发者ID:pusp,项目名称:o2platform,代码行数:12,代码来源:AllFramesProcessor.cs

示例7:

 int IObjectWithSite.SetSite(object site)
 {
     if (site != null)
     {
         browser = (IWebBrowser2)site;
         ((DWebBrowserEvents2_Event)browser).DocumentComplete +=
             new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
     }
     else
     {
         ((DWebBrowserEvents2_Event)browser).DocumentComplete -=
             new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
         browser = null;
     }
     return 0;
 }
开发者ID:e-user,项目名称:tos-dr,代码行数:16,代码来源:BHO.cs

示例8: SetSite

 public int SetSite(object pUnkSite)
 {
     if (pUnkSite != null)
     {
         _pUnkSite = (IWebBrowser2) pUnkSite;
         _webBrowser2Events = (DWebBrowserEvents2_Event) pUnkSite;
         SetSiteStartup();
         _webBrowser2Events.BeforeNavigate2 += _webBrowser2Events_BeforeNavigate2;
     }
     else
     {
         SetSiteShutdown();
         _webBrowser2Events.BeforeNavigate2 -= _webBrowser2Events_BeforeNavigate2;
         _pUnkSite = null;
         _webBrowser2Events = null;
     }
     return 0;
 }
开发者ID:vcsjones,项目名称:IeBHOExamples,代码行数:18,代码来源:BHO_BoilerPlate.cs

示例9: InternalCreateWB

        /// <summary>
        /// Create Webbrowser control and set up it's events
        /// called from OnHandleCreated
        /// Webbrowser control hosting requires an HWND
        /// </summary>
        /// <returns></returns>
        private void InternalCreateWB()
        {
            //Create a new WB, throws exception if fails
            Type webbrowsertype = Type.GetTypeFromCLSID(Iid_Clsids.CLSID_WebBrowser, true);
            //Using Activator inplace of CoCreateInstance, returns IUnknown
            m_WBUnknown = System.Activator.CreateInstance(webbrowsertype);

            //Get the IOleObject
            m_WBOleObject = (IOleObject)m_WBUnknown;
            //Set client site
            int iret = m_WBOleObject.SetClientSite(this);
            //Set hostnames
            iret = m_WBOleObject.SetHostNames("csEXWB", string.Empty);

            //Get client rect
            bool brect = WinApis.GetClientRect(this.Handle, out m_WBRect);
            //Setup H+W
            m_WBRect.Right = m_WBRect.Right - m_WBRect.Left; //W
            m_WBRect.Bottom = m_WBRect.Bottom - m_WBRect.Top; //H
            m_WBRect.Left = 0;
            m_WBRect.Top = 0;

            //Get the IOleInPlaceObject
            m_WBOleInPlaceObject = (IOleInPlaceObject)m_WBUnknown;
            tagRECT trect = new tagRECT();
            WinApis.CopyRect(ref trect, ref m_WBRect);
            //Set WB rects
            iret = m_WBOleInPlaceObject.SetObjectRects(ref m_WBRect, ref trect);

            //INPLACEACTIVATE the WB
            iret = m_WBOleObject.DoVerb((int)OLEDOVERB.OLEIVERB_INPLACEACTIVATE, ref m_NullMsg, this, 0, this.Handle, ref m_WBRect);

            //Get the IWebBrowser2
            m_WBWebBrowser2 = (IWebBrowser2)m_WBUnknown;

            //By default, we handle dragdrops
            m_WBWebBrowser2.RegisterAsDropTarget = false;
            if (!DesignMode)
            {
                //Get connectionpointcontainer
                IConnectionPointContainer cpCont = (IConnectionPointContainer)m_WBUnknown;
                //Find connection point
                Guid guid = typeof(DWebBrowserEvents2).GUID;
                IConnectionPoint m_WBConnectionPoint = null;
                cpCont.FindConnectionPoint(ref guid, out m_WBConnectionPoint);
                //Advice
                m_WBConnectionPoint.Advise(this, out m_dwCookie);

                //Get the IOleComandTarget
                m_WBOleCommandTarget = (IOleCommandTarget)m_WBUnknown;

                //Reguster clipborad format for internal drag drop
                //RegisterClipboardFormatsForDragDrop();
            }

            if (!string.IsNullOrEmpty(m_sUrl))
                this.Navigate(m_sUrl);
            else
                this.Navigate("about:blank");

            //Get the shell embedding, ...
            WBIEServerHandle();
        }
开发者ID:blacklensama,项目名称:earthquake-project-ui,代码行数:69,代码来源:cEXWB.cs

示例10: GetFrameDocument

 protected virtual IHTMLDocument2 GetFrameDocument(IWebBrowser2 frame)
 {
     return UtilityClass.TryFuncIgnoreException(() => frame.Document as IHTMLDocument2);
 }
开发者ID:exaphaser,项目名称:WatiN,代码行数:4,代码来源:IEWaitForComplete.cs

示例11: WBFramesCount

        private int WBFramesCount(IWebBrowser2 pWB)
        {
            int lRet = 0;

            IOleContainer oc = pWB.Document as IOleContainer;
            if (oc == null)
                return lRet;

            //get the OLE enumerator for the embedded objects
            int hr = 0;
            IEnumUnknown eu;

            hr = oc.EnumObjects(tagOLECONTF.OLECONTF_EMBEDDINGS, out eu); //EU ALLOC
            Marshal.ReleaseComObject(oc);                                 //OC FREE
            Marshal.ThrowExceptionForHR(hr);

            object pUnk = null;
            int fetched = 0;
            const int MAX_FETCH_COUNT = 1;

            //get the first ebmedded object
            hr = eu.Next(MAX_FETCH_COUNT, out pUnk, out fetched);         //PUNK ALLOC
            Marshal.ThrowExceptionForHR(hr);
            //while sucessfully get a new embedding, continue
            for (int i = 0; Hresults.S_OK == hr; i++)
            {
                //QI pUnk for the IWebBrowser2 interface
                IWebBrowser2 brow = pUnk as IWebBrowser2;
                if (brow != null)
                {
                    if (IsWBFrameset(brow))
                        lRet += WBFramesCount(brow);
                    else
                    {
                        lRet++;
                        Marshal.ReleaseComObject(brow);                         //PUNK FREE
                    }
                } //if(brow != null)

                //get the next ebmedded object
                hr = eu.Next(MAX_FETCH_COUNT, out pUnk, out fetched);       //PUNK ALLOC
                Marshal.ThrowExceptionForHR(hr);

            } //for(int i = 0; HRESULTS.S_OK == hr; i++)
            Marshal.ReleaseComObject(eu);                                 //EU FREE

            return lRet;
        }
开发者ID:blacklensama,项目名称:earthquake-project-ui,代码行数:48,代码来源:cEXWB.cs

示例12: Process

 public void Process(IWebBrowser2 webBrowser2)
 {
     FramesCount++;
 }
开发者ID:fschwiet,项目名称:watin_unbranched,代码行数:4,代码来源:FrameCountProcessor.cs

示例13: GetFrames

        private List<IWebBrowser2> GetFrames(IWebBrowser2 pWB)
        {
            List<IWebBrowser2> wbFrames = new List<IWebBrowser2>();

            IOleContainer oc = pWB.Document as IOleContainer;
            if (oc == null)
                return null;

            //get the OLE enumerator for the embedded objects
            int hr = 0;
            IEnumUnknown eu;

            hr = oc.EnumObjects(tagOLECONTF.OLECONTF_EMBEDDINGS, out eu); //EU ALLOC
            Marshal.ReleaseComObject(oc);                                 //OC FREE
            Marshal.ThrowExceptionForHR(hr);

            object pUnk = null;
            int fetched = 0;
            const int MAX_FETCH_COUNT = 1;

            //get the first ebmedded object
            hr = eu.Next(MAX_FETCH_COUNT, out pUnk, out fetched);         //PUNK ALLOC
            Marshal.ThrowExceptionForHR(hr);
            //while sucessfully get a new embedding, continue
            for (int i = 0; Hresults.S_OK == hr; i++)
            {
                //QI pUnk for the IWebBrowser2 interface
                IWebBrowser2 brow = pUnk as IWebBrowser2;
                if (brow != null)
                {
                    if (IsWBFrameset(brow))
                    {
                        List<IWebBrowser2> frames = GetFrames(brow);
                        if ((frames != null) && (frames.Count > 0))
                        {
                            wbFrames.AddRange(frames);
                            frames.Clear();
                        }
                    }
                    else
                    {
                        wbFrames.Add(brow);
                        //Marshal.ReleaseComObject(brow);                         //PUNK FREE
                    }
                } //if(brow != null)

                //get the next ebmedded object
                hr = eu.Next(MAX_FETCH_COUNT, out pUnk, out fetched);       //PUNK ALLOC
                Marshal.ThrowExceptionForHR(hr);

            } //for(int i = 0; HRESULTS.S_OK == hr; i++)
            Marshal.ReleaseComObject(eu);                                 //EU FREE

            return wbFrames;
        }
开发者ID:blacklensama,项目名称:earthquake-project-ui,代码行数:55,代码来源:cEXWB.cs

示例14: GetSource

        public string GetSource(IWebBrowser2 thisBrowser)
        {
            if ((thisBrowser == null) || (thisBrowser.Document == null))
                return string.Empty;

            //Declare vars
            int hr = Hresults.S_OK;
            IStream pStream = null;
            IPersistStreamInit pPersistStreamInit = null;

            // Query for IPersistStreamInit.
            pPersistStreamInit = thisBrowser.Document as IPersistStreamInit;
            if (pPersistStreamInit == null)
                return string.Empty;

            //Create stream, delete on release
            hr = WinApis.CreateStreamOnHGlobal(m_NullPointer, true, out pStream);
            if ((pStream == null) || (hr != Hresults.S_OK))
                return string.Empty;

            //Save
            hr = pPersistStreamInit.Save(pStream, false);
            if (hr != Hresults.S_OK)
                return string.Empty;

            //Now read from stream....

            //First get the size
            long ulSizeRequired = (long)0;
            //LARGE_INTEGER
            long liBeggining = (long)0;
            System.Runtime.InteropServices.ComTypes.STATSTG statstg = new System.Runtime.InteropServices.ComTypes.STATSTG();
            pStream.Seek(liBeggining, (int)tagSTREAM_SEEK.STREAM_SEEK_SET, m_NullPointer);
            pStream.Stat(out statstg, (int)tagSTATFLAG.STATFLAG_NONAME);

            //Size
            ulSizeRequired = statstg.cbSize;
            if (ulSizeRequired == (long)0)
                return string.Empty;

            //Allocate buffer + read
            byte[] pSource = new byte[ulSizeRequired];
            pStream.Read(pSource, (int)ulSizeRequired, m_NullPointer);

            //Added by schlaup to handle UTF8 and UNICODE pages
            //Convert
            //ASCIIEncoding asce = new ASCIIEncoding();
            //return asce.GetString(pSource);
            Encoding enc = null;

            if (pSource.Length > 8)
            {
                // Check byte order mark
                if ((pSource[0] == 0xFF) && (pSource[1] == 0xFE)) // UTF16LE
                    enc = Encoding.Unicode;

                if ((pSource[0] == 0xFE) && (pSource[1] == 0xFF)) // UTF16BE
                    enc = Encoding.BigEndianUnicode;

                if ((pSource[0] == 0xEF) && (pSource[1] == 0xBB) && (pSource[2] == 0xBF)) //UTF8
                    enc = Encoding.UTF8;

                if (enc == null)
                {
                    // Check for alternating zero bytes which might indicate Unicode
                    if ((pSource[1] == 0) && (pSource[3] == 0) && (pSource[5] == 0) && (pSource[7] == 0))
                        enc = Encoding.Unicode;
                }
            }

            if (enc == null)
                enc = Encoding.Default;

            int bomLength = enc.GetPreamble().Length;

            return enc.GetString(pSource, bomLength, pSource.Length - bomLength);
        }
开发者ID:blacklensama,项目名称:earthquake-project-ui,代码行数:77,代码来源:cEXWB.cs

示例15: GetTitle

 public string GetTitle(IWebBrowser2 thisBrowser)
 {
     if (thisBrowser == null)
         return string.Empty;
     IHTMLDocument2 doc2 = m_WBWebBrowser2.Document as IHTMLDocument2;
     if (doc2 != null)
         return doc2.title;
     else
         return string.Empty;
 }
开发者ID:blacklensama,项目名称:earthquake-project-ui,代码行数:10,代码来源:cEXWB.cs


注:本文中的IWebBrowser2类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。