Xdialog, HTML, and JavaScript - a Powerful Combination

Description

A brief guide to using xdialog, html, and javascript in combination.

This example show how you can:

  1. Embed a browser object in an Xdialog.

  2. Respond to events in the HTML with Xbasic.

  3. Construct Javascript code using Xbasic and then send that code to the browser object where it is executed.

Example 

Create a ContextEval object and give it a unique name so that it is possible to run multiple instances of this script.

dim XbasicCtxName as c
XbasicCtxName = "MyContextEval" + time("hms3")
' dim ContextEval object
dim XbasicCtx as p
XbasicCtx = ole.create("a5contexteval.contexteval")
' attach then ContextEval object to Alpha Five
XbasicCtx.Attach(*Xbasic_eval_context_attach())
Xbasic_eval_context_add(XbasicCtxName)

Set up the HTML that will be displayed in the browser object on the Xdialog. The ContextEval name is represented by the place holder: {CTXEVALNAME}.

dim html as C
html = <<%html%
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Must set this property in order to make XP Themes render in IE ActiveX control. This control will allow the HTML and Alpha Five to communicate.

These functions handle communications with Xbasic. Grab the ContextEval object.

Notice when you click one of the buttons, Xbasic handles the event.

Type Javascript code in the textbox below.