devxlogo

DDE and HTML

DDE and HTML

Question:
How can I get data from a Dynamic Data Exchange (DDE) server and display it in a Web page? On a Visual Basic form, I can use a text box and use Network Dynamic Data Exchange (NetDDE) with the link topic \K_ddeNDDE$|icomwdrv-LCNS_Link$, and my link item is T4:0,L1,C1. The data is automatically linked and displayed in the text box. This approach also works with a Visual Basic ActiveX document, which is then hosted by Internet Explorer 4.0. How can I accomplish the same thing in HTML or VBscript on a Web page? Is DDE supported by DHTML or VBScript? If not is there another way to accomplish the same thing?

Answer:
You should be able to go through the IE 4 object as a DDE client just as you would with any other application, though I have to admit ignorance as to which specific topics IE4 publishes. However, I’m at a little bit of a loss to understand why you would want to go through DDE in the first place. You would get far better control if instead of using DDE you actually used the Internet Explorer Automation object itself, either in its form as a stand-alone application, or through the WebBrowser control.

In order to work with the Internet Explorer application, you will first need to create a reference to the SHDOCVW.DLL library. To do this, select Project–>References from the menu, then check Microsoft Internet Controls. Once you’ve done this, you can then dimension a reference to the IE object when you declare your variables:

Public IE as InternetExplorer

Or, if you want to catch an event within a given browser (and are using VB5 or above):

Public WithEvents IE as InternetExplorer 

Note that you while you’re declaring references, you may also want to declare one for MSHTML.TLB (Microsoft HTML Object Library), which gives you access to the entire IE Document Object Model. The following code, for example, will launch a new browser window, and send output to it, from VB:

Option ExplicitPublic WithEvents IE As SHDocVw.InternetExplorerPublic WithEvents Doc As HTMLDocumentPublic WithEvents Wnd As HTMLWindow2Private Sub Form_Load()    Set IE = New InternetExplorer    IE.Visible = True    IE.Navigate2 "file:///c|/windows/system/blank.htm"End SubPrivate Sub IE_DocumentComplete(ByVal pDisp As Object, URL AsVariant)    Dim Body As HTMLBody    Set Doc = IE.document    Set Wnd = Doc.parentWindow    Set Body = Doc.Body    Body.innerHTML = "

Test

This is a test

" Wnd.alert ("This is a test")End Sub

The blank.htm document is just that: an HTML file that contains the barest minimum information for an HTML file and will be contained in your System directory (Windows NT users may have a different path). Once you browse to this document, the IE routine will raise an event flag on DocumentComplete, at which point you can assign variables to contain references to the document object, the document’s window, and the Body object of the document to produce any output that you need.

Note that the script languages don’t support the notion of DDE at all. You can get a reference to some of the OLE DDE type verbs that the control publishes by using the ExecWB method of IE. But for the most part any benefit that you get out of using DDE here is far outweighed by the sparseness of DDE versus the richness of the Document Object Model.

Hope that answers your question.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist