How do I use a script to program the Chem3D ActiveX Control?
Like all other AcitveX controls, you can use a script to program it in your web pages. You can also use the Chem3D ActiveX Control to develop your own program, in VB, VC, C# or other windows IDE. But here we will only focus on web pages.
<TITLE>My First Chem3D Model Page</TITLE>
In this sample, the model is displayed in "Cylindrical Bonds" mode. Now we want user can change the display type to "Sticks" mode:
In order to do this, we have created a javacript function, onShowAsSticks(). In this function there is only one statement, my3dobj.setDisplayType(1). my3dobj is the reference to the Chem3D ActiveX Control object that created above.
NOTE: In order to refer to the Chem3D object you create, you MUST specify the *id* parameter.
setDisplayType is the method define in Chem3D ActiveX control, which set the display type. Here 1 means *Sticks*.
To let user can call this function from the page visually, we create a button. When user hits this button, onShowAsSticks() is called to set the Chem3D ActiveX Control object to Sticks model.
OK. You can use the browser to test this page. It works! You may want it be more powerful -- can I set any model type? Yes, of course you can:
Try this page again. It's really cool?! Using your creativity, your pages will very very powerful.