My extension for Internet Explorer don't get BefereNavigate2 event
-
8 martie 2012 11:18
I created a sidebar for Internet Explorer (IE) following the example shown in
http://code.msdn.microsoft.com/CSIEExplorerBar-ba8fe182/view/Reviews
I implemented the IObjectWithSite interface and I defined SetSite method as follow:
public void SetSite(object pUnkSite) { // Release previous COM objects. if (this.site != null) { Marshal.ReleaseComObject(this.site); } if (this.explorer != null) { Marshal.ReleaseComObject(this.explorer); this.explorer = null; } // pUnkSite is a pointer to object that implements IOleWindowSite. this.site = pUnkSite as NativeMethods.IInputObjectSite; if (this.site != null) { // The site implements IServiceProvider interface and can be used to // get InternetExplorer instance. var provider = this.site as NativeMethods._IServiceProvider; Guid guid = new Guid("{0002DF05-0000-0000-C000-000000000046}"); Guid riid = new Guid("{00000000-0000-0000-C000-000000000046}"); try { //allochiamo il nostro browser e diciamo che è IE object webBrowser; provider.QueryService(ref guid, ref riid, out webBrowser); this.explorer = webBrowser as InternetExplorer; try { //agganciamo document complete explorer.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(explorer_DocumentComplete); //agganciamo beforeNavigate explorer.BeforeNavigate2 += new DWebBrowserEvents2_BeforeNavigate2EventHandler(explorer_BeforeNavigate2); } catch (Exception ex) { listBox2.Items.Add(ex.Message); } } catch (COMException) { } } }I tried, in the code above, to attach DocumentComplete and BeforeNavigate2 events to IE and I noticed that in this way DocuemtnComplete fires and BeforeNavigate2 not.
Where is my fault? Do I successfully attach these two events in that way?
Any help will be appreciated,
Pietro-devel
Pietro Recchilongo
To be more complete:
I implemented my DocumentComplete with the following signature:
private void explorer_DocumentComplete(object pdisp, ref object URL)
and BeforeNavigate2 as follows:
private void explorer_BeforeNavigate2(object pDisp, ref object URL, ref object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel)
Pietro-devel
- Editat de pietro-devel 8 martie 2012 11:41
Toate mesajele
-
12 martie 2012 03:39Moderator
Hello,
I hope this thread can help you
http://social.msdn.microsoft.com/Forums/nl-NL/ieextensiondevelopment/thread/20b16462-63bd-4df4-8f2f-900307252edeBest regards,
JesseJesse Jiang [MSFT]
MSDN Community Support | Feedback to us
- Marcat ca răspuns de pietro-devel 12 martie 2012 15:42
-
12 martie 2012 15:41
That solution perfect fits!
I implemented it in this way:
try { //allochiamo il nostro browser e diciamo che è IE object webBrowser; provider.QueryService(ref guid, ref riid, out webBrowser); this.explorer = webBrowser as InternetExplorer; explorer.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(explorer_DocumentComplete); axDocumentV1 = (WebBrowser_V1)this.explorer; axDocumentV1.BeforeNavigate += axDocumentV1_BeforeNavigate;If I did any mistake, please warn me!
Thank you very much,
Pietro
Pietro Recchilongo
- Marcat ca răspuns de pietro-devel 12 martie 2012 15:41
- Anulare marcare ca răspuns de pietro-devel 12 martie 2012 15:42