.net - C# WebBrowser - Help Adding Flags to Navigate Method -
i'm not greatest com objects but, have need extend webbrowser control support flags in navigate method (specifically prevent reading/writing cache).
from gather i'll need implement iwebbrowser2 extent. can implement navigate method or need define methods in interface?
i've found examples attaching/detaching event sink extend events of web browser little around actual methods.
can use underling activexinstance of webbrowser control? if create class implements iwebbrowser2::navigate, , cast variable class, assigning webbrowser control activexinstance attempt navigate com exception hresult e_fail
i found not sure if underlying control still shdocvw didn't see in com objects (target fw .net 3.5): web browser handle pop ups within application
internal shdocvw.webbrowser activexwebbrowser { get; private set; }` new public void navigate(string url) { this.navigate(url, axnativemethods.webbrowsernavigateflags.noreadfromcache | axnativemethods.webbrowsernavigateflags.nowritetocache, string.empty, new byte[] { }, string.empty); } public void navigate(string url, axnativemethods.webbrowsernavigateflags flags, string targetframename, byte[] postdata, string headers) { this.activexwebbrowser = (shdocvw.webbrowser)this.activexinstance;` object flagsobj = (flags == axnativemethods.webbrowsernavigateflags.none) ? null : (object)flags; object targetframenameobj = targetframename; object headersobj = headers; object postdataobj = postdata; activexwebbrowser.navigate(url, ref flagsobj, ref targetframenameobj, ref postdataobj, ref headersobj); }
this perfect use case extension methods. basically, allow define methods in static class appear bound directly type being extended, , behave public instance methods on type, except public or internal (in case of friend assemblies or extension class , extended class being in same assembly) available.
here's example snippet:
public static class webbrowserextensions { public static void navigate(this iwebbrowser2 browser, string url) { browser.navigate(url, /* fill in arguments necessary*/) } }
Comments
Post a Comment