WebBrowser control has been an integral component of MS Windows following the browser wars with Netscape. Starting with SuperMemo 98, it has also underlain the HTML component in SuperMemo. With Internet Explorer 5.0, MSHTML DLL encapsulated in WebBrowser control implemented DHTML capabilities and provided access to HTML editing via the DOM model. As of Internet Explorer 5.5, MSHTML library superseded its predecessor DHTMLEdit control. Programmers are thus now able to provide HTML parsing, rendering and WYSIWYG editing without investing untold development hours or relying on third party components. Most HTML editors available on the market today capitalize on the WebBrowser control to provide HTML preview. They also often employ the MSHTML Editor for HTML editing. Microsoft software also relies heavily on the WebBrowser control. Apart from Internet Explorer, it is also used in Microsoft Money or in MS Outlook (Outlook Today page). In other words, investment in WebBrowser control is not likely to be wasted. This component is to remain an integral part of Windows. Not even the anti-trust action against Microsoft posed or poses any danger to this important component.
As of Internet Explorer 6.0, the reliability of MSHTML module became sufficient for an important decision: SuperMemo 2002 transferred the default incremental reading process from the old reliable RTF format to the HTML standard.
The RichEdit control (RTF text) has been a part of Windows for many years. Despite its multiple limitations, the component has been very stable and well documented. This still isn't true of the WebBrowser control. This relatively new implementation shows multiple stability problems. Naturally, you will not experience these in Microsoft products. Presumably, MS programmers are able to internally communicate the problems with the control in between individual development teams. Programmers outside Microsoft do not have this comfort and have to live with numerous problems posed by the control. In addition, the Delphi Active X control wrapper that encapsulates the WebBrowser control is incompatible with some of WebBrowser behaviors. In other words, WebBrowser is a blessing that may also cost lots of tribulation on the part of those who decide to encapsulate it in software for mass consumption.
SuperMemo 2002 successfully employs WebBrowser control in incremental reading. You can now view the source code that is used in SuperMemo to encapsulate TWebBrowser as a dedicated TWeb object. See: www.supermemo.com/source/tweb.htm
You can easily notice that 60-80% of the presented code includes various workarounds needed to make WebBrowser work within the framework of a SuperMemo component. Although the unit was written in two short months, resolving all bugs and problems took another six months that ultimately delayed the release of SuperMemo 2002.
The HTML encapsulation hierarchy in SuperMemo is now quite complex and provided for quite a development challenge as well ... as some stability problems that show particularly on non-NT platforms. The MSHTML DLL is encapsulated by WebBrowser which adds such functions as search, navigation, in-place hyperlinking, etc. WebBrowser is encapsulated in Delphi as TWebBrowser a standard VCL component with standard VCL interface. However, as you can see in the source code, the way OLE child controls live in VCL components resulted in the need to re-write the keyboard handler nearly from scratch. TWebBrowser is in turn encapsulated as TWeb (see the code), which is a SuperMemo-specific web browser component. TWeb implements functions such as LoadFile, SetFont, SetText, Paste, Undo, SelectAll, Find, etc. TWeb is then embedded in a TComponentEditor (derived from Delphi's TForm class). TComponentEditor is used to host all SuperMemo components in editing and dragging modes. Finally, components are hosted by the scrollbox of the element window (TForm) in the main SuperMemo program. The element window and the component editor implement the remaining functions such as ClozeDeletion, ExtractSelection, Highlight and close to 1000 other element- or component-specific functions.
The presented collection can be used to learn some of the most basic objects, methods, properties and commands that can be used to manipulate the DOM interface of the WebBrowser control. Having learned the presented collection, and re-using the presented source code, all Delphi programmers should be able to add rudimentary HTML capability to their software with minimum effort