Michael,
You asked if it is possible for Visual Basic to communicate with a Jmol
Applet that is appearing within a web page that is a window in the VB
application. The answer is yes, definitely.
If someone knows better than I how to use the webBrowser.execWB()
command, that's probably your best bet, but I haven't
had any luck using it to do much more that refresh the whole page.
My crude solution is a combination of AJAX and web services:
To give directions to the applet from VB you can use AJAX
------------------------------------------------------------
1) create a VB application and add a "Microsoft Internet Controls"
WebBrowser activeX control.
2) have VB load your page into that window. In the web page that has the
Jmol applet, do the following:
2.1) add an empty script tag with the id "jmolcmd"
<script type="text/javascript" id="jmolcmd"></script>
2.2) add a function on that page the polls that script tag for AJAX
commands:
function getCommand(){
document.getElementById("jmolcmd").src="jmolcmd.js"
setTimeout("getCommand()",500)
}
What this is doing is going back to the server (your hard drive) every
1/2 second to get whatever is in jmolcmd.js and execute it.
You just have VB drop any command you like into the file "jmolcmd.js" in
the same directory as
the web page and it will run on the web page. So, for example, if you put
jmolScript("background red")
into jmolcmd.js, that command will be run every 500 milliseconds in the
applet.
Obviously, this is not quite what we want.
2.3) So I recommend a second function:
lastid = null
function doScript(thisid, script) {
if (thisid==lastid)return
lastid=thisid
jmolScript(script)
}
Now the script will only run if the id has changed. You might, in VB,
then do the following:
sub callJmol(cmd)
Dim s as String
s = "doScript(" & Rnd() & ",test)"
Open "jmolcmd.js" For Output As #1: Print #1, s: Close #1
end sub
With the page polling for a script, and VB writing script at your
leisure, VB is effectively controlling the page.
This is very straightforward AJAX.
To return data from the applet to the VB application use a commandsock
control
---------------------------------------------------------------------------------
If it were my project what I would is add a winsok TCP/IP control to my
VB application. That would then listen on a port. You would have your
web page
JavaScript submit forms to "localhost" on the port, and your VB
application would be
in direct communication with the web page, receiving textarea data, for
example.
-Bob Hanson
Michael Marden wrote:
> Hello Bob,
>
>
>>>>> Question. Is VB and Jmol a good combination? I already use a
>>>>> web-browser window within my program to obtain info from the
>>>>> outside world. Could Jmol be driven this way?
>>>>> Advice or an example would be greatly appreciated.
>>>>
>>>>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users