MORE INFORMATION
NOTE: The classes in the com.ms.wfc.html.om.* WFC package
are unsupported and are subject to change. This article provides an alternative to generating, packaging, and distributing Java wrappers for the Shdocvw DLL. If you find that this package is missing or doesn't expose the Shdocvw methods that you need, try generating your own wrappers per the instructions in this article.
Before WFC's
HTMLControl class, Java programmers who wanted to embed the Internet Explorer browser into their applications needed to generate Java COM wrappers for the control by using the Jactivex utility (Microsoft's ActiveX Control importer for Java, which is available with Microsoft's SDK for Java, version 3.2). HTMLControl class has eliminated this need by allowing the user to simply drag and drop a control onto a form.
Actually, the need to generate Java COM wrappers wasn't eliminated. The Java COM wrappers were generated ahead of time and included in Visual J++ 6.0 as a simple WFC control.
HTMLControl has the Internet Explorer COM object at its core. As such, you have access to the public methods of that object. The following code sample lists a few of the most commonly requested public methods. See the
MSDN Library entry for IWebBrowser2 for more information about the C++ equivalent of these and other methods available from the Internet Explorer COM interface.
Here's a small sample of the IWebBrowser2 public method Java prototypes:
public synchronized void GoBack();
public synchronized void GoForward();
public synchronized void GoHome();
public synchronized void GoSearch();
public synchronized void Navigate(String URL, Variant Flags, Variant TargetFrameName, Variant PostData, Variant Headers);
public synchronized void Refresh();
public synchronized void Refresh2(Variant Level);
public synchronized void Stop();
public synchronized boolean getBusy();
These methods (and others) are available directly from
HTMLControl because it is derived from com.ms.wfc.html.om.shdocvw.WebBrowser.WebBrowser, which is the Java COM wrapper for Internet Explorer's browser COM object (package com.ms.wfc.html.om provides Java wrapper classes for the Dynamic HTML object model).
To have your
HTMLControl object display the user's default Internet Explorer homepage, simply include a statement similar to the following:
myBrowserObj.GoHome();
Unfortunately, the documentation for the
WebBrowser control is lacking, and Visual Studio's IntelliSense doesn't cover it well either.
For a complete list of methods available to you from the Internet Explorer browser control, you can do what the WFC developers did. You can generate your own Java COM wrapper for Internet Explorer using the Jactivex utility. From a command prompt type something similar to the following (folders may differ based on operating system and settings. The following would be a typical command-line):
C:\Microsoft SDK for Java 3.2\BIN\JACTIVEX.EXE /wfc /d c:\winnt\java\trustlib c:\winnt\system32\shdocvw.dll
The above command should generate dozens of java files and a couple of folders all within a folder named Shdocvw. The only file that you're interested in is "\Shdocvw\WebBrowser\WebBrowser.java," which is the file that contains the Java prototypes to the public methods of the Internet Explorer browser COM object.
NOTE: If you plan to use WFC's
HTMLControl class, you don't need this file other than as a supplement to the MSDN Library.
REMINDER: For those of you who are more COM savvy,
HTMLControl has a method named getOcx( ) that returns the IUnknown interface for the underlying ActiveX (COM) control.