Feature #12056
Microsoft WebBrowser ActiveX control: script execution and document access
0%
History
#1 Updated by Greg Shah about 1 month ago
Microsoft WebBrowser ActiveX control: script execution and document access¶
Project: User Interface
Problem¶
The Microsoft WebBrowser control (Shell.Explorer, CLSID {8856F961-340A-11D0-A96B-00C04FD705A2}) is used to embed maps, a hosted login page and chart panes. Members used: Navigate, Document:parentWindow:execScript (two-way JavaScript calls), Document:Script:<name> to read values back from the hosted page, ExecWB to print, and position and size. Events: TitleChange and DocumentComplete.
FWD's HTML-BROWSER renders a live iframe with navigation, loading from a string, printing, a postMessage bridge and navigation events. It has no execScript and no access to the page from the server.
Work¶
- Map the control onto HTML-BROWSER with an alias table.
- Add a script execution bridge for
execScriptand for reading script values from the page, over the postMessage bridge, with a completion event so that the 4GL can wait for the result. - Map
ExecWBprinting,TitleChangeandDocumentComplete. - Register the control's CLSID in the OCX registry (
ocx-registry.xml), mapping it to the target widget, as #11919 did for ctToolBar. - Decode the design-time state the control keeps in the
.wrxstorage at conversion time, so that it exists after conversion. - Implement the members and events listed above on the target, with the vendor's semantics: argument types, return values, defaults, and the order in which events fire. Members of the type library that are not used become no-ops with a conversion warning, as the OCX pipeline already does.
- Follow the OCX emulation playbook attached to #11919: an OpenEdge test program with goldens for each member and event, recorded input sequences for the interactive parts, and Lyra automation.
- Update the gap marking and the OCX registry documentation.
Testcases¶
Each member and event above, exercised on Windows OpenEdge with the real control to produce goldens, then run against the FWD replacement on the web and Swing clients. The vendor help files are the reference where behaviour cannot be observed directly.
#2 Updated by Greg Shah 8 days ago
The same project also uses the .NET Windows Forms browser class, System.Windows.Forms.WebBrowser, from 4GL. It is never shown in a form: it loads a local HTML file, waits for it, and prints it, or shows the page setup dialog:
oBrowser = NEW System.Windows.Forms.WebBrowser().
oBrowser:DocumentCompleted:Subscribe("onDocumentCompleted").
oBrowser:Url = NEW System.Uri(cHtmlFile).
...
PROCEDURE onDocumentCompleted:
DEFINE INPUT PARAMETER sender AS System.Object NO-UNDO.
DEFINE INPUT PARAMETER e AS System.EventArgs NO-UNDO.
oBrowser:Print().
END PROCEDURE.
The members used are the constructor, Url (set, through System.Uri), the DocumentCompleted event, Print() and ShowPageSetupDialog(). All of them are the work this task already does for the ActiveX control, so it should cover this class too:
- Map
System.Windows.Forms.WebBrowseronto the same HTML-BROWSER support in the conversion, withSystem.Uri(character)accepted as the URL, andSystem.ObjectandSystem.EventArgsaccepted as the event handler's parameter types. - Raise
DocumentCompletedfrom the same document-completion event as the ActiveX control'sDocumentComplete. Print()prints the loaded page the same way as the ActiveX control'sExecWBprint: the user prints it from their browser.ShowPageSetupDialog()and page setup in general: there are no Internet Explorer registry settings in a converted system. Use FWD's own print options (page size, orientation and margins, asPDFPageSetupalready models), and letShowPageSetupDialog()edit them for the session.- Allow the browser object to exist without being shown, since this code never places it on a frame.
Testcases: load a local HTML file through Url, receive DocumentCompleted and call Print(); ShowPageSetupDialog() followed by Print(), checking that the chosen page settings apply; the same flow with a missing file.