Internet Explorer Programming Brief (1) WebBrowser or WebBrowser

xiaoxiao2021-03-06  64

Keywords: WebBrowser, WebBrowser_v1, NewWindow, NewWindow2, NewWindow3, InewindowManager

There is always a "two" webbrowser on your machine, a webbrowser, another called WebBrowser_v1, its ClassID is as follows:

Class_WebBrowser: tguid = '{8856F961-340A-11D0-A96B-00c04FD705A2}'; class_webbrowser_v1: tguid = '{EAB22AC3-30C1-11CF-A7EB-0000c05Bae0b}';

Their corresponding interfaces are IWebBrowser2 and IWebBBBBROWSER. What is the problem we use? According to Microsoft's recommendation, we should try to use the former because the latter is reserved for compatible Internet Explorer 3.x (although it can respond to events from Internet Explorer 3.x, 4.x, 5.x, 6.x) The corresponding IWebBrowser and IWebBrowSerapp interfaces should also be discarded.

Since Internet Explorer 3.x is long, the events provided by WebBrowser_v1 are less pitiful, but it is worth mentioning that it provides two events onnewwwindow and ONFrameBeForenaviGate have almost the same parameters as OnBeforenavigate:

OnBeforeNavigate (BSTR URL, long Flags, BSTR TargetFrameName, VARIANT * PostData, BSTR Headers, BOOL FAR * Cancel) OnNewWindow (BSTR URL, long Flags, BSTR TargetFrameName, VARIANT * PostData, BSTR Headers, BOOL FAR * Processed) OnFrameBeforeNavigate (BSTR URL Long Flags, BSTR TargetFramename, Variant * PostData, BSTR Headers, Bool Far * Cancel

So using webbrowser_v1 allows our browsers to easily capture their URLs and related data when there is a new window. If you set the processed to True, you can cancel the pop-up of the new window. Similarly, processing Frame is also easier than in WebBrowser.

However, the fatal weakness of WebBrowser_v1 is that it does not support advanced interfaces, such as IDochostuiHandler, even if we implemented the IDOCHOSTUIHANDLER interface, it will not be called by WebBrowser_v1. So I hope to implement XP interface topics in their own browser, extending advanced controls such as IE DOM (Document Object Model), it is certainly not to choose WebBrowser_v1.

Handling a new window is a very troublesome, I don't know why Microsoft removes the parameters such as the URL in the new version of the Onnewwwindow2 event, and the ONNewWindow2 event cannot completely capture all new windows to open. But if Windows XP SP2 is installed, the benefits come back.

Windows XP SP2 has been upgraded to Internet Explorer 6, and provides a new event OnNewWindow3. It happens before the OnNewWindow2 event, which contains the URL of the new window that allows us to filter the new window, plus the INewindowManager interface, It is the basis for implementing the filter ad window in Windows XP SP2. Reference: MSDN: 185538 HOWTO: CAUSE NAVIGATION TO OCCUR in Same Webbrowser Window

Quote Address: Internet Explorer Programming Brief (1) WebBrowser or WebBrowser_v1

转载请注明原文地址:https://www.9cbs.com/read-119829.html

New Post(0)