X
24 Rate this article:
No rating

INTERNAL: Embeding the IDLDrawWidget ActiveX Control into MS Word

Anonym
Topic:
On Windows/NT, users have the ability to embed an IDL ActiveX Contronl (IDLDrawWidget) into Microsoft Word or PowerPoint. Discussion:
Because we're working in MS Word, it is necessary to create an initial event to get IDL started. Hence, the Start IDL button.

NOTE: In this case, we recommend printing through IDL using the IDLDrawWidget.ExecuteStr method rather than via VB's printform(). This way, we only print the IDL plot graphic and not the entire form.

Screencap1


To begin with, open a new doc in MS Word. From the 'View' icon, select 'Control Toolbox'. This will display MS Word's GUI toolbox along the right boarder of the IDE. **You will be moving in and out of design mode -- see MS Word OnLine Help for more information** Use these tools to add buttons to the doc -- selecting a location on the doc and then clicking on the button icon from to the toolbox will insert the control. I add three buttons for this example using this method.

ScreenCap2


Once the three command buttons have been added and named, we need to add IDL's ActiveX Control. To do this, press the wrench/hammer icon displayed in the Toolbox and scan the resulting menu for 'IDLDrawWidget Control 2.0'. Once the control appears in the doc, position and resize it so that an IDL shaded surface will fit in it nicely.

3


Next we need to add functionality to each of the buttons. Select the 'Start IDL' button and then do a right-click to 'View Code'. This will bring up the VB src associated with the button in MS Visual Basic Studio.
Add the following code:

'Set the IDL Path
IDLDrawWidget1.IDLPath = "D:\RSI\IDL53\bin\bin.x86"

'Initialize IDL
IDLDrawWidget1.InitIDL IDLDrawWidget1.hWnd

'Create a IDL Draw Wiget
IDLDrawWidget1.CreateDrawWidget
'Execute a simple IDL command
IDLDrawWidget1.ExecuteStr ("loadct,5")
IDLDrawWidget1.ExecuteStr ("shade_surf, dist(40)")

ScreenCap4


This is the MS Visual Basic Editor with the new code added from last screen shot. Now minimize this window so that you're back to the MS Word doc that has our buttons on it. Right click on the remaining two buttons (Print and Exit) and add the following code respectively:


'Handle the printing using IDL
IDLDrawWidget1.ExecuteStr ("set_plot, 'printer'")
IDLDrawWidget1.ExecuteStr ("shade_surf, dist(40)")
IDLDrawWidget1.ExecuteStr ("device, /close")

'End the Session
IDLDrawWidget1.DoExit


ScreenCap5


Press the 'Start IDL' Button. Now a shaded surface should be rendered in the IDLDrawWidget window. Test 'Print' and 'Quit.' Now this doc can be saved and anyone running IDL can execute it as long as their IDL distribution path is set up like we defined in the 'Start IDL' initialization routine:

IDLDrawWidget1.IDLPath = "D:\RSI\IDL53\bin\bin.x86"Solution:
[Edit this field in the IDL-based Tech Tip Editor, v3]